Monday, October 29, 2012

Prepare GNUARM compiler toolchain for Windows

Copied verbatim from

Look at the date. I'll update and modify this posting when/if I get around to it.

Prepare GNUARM compiler toolchain for Windows

GNUARM is a toolchain for developing ARM microcontroller projects based on open source compiler GCC.
GNUARM works on windows (requires Cygwin), Linux and MacOS. GNUARM doesn't have any GUI, but you can adapt any GUI that supports commands from command line. One of good project is WinARM where you get all tools needed in one package. Thiswill be discussed later.
GNUARM package consists of the GNU binutils, GCC compiler set and debugger (Insight for Windows and Linux, GDB only for MacOS). Newlib is used for the C library. With GNUARM yo uhave ability compile C and C++ programs.
Let's set up toolchain for windows environment. First of all download compiled toolset from
Download the newest GNUARM stabile compilation:
Then start installation:
  • Start window:
Gnuarm start install 
  • Accept license agreement:
Gnuarm license 
  • Select folder where do you want GNUARM to be installed. I recommend to select C:/GNUARM:
Gnu arm install location 
  •  Select the components. You can select all of them:
Gnuarm components 
  • Chose Start menu folder name:
Start menu of Gnuarm 
  • Select desktop shortcut to be placed. I highly recommend to check Cygwin DLL:
Gnuarm installation tasks
  • And press install..
  • Select checkbox in order to create system variable: PATH=c:\gnuarm\bin:
Gnuarm PAHT 
After we have GNUARM installed, download binutils from Download this archive and unpack all contents to c:\gnuarm\bin folder. Also You can download and put it in c:\gnuarm\bin folder if there is no any. Now we are ready to start building projects.
Lets try some test compilation. Just example download LPC2214 project package from and extract in any folder. In the package you’ll find following files:
  • lpc2214.h LPC2214 header. You can also download header files from
  • blink.c LED blink example routine.
  • boot.s The startup routine which is first executed after the CPU is reset. After it main function is called.
  • Makfile makefile
  • lpc2214-rom.ld The script file which used by linker. The start address size and the ROM/RAM is described. If there is needed - ROM binary is built.
  • setenv.cmd Configuration file, where you have to show path to C:\GNUARM\bin and bin C:\GNUARM\bin\utils
  • jtag_flash.exe The tool, which writes the flash by JTAG and executes on demand.
  • jtag_stub.exe The JTAG debugger for GDB/Insight.
Because setenv.cmd is used to show path to C: when GCC is installed in different location, you have to edit it. If you left default settings, then don’t edit this file.
Lets try to compile this program. Start DOS console window (Start->Run and type CMD):
Lets compile project to hex file. Leave make file not edited as it is ready for this. So I will have to use commands: make and once again make hex.
making ARM project with GNUARM 
That’s it hex is built and placed in project directory. It can be uploaded ARM MCU.
Here is a table with most common make commands:
Command Target (function)
  • Make Compiling, linking and forming the elf file;
  • Make clean Clearing compiled o, lst, elf, hex and bin files;
  • Make hex forming the hex file;
  • Make bin forming Bin file;
  • Make lst Listing (assembling) file formation;
  • Make run Compiling, linking and it writing in to the flash after this execution starts;
  • Make debug Compiling, linking and writing in to the flash after building start Insight/GDB.
So if you already have programmer adapter connected, you can flash you ARM microcontroller with only one command - make run.

No comments:

Post a Comment