Most of the examples listed here have a Makefile included with them so in theory if you type make they should build. If they do not then most likely you will see an error indicating that the linker can’t find the gcc library. You can fix this by editing the Makefile and pointing the LIBSPEC variable at your library directory.
Alternatively you could try executing a command like this (on Linux, Windows or OSX):
arm-none-eabi-gcc -static -mthumb -mcpu=cortex-m0plus main.c init.c serial.c -T linker_script.ld -o main.elf -nostartfiles
Breaking this down:
arm-none-eabi-gcc: Your cross compiler. Your PATH environment variable should include the directory this lives in.
-static: Don’t use DLL’s (run-time linking) i.e. include the library function code in the final executable image.
-mthumb: Generate thumb code rather than ARM code.
-mcpu=cortex-m0plus: Check which core your MCU has. In this case its a Cortex M0+
The list of C files (your list may differ)
-T linker_script.ld: Use this linker script to define memory regions when building the output executable image.
-o main.elf: name the output file main.elf
–nostartfiles: Don’t include “standard” start and stop functions. The code includes our own custom start-up code
If you want to convert to a bin format for use with an STM32 Nucleo board or and MBed enabled board then do this:
arm-none-eabi-objcopy -O binary main.elf main.bin
This creates a raw binary program image which can be dropped on to the Nucleo’s virtual disk.
If you want to create an Intel hex file suitable for use with a bootloader/ISP program such as lpc21isp or stm32flash do this:
arm-none-eabi-objcopy -O ihex main.elf main.ihex
You can get a cross compiler for most systems over at launchpad.net