You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
54 lines
1.3 KiB
PREFIX ?= arm-none-eabi-
|
|
|
|
LDSCRIPT = support/stm32vl-discovery.ld
|
|
|
|
CFLAGS += -Os
|
|
LDFLAGS += -Os
|
|
|
|
CFLAGS += -fno-common --function-sections -fdata-sections
|
|
LDFLAGS += -static -nostartfiles
|
|
LDFLAGS += -Wl,--gc-sections
|
|
LDFLAGS += -T ${LDSCRIPT}
|
|
LIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
|
|
|
|
# Set up libopencm3.
|
|
OPENCM3_DIR ?= libopencm3
|
|
OPENCM3_LIBNAME = opencm3_stm32f1
|
|
CFLAGS += -I$(OPENCM3_DIR)/include
|
|
CFLAGS += -DSTM32F1 -msoft-float -mthumb -mcpu=cortex-m3 -mfix-cortex-m3-ldrd
|
|
LDFLAGS += -L$(OPENCM3_DIR)/lib
|
|
LIBS += -l$(OPENCM3_LIBNAME)
|
|
|
|
STLINK_PORT ?= :4242
|
|
|
|
obj-y += source/core/spi.o
|
|
|
|
$(OPENCM3_DIR)/lib/lib$(OPENCM3_LIBNAME).a:
|
|
@if [ ! -e libopencm3/.git ]; then \
|
|
git submodule init; \
|
|
git submodule update; \
|
|
fi
|
|
@$(MAKE) -C $(OPENCM3_DIR)
|
|
|
|
$(BUILD)/tbm: $(OPENCM3_DIR)/lib/lib$(OPENCM3_LIBNAME).a
|
|
|
|
$(BUILD)/tbm.bin: $(BUILD)/tbm
|
|
$(PREFIX)objcopy -Obinary $< $@
|
|
|
|
$(BUILD)/tbm.hex: $(BUILD)/tbm
|
|
$(PREFIX)objcopy -Oihex $< $@
|
|
|
|
run: $(BUILD)/tbm
|
|
@echo "GDB $<"
|
|
@$(GDB) --batch \
|
|
-ex 'target extended-remote $(STLINK_PORT)' \
|
|
-x flash.scr \
|
|
$<
|
|
|
|
flash: $(BUILD)/tbm.bin
|
|
stm32flash -g 0x8000000 -w $< $(STM32_PORT)
|
|
|
|
openocd:
|
|
openocd -f /usr/share/openocd/scripts/interface/jlink.cfg -c 'transport select swd' -f /usr/share/openocd/scripts/target/stm32f1x.cfg -c 'gdb_port 4242'
|
|
|
|
.PHONY: run
|
|
|