|
|
@ -1,30 +1,66 @@
|
|
|
|
PREFIX ?= arm-none-eabi
|
|
|
|
APPIFY ?= 0
|
|
|
|
CC = $(PREFIX)-gcc
|
|
|
|
PREFIX ?= arm-none-eabi-
|
|
|
|
LD = $(PREFIX)-gcc
|
|
|
|
CC = $(PREFIX)gcc
|
|
|
|
OBJCOPY = $(PREFIX)-objcopy
|
|
|
|
LD = $(PREFIX)gcc
|
|
|
|
OBJDUMP = $(PREFIX)-objdump
|
|
|
|
OBJCOPY = $(PREFIX)objcopy
|
|
|
|
FLASH = $(shell which st-flash)
|
|
|
|
OBJDUMP = $(PREFIX)objdump
|
|
|
|
|
|
|
|
FLASH = st-flash
|
|
|
|
TOOLCHAIN_DIR ?= ../../../STM/libopencm3
|
|
|
|
OPENOCD = openocd
|
|
|
|
|
|
|
|
TOP_DIR = /home/stick/work/trezor/trezor-mcu
|
|
|
|
CFLAGS += -Os -g \
|
|
|
|
TOOLCHAIN_DIR = /home/stick/work/STM/libopencm3
|
|
|
|
-Wall -Wextra -Wimplicit-function-declaration -Wredundant-decls -Wstrict-prototypes -Wundef -Wshadow \
|
|
|
|
|
|
|
|
-fno-common -mcpu=cortex-m3 -mthumb -msoft-float -MD -DSTM32F2 \
|
|
|
|
OPTFLAGS = -Os -g
|
|
|
|
-I$(TOOLCHAIN_DIR)/include
|
|
|
|
|
|
|
|
LDSCRIPT ?= $(NAME).ld
|
|
|
|
CFLAGS += $(OPTFLAGS) \
|
|
|
|
LDFLAGS += --static -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group \
|
|
|
|
-Wall \
|
|
|
|
-L$(TOOLCHAIN_DIR)/lib -L$(TOOLCHAIN_DIR)/lib/stm32/f2 \
|
|
|
|
-Wextra \
|
|
|
|
-T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections \
|
|
|
|
-Wimplicit-function-declaration \
|
|
|
|
-mthumb -march=armv7 -mfix-cortex-m3-ldrd -msoft-float
|
|
|
|
-Wredundant-decls \
|
|
|
|
OBJS += $(NAME).o
|
|
|
|
-Wstrict-prototypes \
|
|
|
|
|
|
|
|
-Wundef \
|
|
|
|
all: images
|
|
|
|
-Wshadow \
|
|
|
|
|
|
|
|
-fno-common \
|
|
|
|
images: $(NAME).bin
|
|
|
|
-mcpu=cortex-m3 \
|
|
|
|
|
|
|
|
-mthumb \
|
|
|
|
|
|
|
|
-msoft-float \
|
|
|
|
|
|
|
|
-DSTM32F2 \
|
|
|
|
|
|
|
|
-I$(TOOLCHAIN_DIR)/include \
|
|
|
|
|
|
|
|
-I$(TOP_DIR) \
|
|
|
|
|
|
|
|
-DAPPIFY=$(APPIFY)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LDSCRIPT = $(TOP_DIR)/layout$(APPIFY).ld
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LDFLAGS += --static \
|
|
|
|
|
|
|
|
-Wl,--start-group \
|
|
|
|
|
|
|
|
-lc \
|
|
|
|
|
|
|
|
-lgcc \
|
|
|
|
|
|
|
|
-lnosys \
|
|
|
|
|
|
|
|
-Wl,--end-group \
|
|
|
|
|
|
|
|
-L$(TOP_DIR) \
|
|
|
|
|
|
|
|
-L$(TOOLCHAIN_DIR)/lib \
|
|
|
|
|
|
|
|
-L$(TOOLCHAIN_DIR)/lib/stm32/f2 \
|
|
|
|
|
|
|
|
-T$(LDSCRIPT) \
|
|
|
|
|
|
|
|
-nostartfiles \
|
|
|
|
|
|
|
|
-Wl,--gc-sections \
|
|
|
|
|
|
|
|
-mthumb \
|
|
|
|
|
|
|
|
-march=armv7 \
|
|
|
|
|
|
|
|
-mfix-cortex-m3-ldrd \
|
|
|
|
|
|
|
|
-msoft-float
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
all: $(NAME).bin
|
|
|
|
|
|
|
|
|
|
|
|
flash: $(NAME).bin
|
|
|
|
flash: $(NAME).bin
|
|
|
|
$(FLASH) write $(NAME).bin 0x8000000
|
|
|
|
$(FLASH) write $(NAME).bin 0x8000000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flash2: $(NAME).hex
|
|
|
|
|
|
|
|
$(OPENOCD) -f board/stm32f4discovery.cfg \
|
|
|
|
|
|
|
|
-c "init" \
|
|
|
|
|
|
|
|
-c "reset init" \
|
|
|
|
|
|
|
|
-c "stm32f2x mass_erase 0" \
|
|
|
|
|
|
|
|
-c "flash write_image $(NAME).hex" \
|
|
|
|
|
|
|
|
-c "reset" \
|
|
|
|
|
|
|
|
-c "shutdown"
|
|
|
|
|
|
|
|
|
|
|
|
$(NAME).bin: $(NAME).elf
|
|
|
|
$(NAME).bin: $(NAME).elf
|
|
|
|
$(OBJCOPY) -Obinary $(NAME).elf $(NAME).bin
|
|
|
|
$(OBJCOPY) -Obinary $(NAME).elf $(NAME).bin
|
|
|
|
|
|
|
|
|
|
|
@ -44,6 +80,7 @@ $(NAME).elf: $(OBJS) $(LDSCRIPT) $(TOOLCHAIN_DIR)/lib/libopencm3_stm32f2.a
|
|
|
|
$(CC) $(CFLAGS) -o $@ -c $<
|
|
|
|
$(CC) $(CFLAGS) -o $@ -c $<
|
|
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
clean:
|
|
|
|
|
|
|
|
rm -f *.a
|
|
|
|
rm -f *.o
|
|
|
|
rm -f *.o
|
|
|
|
rm -f *.d
|
|
|
|
rm -f *.d
|
|
|
|
rm -f *.elf
|
|
|
|
rm -f *.elf
|
|
|
|