Skip to content

Instantly share code, notes, and snippets.

@vdudouyt
Created June 9, 2017 01:54
Show Gist options
  • Save vdudouyt/429a465b6c321ca8b0dc76c66548ab56 to your computer and use it in GitHub Desktop.
Save vdudouyt/429a465b6c321ca8b0dc76c66548ab56 to your computer and use it in GitHub Desktop.
Sample makefile for libopencm3 project
PREFIX=/usr/bin/arm-none-eabi
CC=gcc
OBJCOPY=objcopy
TARGET=STM32F3
STFLASH=st-flash
%.o: %.c
$(PREFIX)-$(CC) -O0 -Wextra -Wshadow -Wimplicit-function-declaration -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -fno-common -ffunction-sections -fdata-sections -MD -Wall -Wundef -I../third-party/libopencm3/include -D$(TARGET) -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -gdwarf-2 -g3 -o $@ -c $<
%.elf: %.o
$(PREFIX)-$(CC) -nostartfiles -L../third-party/libopencm3/lib -Tstm32f3-discovery.ld -Wl,--gc-sections -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 $< -lopencm3_stm32f3 -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group -gdwarf-2 -g3 -lm -o $@
%.bin: %.elf
$(PREFIX)-$(OBJCOPY) -O binary $< $@
flash: $(FW)
$(STFLASH) write $(FW) 0x08000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment