forked from virtualrobotix/VRX_Bootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile_VRX.f4
59 lines (45 loc) · 1.75 KB
/
Makefile_VRX.f4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#
# VRX bootloader build rules for STM32F4 targets.
#
PRODUCT = vr$(TARGET)_bl
OPENOCD ?= openocd
JTAGCONFIG ?= interface/olimex-jtag-tiny.cfg
#JTAGCONFIG ?= interface/jtagkey-tiny.cfg
# 5 seconds / 5000 ms default delay
VRX_BOOTLOADER_DELAY ?= 5000
SRCS = $(COMMON_SRCS) main_f4.c
ifeq ($(INTERFACE),USB)
SRCS += cdcacm.c
endif
ifeq ($(INTERFACE),USART)
SRCS += usart.c
endif
FLAGS += -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 \
-DSTM32F4 \
-DAPP_LOAD_ADDRESS=0x08004000 \
-DBOOTLOADER_DELAY=$(VRX_BOOTLOADER_DELAY) \
-DBOARD_$(BOARD) \
-DINTERFACE_$(INTERFACE) \
-DUSBDEVICESTRING="$(USBDEVICESTRING)" \
-DUSBPRODUCTID="$(USBPRODUCTID)" \
-Tstm32f4.ld \
-L$(LIBOPENCM3)/lib/stm32/f4/ \
-lopencm3_stm32f4 \
BUILDPATH = bootloader/
ELF = $(BUILDPATH)$(PRODUCT).elf
BINARY = $(BUILDPATH)$(PRODUCT).bin
HEX = $(BUILDPATH)$(PRODUCT).hex
all: $(ELF) $(BINARY)
$(ELF): $(SRCS) $(MAKEFILE_LIST)
$(CC) -o $@ $(SRCS) $(FLAGS)
$(BINARY): $(ELF)
$(OBJCOPY) -O binary $(ELF) $(BINARY)
$(OBJCOPY) -O ihex $(ELF) $(HEX)
#upload: all flash flash-bootloader
upload: all flash-bootloader
flash-bootloader:
$(OPENOCD) --search ../vr_bootloader -f $(JTAGCONFIG) -f stm32f4x.cfg -c init -c "reset halt" -c "flash write_image erase $(BINARY) 0x08000000" -c "reset run" -c shutdown
# Use to upload to a stm32f4-discovery devboard, requires the latest version of openocd (from git)
# build openocd with "cd openocd; ./bootstrap; ./configure --enable-maintainer-mode --enable-stlink"
upload-discovery:
$(OPENOCD) --search ../vr_bootloader -f board/stm32f4discovery.cfg -c init -c "reset halt" -c "flash probe 0" -c "stm32f2x mass_erase 0" -c "flash write_image erase $(BINARY) 0x08000000" -c "reset" -c shutdown