Bare Metal Toolchain
Introduction
Download and install the tools
Download and install the toolchain
How to use the toolchain?
Support
Additional information
Download
 

Introduction

For a complete C/C++ development system we need the following components:

1. GDB Server
2. GNU ARM Bare Metal Toolchain
3. Integrated Development Environment

The GNU ARM Bare Metal Toolchain (arm-none-eabi) will be used for building applications for the ARM architecture without any operation systems like Linux. If you want to build applications for Linux, search for a arm-linux-eabi toolchain.

This tutorial here will cover how to setup the GNU ARM Embedded Toolchain, and how to compile your first ARM program.

Later I will describe how to expand the toolchain by Eclipse.

Download and install the tools

Do not install the tools or the toolchain in a directory which contain spaces like "C:/Program Files/". In this case the programs will not work!

If you do not have the utilities like make, sh, rm, cp and mkdir, I recomended to use the
"GNU ARM Eclipse Windows Build Tools", which can be found here.

Start the installer:

Press the "Next >" button and follow the instruction of the installer.

Unfortunately the path for the tools must be added manually after the installation.

Now we want to make a short test if these tools are all available. Therefore open a command prompt and type:

C:\>make --version

The result should look like:

GNU Make 4.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

If there is no answer, probably the "build tools" was not installed or are not in your PATH.

Download and install the toolchain

If you do not already have downloaded the "GNU ARM Embedded Toolchain toolchain", you can download the installer here.

Start the installer:

Press the "Next >" button and follow the instruction from the installer. Do not forget to select the "Add path to environment variable" check mark.

Now we want to make a short test if the compiler is available. Therefore open a command
prompt and type:

C:\>arm-none-eabi-gcc --version

The result should look like:

arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 6.2.1 20161205 (releas
e) [ARM/embedded-6-branch revision 243739]
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If there is no answer, probably the toolchain was not installed or is not in your PATH.

How to use the toolchain?

Here I will show you, how to compile your first program. Therefore I have created some small examples for it. Download the Bare Metal example you need and expand the zip file in your working directory.

I will show you the next steps with the STM3240GTest example, and have expanded it in the following directory:

C:\temp\STM3240GTest

This directory is only an example, choose what is the best for you. For the next steps I will use this directory.

Open a command prompt and change in the C:\temp\STM3240GTest directory. First you must clean the project, therefore type:

C:\temp\STM3240GTest>make clean

The result should look like:

rm -f ./cmsis/device/startup_stm32f4xx.o ./cmsis/device/system_stm32f4xx.o ./src/syscalls.o ./src/main.o
rm -f test_ram.elf
rm -f test_ram.map
rm -f test_ram.hex
rm -f ./cmsis/device/system_stm32f4xx.c.bak ./src/syscalls.c.bak ./src/main.c.bak
rm -f ./cmsis/device/system_stm32f4xx.lst ./src/syscalls.lst ./src/main.lst
rm -f ./cmsis/device/startup_stm32f4xx.s.bak
rm -f ./cmsis/device/startup_stm32f4xx.lst
rm -fR .dep

All list and object files are deleted, now we want to compile the program, type:

C:\temp\STM3240GTest>make all

The output should look like:

arm-none-eabi-gcc -x assembler-with-cpp -c -mthumb -mcpu=cortex-m4 -mfloat-abi=h
ard -mfpu=fpv4-sp-d16 -D__FPU_USED=1 -O0 -g -gdwarf-2 -Wa,-amhls=cmsis/device/s
tartup_stm32f4xx.lst -D__HEAP_SIZE=8192 -D__STACK_SIZE=2048 cmsis/device/start
up_stm32f4xx.s -o cmsis/device/startup_stm32f4xx.o
arm-none-eabi-gcc -c -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
-D__FPU_USED=1 -O0 -gdwarf-2 -Wall -Wstrict-prototypes -fverbose-asm -ffunctio
n-sections -fdata-sections -Wa,-ahlms=cmsis/device/system_stm32f4xx.lst -DRUN_
FROM_FLASH=0 -DVECT_TAB_SRAM -MD -MP -MF .dep/system_stm32f4xx.o.d -I . -I./inc
-I./cmsis/core -I./cmsis/device cmsis/device/system_stm32f4xx.c -o cmsis/device/
system_stm32f4xx.o
arm-none-eabi-gcc -c -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
-D__FPU_USED=1 -O0 -gdwarf-2 -Wall -Wstrict-prototypes -fverbose-asm -ffunctio
n-sections -fdata-sections -Wa,-ahlms=src/syscalls.lst -DRUN_FROM_FLASH=0 -DVE
CT_TAB_SRAM -MD -MP -MF .dep/syscalls.o.d -I . -I./inc -I./cmsis/core -I./cmsis/
device src/syscalls.c -o src/syscalls.o
arm-none-eabi-gcc -c -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
-D__FPU_USED=1 -O0 -gdwarf-2 -Wall -Wstrict-prototypes -fverbose-asm -ffunctio
n-sections -fdata-sections -Wa,-ahlms=src/main.lst -DRUN_FROM_FLASH=0 -DVECT_T
AB_SRAM -MD -MP -MF .dep/main.o.d -I . -I./inc -I./cmsis/core -I./cmsis/device s
rc/main.c -o src/main.o
arm-none-eabi-gcc ./cmsis/device/startup_stm32f4xx.o ./cmsis/device/system_stm32
f4xx.o ./src/syscalls.o ./src/main.o -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -m
fpu=fpv4-sp-d16 -D__FPU_USED=1 -nostartfiles -T./prj/stm32f4xx_ram.ld -Wl,-Map=t
est_ram.map,--cref,--gc-sections,--no-warn-mismatch -o test_ram.elf
arm-none-eabi-objcopy -O ihex test_ram.elf test_ram.hex

A file test_ram.elf should now be created in your build directory. If you could find it,
congratulations, you have compiled your first ARM program with the new toolchain.

The next tutorial will describe how to expand the toolchain by Eclipse.

Support

If you need support, take a look here:

Additional information

If you do not like to play the installation puzzle, want to have only ONE application, and have the
budget to pay for the toolchain, take a look at Rowley Associates. Rowley has now extended the licensing scheme to include hobbyists and students with a new Personal License.

A little bit out of date, only ARM7 and ARM9, but a good tutorial about "Building Bare-Metal ARM Systems with GNU" from Miro Samek dealing with the Startup Code, Low-level Initialization and the Linker Script can be found at Embedded.com.

Download

GNU ARM Eclipse Windows Build Tools

GNU ARM Embedded Toolchain