TITLE: ARM Cortex M4 Blink Example (Makefile)
AUTHOR: Chuck McManis
LAST UPDATE: 25-May-2014


This is the makefile for the blink example. The important things are that CFLAGS are set to -mcpu=cortex-m4 and -mthumb which tell the C compiler you are compiling for the Cortex M4.

The linker flags, -T blink.ld and -Map blink.map tell the linker to use the ldscript blink.ld and to generate a map file of the final output.

The Source Code

# Trivial blink example using the ARM Embedded Toolchain
# Chuck McManis (cmcmanis@mcmanis.com)
all:    blink.elf blink.ld

CFLAGS = -mcpu=cortex-m4 -mthumb -g
LDFLAGS = -T blink.ld -Map blink.map

all:    blink.elf

startup.o: startup_ARMCM4.S
    arm-none-eabi-as $(CFLAGS) -o startup.o $<

blink.o: blink.c
    arm-none-eabi-gcc $(CFLAGS) -c blink.c

blink.elf:  blink.o blink.c startup.o
    arm-none-eabi-ld $(LDFLAGS) -o blink.elf blink.o startup.o

    rm *.o blink.elf blink.map


Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License. You are free to play around with it and modify it but you are not licensed to use it for commercial purposes. Click the link above for more details on your rights under this license.