-
Notifications
You must be signed in to change notification settings - Fork 189
Windows x64 Compiler Setup and Build Environment
This page in fact contains two guides, a newer one, which gives you a straight forward path to a sucessful build in next to no time on a new machine. The second part is an older guide by Kevin, K2AAE, which is more detailled and flexible and may give you an idea how to setup up things in a more complex scenario. Beginners should use the first guide.
This guide describes how to setup the enviroment and get the first build of the UHSDR firmware in next to no time. It assume you follow the guide exactly. It also assumes that you don't have Git for Windows (or some of the other stuff) already installed with non-default settings. In this case, the guide my or may not work.
The base for this was the following document: https://eclipse-embed-cdt.github.io/plugins/install/
- Create a dedicated folder for downloading and install everything. I use
C:\Users\micky\uhsdr-dev
in this guide. - Create two more folders inside
downloads
andinstalls
- Inside
installs
create one folder callednode
- The machine must be connected to the Internet for the whole setup time. Later no permanent internet connection is required.
These are all files you need to download. Download all of them ahead of time.
- If you don't have Java installed on your machine, download "Java for Windows" from (https://www.java.com/)
- Download "64-bit Git for Windows Setup" (https://git-scm.com/download/win) into
downloads
- Download latest "Eclipse IDE for Embedded C/C++ Developers" (https://www.eclipse.org/downloads/packages ) into
downloads
. Use theWindows x86_64
package. - Download Node.js release ZIP from https://nodejs.org/en/ Select latest LTS Release. Use the 64 bit zip
Newer Eclipse releases now include their own Java, hence you will not need to install Java anymore in order to use Eclipse. In fact, an installed Java may even cause Eclipse to fail on startup if Java is too old.
This needs administrator rights.
- Just run the downloaded installer, leave all settings on their defaults.
- Open Windows file explorer on the folder "C:\Users\micky\uhsdr-dev".
- Now do open the context menu on this folder (right click). There should be an entry called "Git Bash Here". Select this one
- A new windows should pop up and great you with a command prompt. Type
ls
and enter and it should listdownloads
andinstalls
- Close window.
- If any of this does not work, do not proceed, seek help.
We use node.js to run an simple package manager called XPM
To keep things simple, we just install node.js locally. If you have other node.js installs, this may be a problem or not. You may skip install and go to XPM Install but you have been warned. This is not supported by this guide.
- Goto "downloads" folder.
- Unzip node.js download ZIP
- Copy the contents of the folder with program
node.exe
ornode
into the previously created folderinstalls/node/
. Now node.exe should be found ininstalls\node
- Open Git Bash or command prompt on
installs\node
- If any of this does not work, do not proceed, seek help.
- type
./npm install --global xpm@latest
- This should download and install
xpm
- You now should see xpm and xpm.cmd inside this folder
- Keep the Bash window open.
- If any of this does not work, do not proceed, seek help.
In the bash window from the previous step, run the following commands. Do it one by one. These download and install required packages just in the right spot!
- Use the Windows Bash terminal. It must be in
installs\node
(the prompt shows this)
./xpm install --global @xpack-dev-tools/windows-build-tools@latest --verbose
./xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest --verbose
./xpm install --global @xpack-dev-tools/qemu-arm@latest --verbose
./xpm install --global @xpack-dev-tools/openocd@latest --verbose
./xpm install --global @xpack-dev-tools/cmake@latest --verbose
./xpm install --global @xpack-dev-tools/ninja-build@latest --verbose
./xpm install --global @xpack-dev-tools/meson-build@latest --verbose
- If any of this does not work, do not proceed, seek help.
- Unzip the Eclipse Embedded CDT ZIP
- Move (or copy) the folder
eclipse
toinstalls\eclipse
- Start eclipse by running the program
eclipse.exe
oreclipse
insideinstalls\eclipse
- Enter
C:\Users\micky\uhsdr-dev\workspace
when asked for a workspace location - You should see a tool opening, with a welcome screen.
- If any of this does not work, do not proceed, seek help.
- Goto "downloads" folder.
- Unzip gcc-arm-none-eabi-xx.ZIP
- Copy the contents of the folder to
installs\GCC
- Set the path in Eclipse to point recommended toolchan folder
Window\Preferences\MCU\Global Arm Toolchain Paths\Toolchain folder
set toinstalls\GCC\bin
The reason for using somewhat outdated toolchain is to make binaries smallest size possible, also latest version of compiler produces errors during build preventing creation of binaries.
We now run a test build using the "official" github repo directly. This is not really suitable for a contributor, but is the best way to test the setup.
Contributors should replace the path below with the path to their own forked clone of the UHSDR repository in Github. See the Contributing.md for more info on this
- In Eclipse select "Import", "Git", and use "Clone URI"
https://github.com/df8oe/UHSDR.git
- In the dialogs do not specify a password or user, even if Eclipse fills these fields.
- Import at least the branch
active-devel
but you may also import all branches if you like. - You will see two projects listed for import into workspace. Select "uhsdr/mchf-eclipse". The other project is not for the Eclipse Embedded CDT.
- If any of this does not work, do not proceed, seek help.
We don't need to add any settings to our Eclipse, GNU MCU will find all tools by itself since we installed them where GNU MCU Eclipse expects them.
- Select
Project
->Build Configurations
->Set Active
->DebugLibMCHF
- Eclipse will start building the library, you'll see some output in the console window in the lower part.
- This should finish without error.
- If any of this does not work, do not proceed, seek help.
- Select
Project
->Build Configurations
->Set Active
->DebugMCHF
- Eclipse will start building the firmware, you'll see some output in the console window in the lower part.
- This should finish without error.
- The resulting firmware binary is inside "DebugMCHF". Click on this folder in Eclipse, open context menu (right click) and click on the button behind the file name, this will open the Windows explorer on this folder.
- If any of this does not work, do not proceed, seek help.
- You can speed up build time by selecting multiple parallel builds by setting
Project\Properties\C/C++ Build\Builder Settings\Builder type:
toExternal builder
and then inBehavior
setEnable parallel build
toUse optimal jobs
which usually refers to your physical processors available in Windows. This setting speeds up compiler by increasing number of running compilation instances at the same time. - Opening in Eclipse some large source files such as ui_driver.c may cause display of syntax highlighting not working poperly, try to increase the scalability limit from default 5000 lines to lets say 25000. You can find the setting in
Window\Preferences\C/C++\Editor\Scalability\Scalability mode detection
.
That's all, folks!
Sunday, September 17, 2017
Over the last month I've tried different ways to try and setup gcc but have had issues with ST's free stuff. I found GNU MCU Eclipse and tried it but never got it to work, no hello world joy. I found some time to walk through the site at GNU MCU and cherry picked what I thought was needed:
- Do Not add the path to the environment of anything - This from GNU MCU Eclipse.
I have Windows 10 X64, however the instructions apply equally to Windows 7 and Windows 8 64 bit! Windows 32bit users cannot follow all of it and have a more complicated setup as GNU MCU Eclipse does not release 32bit Eclipse packages anymore.
This is the instructions: for X64 download the X64 software. That is x64 for Java and almost all other modules.
-
Java JRE
- Get the latest (64bit) Java from (https://www.java.com/en/download/win10.jsp).
- Install and test.
-
Get The latest recommended ARM tool chain
- Download it from (https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads). You may either use the installer
gcc-arm-none-eabi-X-20XX-qX-xxxxx-win32-sha2.exe
for Windows 7 or newer or the zipgcc-arm-none-eabi-X-20XX-qX-xxxxx-win32.zip
. Yes, there is only a 32bit variant of the tool chain, no 64 bit. The gcc-arm-none-eabi-8-2018-q4 win32-xxx packages are broken and don't work! Install the previous (or newer releases if they appear). Not this one. - Install it in the default location or unzip the zip and remember the path.
- Download it from (https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads). You may either use the installer
-
Get the Windows Build Tools
- Download from here: (https://github.com/gnu-mcu-eclipse/windows-build-tools/releases) . Scroll down to the downloads and pick the newest win64 zip version to download.
- Unpack it at a convenient location and remember the path where you unpacked it.
-
Get real-time debugging and direct flashing tools
-
OpenOCD (required for ST-Link)
- Download the latest version
gnu-mcu-eclipse-openocd-X.XX.X-X-XXXXXXXX-XXXX-dev-win64-setup.exe
from here: (https://github.com/gnu-mcu-eclipse/openocd/releases) - Install it and remember the path where you installed it.
- Download the latest version
-
J-Link (optional, requires J-Link debugger) If you own (or plan to getting a) J-link debugger (or want to use a reflashed ST-Link):
- Get the J-link stuff (http://www.segger.com/jlink-software.html), current version is
JLink_Windows_V620a.exe
as of 9/17/2017. - Install it and remember the path where you installed it.
- Get the J-link stuff (http://www.segger.com/jlink-software.html), current version is
-
-
QEMU (Optional, not used)
- Download the latest version
gnuarmeclipse-qemu-win64-x.x.x-20xxxxxxxxxx-dev-setup.exe
from here: https://github.com/gnu-mcu-eclipse/qemu/releases. - Install it and remember the path where you installed it.
- Download the latest version
-
GNU MCU Eclipse and Eclipse:
- Download the latest version
20XXXXXX-XXXXXX-gnumcueclipse-X.X.X-XXXXXXX.win32.x86_64.zip
from here (https://github.com/gnu-mcu-eclipse/org.eclipse.epp.packages/releases/) . - expand the zip to the ROOT of your drive (or within a folder path) with a rather short length. Expand may break during expansion with Filename too long if you try to expand in a folder with a too long name.
- Download the latest version
- Double click C:\eclispe\eclipse.exe (or where you unpacked the GNU MCU Eclipse package) and leave it alone for a few minutes.
- then go to: Help/Check for Updates and install any updates.
- Finally go to
Window/Preferences/MCU/Global Arm Toolchains Paths
and set up the path to the previously installed tools.
My tool chain from above was (replace with your installation paths and the "bin" at the end of most paths):
Settings Name | Value(s) | Comment |
---|---|---|
GNU Tools for ARM Embedded Processors | C:\Program Files (x86)\GNU Tools ARM Embedded\7 2018-q2-update\bin | I used the installer here |
Global Build Tools Path | Folder: C:\Users\kevin\GNU MCU Eclipse\Build Tools\2.11-20180428-1604\bin | I unpacked in my user directory, you need to enter the full path to the bin directory! |
Global OpenOCD Path | Executable: openocd.exe, Folder: C:\Program Files\GNU ARM Eclipse\OpenOCD\0.10.0-10-20181020-0522\bin | Required for real-time debugging with ST-Link |
pyOCD | - | not used |
Global QEMU Path | Exectutable: qemu-system-gnuarmeclipse.exe, Folder: C:\Program Files\GNU ARM Eclipse\QEMU\2.8.0-201612271623-dev\bin | optional, not used |
Global SEGGER J-Link Path | C:\Program Files (x86)\SEGGER/JLink_V620a\ | optional, only if using a J-Link compatible debugger, not required for ST-Link |
The Workspace setting override Global - Leave blank unless you know what you are doing. And never change these settings in the UHSDR project itself, leave also blank to use global or workspace settings.
Create a Hello World Project to test:
- Go to
File/New/C Project
- Enter Project name
Hello
- Select Hello World ARM C Project
-
Next
and fill in the blanks Next
- Select
GNU ARM Cross Toolchain
Finish
- Select menu item
Project/Build All
. You shouldn't get any errors and the ouput in the build console (lower right) should look like this:
17:24:38 **** Build of configuration Release for project Hello ****
make all
Building file: ../src/main.c
Invoking: GNU ARM Cross C Compiler
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g -std=gnu11 -MMD -MP -MF"src/main.d" -MT"src/main.o" -c -o "src/main.o" "../src/main.c"
Finished building: ../src/main.c
Building target: Hello.elf
Invoking: GNU ARM Cross C Linker
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g -Xlinker --gc-sections -Wl,-Map,"Hello.map" --specs=rdimon.specs -Wl,--start-group -lgcc -lc -lc -lm -lrdimon -Wl,--end-group -o "Hello.elf" ./src/main.o
Finished building target: Hello.elf
Invoking: GNU ARM Cross Create Flash Image
arm-none-eabi-objcopy -O ihex "Hello.elf" "Hello.hex"
Finished building: Hello.hex
Invoking: GNU ARM Cross Print Size
arm-none-eabi-size --format=berkeley "Hello.elf"
text data bss dec hex filename
8440 2416 296 11152 2b90 Hello.elf
Finished building: Hello.siz
17:24:39 Build Finished (took 1s.125ms)
- First you'll need a Github account, after you login visit https://github.com/df8oe/UHSDR and in the top right click Fork.
- After you have your 'Fork' switch to your github account and select the new Git, click Clone and copy the URL.
- Open your local repository folder, I keep mine at C:\gits so I would cd gits. You can use git:
git clone https://github.com/YOURGITHUBREPOUSERNAME/UHSDR.git
which will clone your fork of the git to c:\gits\UHSDR or use GitKracken or Github Desktop to clone your git.
After several days I noticed my github fork was behind the main git, you can update it with:
- open command prompt or Git bash there / cd into any of your UHSDR firmware directories
- Only once:
git remote add upstream https://github.com/df8oe/UHSDR.git
- The actual update:
git pull --rebase upstream
But that only updates the local HD copy. After hunting for a means to update the forked git in github I found how to do this with Github Desktop.
- Branch drop down Merge into current branch... they list upstream/active-devel by selecting that as the current branch. I can Fetch all changes from DF8OE/UHSDR to my Github Local HD updating it to current, takes about 2 seconds,
- then the Github Desktop shows I have objects to Push, click on that and the changes are Pushed into your Github Git. You can do the same with the git command line:
- open command prompt or Git bash there / cd into any of your UHSDR firmware directories
- Just do
git push -f upstream
After cloning the git I followed the prompts from the startup page in Eclipse to Import project from Git, selecting local git. After setting Active DebugLibMCHF
and building I set Active DebugMCHF
and built the project resulting in:
16:22:15 **** Incremental Build of configuration DebugMCHF for project mchf-eclipse ****
make -j4 all
Building target: fw-mchf.elf
Invoking: Cross ARM C++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O2 -ffunction-sections -fdata-sections -flto -Wall -g3 -T "C:\UHSDR\mchf-eclipse\arm-gcc-link.ld" -Xlinker --gc-sections -L"C:\UHSDR\mchf-eclipse\DebugLibMCHF" -Wl,-Map,"fw-mchf.map" --specs=nano.specs -u _printf_float -o
--------snip ----- way to much information --
-lmchf-eclipse -lc -lm -lnosys
Finished building target: fw-mchf.elf
Invoking: Cross ARM GNU Create Flash Image
Invoking: Cross ARM GNU Print Size
arm-none-eabi-objcopy -O binary "fw-mchf.elf" "fw-mchf.bin"
arm-none-eabi-size --format=berkeley "fw-mchf.elf"
text data bss dec hex filename
447876 1992 89976 539844 83cc4 fw-mchf.elf
Finished building: fw-mchf.siz
Finished building: fw-mchf.bin
16:22:41 Build Finished (took 26s.186ms)
Excellent Work on the project build! I believe this is the first time I've install a compiler, downloaded a project and built the project without errors in 30 years.
Kevin K2AAE
- Supported SDR Hardware
- UHSDR: Manuals
- mcHF: Building your own SDR
- OVI40: Building your own SDR
- UHSDR: SW Installation on SDR
- UHSDR: Theory of Operation
- UHSDR: SW Development
- UHSDR: Supported Hardware
- UHSDR: Manuals
- Building a mcHF SDR
-
Building a OVI40 SDR
- UHSDR SW Installation
- Theory of Operation
- UHSDR SW Development