Skip to content

Instantly share code, notes, and snippets.

@jaz303
Created October 23, 2011 15:57
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jaz303/1307514 to your computer and use it in GitHub Desktop.
Save jaz303/1307514 to your computer and use it in GitHub Desktop.
Makefile for Linux STM32 microcontroller development
CC = arm-none-eabi-gcc
LD = arm-none-eabi-ld -v
AR = arm-none-eabi-ar
AS = arm-none-eabi-as
CP = arm-none-eabi-objcopy
OD = arm-none-eabi-objdump
CFLAGS = -I./ -I./stdlib/inc -DSTM32F10X_MD -fno-common -O0 -g -mcpu=cortex-m3 -mthumb
AFLAGS = -ahls -mapcs-32
LFLAGS =
CPFLAGS =
ODFLAGS =
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
%.o: %.s
$(AS) $(AFLAGS) -o $@ $<
BASENAME = main
OUTFILE = $(BASENAME).out
BINFILE = $(BASENAME).bin
DUMPFILE = $(BASENAME).list
LAYOUT = layout.cmd
OBJS = main.o
build: $(BINFILE)
obj: $(OBJS)
clean:
find . -name '*.o' -delete
find . -name '*.list' -delete
find . -name '*.out' -delete
find . -name '*.bin' -delete
$(OUTFILE): $(OBJS)
$(LD) $(LFLAGS) -nostartfiles -T $(LAYOUT) -o $(OUTFILE) $(OBJS)
$(BINFILE): $(OUTFILE)
$(CP) $(CPFLAGS) -Obinary -j .text $(OUTFILE) $(BINFILE)
$(OD) $(ODFLAGS) -D $(OUTFILE) > $(DUMPFILE)
flash: $(BINFILE)
./flasher $(BINFILE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment