1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 06:48:16 +00:00
trezor-firmware/speed-stm32/Makefile.include
Pavol Rusnak 638cf2310b cleanup
2013-09-20 21:49:17 +02:00

92 lines
2.0 KiB
Makefile

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
flash: $(NAME).bin
$(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
$(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:
rm -f *.a
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*