2013-09-20 19:49:17 +00:00
|
|
|
APPIFY ?= 0
|
|
|
|
PREFIX ?= arm-none-eabi-
|
|
|
|
CC = $(PREFIX)gcc
|
|
|
|
LD = $(PREFIX)gcc
|
|
|
|
OBJCOPY = $(PREFIX)objcopy
|
|
|
|
OBJDUMP = $(PREFIX)objdump
|
|
|
|
FLASH = st-flash
|
|
|
|
OPENOCD = openocd
|
|
|
|
TOP_DIR = /home/stick/work/trezor/trezor-mcu
|
|
|
|
TOOLCHAIN_DIR = /home/stick/work/STM/libopencm3
|
|
|
|
|
|
|
|
OPTFLAGS = -Os -g
|
|
|
|
|
|
|
|
CFLAGS += $(OPTFLAGS) \
|
|
|
|
-Wall \
|
|
|
|
-Wextra \
|
|
|
|
-Wimplicit-function-declaration \
|
|
|
|
-Wredundant-decls \
|
|
|
|
-Wstrict-prototypes \
|
|
|
|
-Wundef \
|
|
|
|
-Wshadow \
|
|
|
|
-fno-common \
|
|
|
|
-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
|
2013-08-18 18:54:18 +00:00
|
|
|
|
|
|
|
flash: $(NAME).bin
|
|
|
|
$(FLASH) write $(NAME).bin 0x8000000
|
|
|
|
|
2013-09-20 19:49:17 +00:00
|
|
|
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"
|
|
|
|
|
2013-08-18 18:54:18 +00:00
|
|
|
$(NAME).bin: $(NAME).elf
|
|
|
|
$(OBJCOPY) -Obinary $(NAME).elf $(NAME).bin
|
|
|
|
|
|
|
|
$(NAME).hex: $(NAME).elf
|
|
|
|
$(OBJCOPY) -Oihex $(NAME).elf $(NAME).hex
|
|
|
|
|
|
|
|
$(NAME).srec: $(NAME).elf
|
|
|
|
$(OBJCOPY) -Osrec $(NAME).elf $(NAME).srec
|
|
|
|
|
|
|
|
$(NAME).list: $(NAME).elf
|
|
|
|
$(OBJDUMP) -S $(NAME).elf > $(NAME).list
|
|
|
|
|
|
|
|
$(NAME).elf: $(OBJS) $(LDSCRIPT) $(TOOLCHAIN_DIR)/lib/libopencm3_stm32f2.a
|
|
|
|
$(LD) -o $(NAME).elf $(OBJS) -lopencm3_stm32f2 $(LDFLAGS)
|
|
|
|
|
|
|
|
%.o: %.c Makefile
|
|
|
|
$(CC) $(CFLAGS) -o $@ -c $<
|
|
|
|
|
|
|
|
clean:
|
2013-09-20 19:49:17 +00:00
|
|
|
rm -f *.a
|
2013-08-18 18:54:18 +00:00
|
|
|
rm -f *.o
|
|
|
|
rm -f *.d
|
|
|
|
rm -f *.elf
|
|
|
|
rm -f *.bin
|
|
|
|
rm -f *.hex
|
|
|
|
rm -f *.srec
|
|
|
|
rm -f *.list
|
|
|
|
rm -f usb.pb*
|