1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00

update Makefiles to reflect new way of building stuff

This commit is contained in:
Pavol Rusnak 2017-01-23 10:21:48 +01:00
parent 892409c9b8
commit d8f1b1397c
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 75 additions and 23 deletions

View File

@ -27,7 +27,7 @@ build_stmhal_frozen: vendor res build_cross ## build stmhal port with frozen mod
$(MAKE) -C vendor/micropython/stmhal BOARD=$(BOARD) FROZEN_MPY_DIR=../../../src
build_bootloader: vendor ## build bootloader
$(MAKE) -C vendor/micropython/stmhal -f Makefile.bootloader BOARD=$(BOARD)
$(MAKE) -C vendor/micropython/stmhal -f Makefile.bootloader BOARD=$(BOARD) BUILD=build-$(BOARD)_bootloader
build_unix: vendor ## build unix port
$(MAKE) -C vendor/micropython/unix MICROPY_FORCE_32BIT=1
@ -47,11 +47,14 @@ run: ## run unix port
emu: ## run emulator
./emu.sh
clean: clean_stmhal clean_unix clean_cross ## clean all builds
clean: clean_stmhal clean_bootloader clean_unix clean_cross ## clean all builds
clean_stmhal: ## clean stmhal build
$(MAKE) -C vendor/micropython/stmhal clean BOARD=$(BOARD)
clean_bootloader: ## clean stmhal build
$(MAKE) -C vendor/micropython/stmhal -f Makefile.bootloader clean BOARD=$(BOARD) BUILD=build-$(BOARD)_bootloader
clean_unix: ## clean unix build
$(MAKE) -C vendor/micropython/unix clean
@ -70,9 +73,9 @@ flash: ## flash firmware using st-flash
st-flash write $(STMHAL_BUILD_DIR)/firmware1.bin 0x8020000
flash_bl: vendor ## flash bootloader using st-flash
st-flash write $(STMHAL_BUILD_DIR)/bootloader0.bin 0x8000000
st-flash write $(STMHAL_BUILD_DIR)_bootloader/firmware0.bin 0x8000000
sleep 0.1
st-flash write $(STMHAL_BUILD_DIR)/bootloader1.bin 0x8020000
st-flash write $(STMHAL_BUILD_DIR)_bootloader/firmware1.bin 0x8020000
openocd_flash: $(STMHAL_BUILD_DIR)/firmware.hex ## flash firmware using openocd
openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg \
@ -83,12 +86,12 @@ openocd_flash: $(STMHAL_BUILD_DIR)/firmware.hex ## flash firmware using openocd
-c "reset" \
-c "shutdown"
openocd_flash_bl: $(STMHAL_BUILD_DIR)/bootloader.hex ## flash bootloader using openocd
openocd_flash_bl: $(STMHAL_BUILD_DIR)_bootloader/firmware.hex ## flash bootloader using openocd
openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg \
-c "init" \
-c "reset init" \
-c "stm32f4x mass_erase 0" \
-c "flash write_image $(STMHAL_BUILD_DIR)/bootloader.hex" \
-c "flash write_image $(STMHAL_BUILD_DIR)_bootloader/firmware.hex" \
-c "reset" \
-c "shutdown"
@ -99,7 +102,7 @@ gdb: ## start remote gdb session which connects to the openocd
arm-none-eabi-gdb $(STMHAL_BUILD_DIR)/firmware.elf -ex 'target remote localhost:3333'
gdb_bl: ## start remote gdb session which connects to the openocd
arm-none-eabi-gdb $(STMHAL_BUILD_DIR)/bootloader.elf -ex 'target remote localhost:3333'
arm-none-eabi-gdb $(STMHAL_BUILD_DIR)_bootloader/firmware.elf -ex 'target remote localhost:3333'
load: ## load contents of src into mass storage of trezor
rm -rf /run/media/${USER}/PYBFLASH/*

View File

@ -132,6 +132,42 @@ SRC_USBDEV = $(addprefix $(USBDEV_DIR)/,\
class/src/usbd_msc_data.c \
)
ifeq ($(MICROPY_PY_WIZNET5K),1)
WIZNET5K_DIR=drivers/wiznet5k
INC += -I$(TOP)/$(WIZNET5K_DIR)
CFLAGS_MOD += -DMICROPY_PY_WIZNET5K=1
SRC_MOD += modnwwiznet5k.c
SRC_MOD += $(addprefix $(WIZNET5K_DIR)/,\
ethernet/w5200/w5200.c \
ethernet/wizchip_conf.c \
ethernet/socket.c \
internet/dns/dns.c \
)
endif
# for CC3000 module
ifeq ($(MICROPY_PY_CC3K),1)
CC3000_DIR=drivers/cc3000
INC += -I$(TOP)/$(CC3000_DIR)/inc
CFLAGS_MOD += -DMICROPY_PY_CC3K=1
SRC_MOD += modnwcc3k.c
SRC_MOD += $(addprefix $(CC3000_DIR)/src/,\
cc3000_common.c \
evnt_handler.c \
hci.c \
netapp.c \
nvmem.c \
security.c \
socket.c \
wlan.c \
ccspi.c \
inet_ntop.c \
inet_pton.c \
patch.c \
patch_prog.c \
)
endif
ifeq ($(MICROPY_PY_TREZORUI),1)
INC += -I../extmod/modtrezorui
SRC_MOD += $(addprefix extmod/modtrezorui/,\
@ -160,11 +196,24 @@ $(PY_BUILD)/formatfloat.o: COPT += -Os
$(PY_BUILD)/parsenum.o: COPT += -Os
$(PY_BUILD)/mpprint.o: COPT += -Os
all: $(BUILD)/bootloader.dfu $(BUILD)/bootloader.hex
all: $(BUILD)/firmware.dfu $(BUILD)/firmware.hex
ifneq ($(FROZEN_DIR),)
# To use frozen source modules, put your .py files in a subdirectory (eg scripts/)
# and then invoke make with FROZEN_DIR=scripts (be sure to build from scratch).
CFLAGS += -DMICROPY_MODULE_FROZEN_STR
endif
ifneq ($(FROZEN_MPY_DIR),)
# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
# then invoke make with FROZEN_MPY_DIR=frozen (be sure to build from scratch).
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
endif
.PHONY: deploy
deploy: $(BUILD)/bootloader.dfu
deploy: $(BUILD)/firmware.dfu
$(ECHO) "Writing $< to the board"
ifeq ($(USE_PYDFU),1)
$(Q)$(PYTHON) $(PYDFU) -u $<
@ -175,27 +224,27 @@ endif
FLASH_ADDR ?= 0x08000000
TEXT_ADDR ?= 0x08020000
deploy-stlink: $(BUILD)/bootloader.dfu
$(ECHO) "Writing $(BUILD)/bootloader0.bin to the board via ST-LINK"
$(Q)$(STFLASH) write $(BUILD)/bootloader0.bin $(FLASH_ADDR)
$(ECHO) "Writing $(BUILD)/bootloader1.bin to the board via ST-LINK"
$(Q)$(STFLASH) --reset write $(BUILD)/bootloader1.bin $(TEXT_ADDR)
deploy-stlink: $(BUILD)/firmware.dfu
$(ECHO) "Writing $(BUILD)/firmware0.bin to the board via ST-LINK"
$(Q)$(STFLASH) write $(BUILD)/firmware0.bin $(FLASH_ADDR)
$(ECHO) "Writing $(BUILD)/firmware1.bin to the board via ST-LINK"
$(Q)$(STFLASH) --reset write $(BUILD)/firmware1.bin $(TEXT_ADDR)
deploy-openocd: $(BUILD)/bootloader.dfu
$(ECHO) "Writing $(BUILD)/bootloader{0,1}.bin to the board via ST-LINK using OpenOCD"
$(Q)$(OPENOCD) -f $(OPENOCD_CONFIG) -c "stm_flash $(BUILD)/bootloader0.bin $(FLASH_ADDR) $(BUILD)/bootloader1.bin $(TEXT_ADDR)"
deploy-openocd: $(BUILD)/firmware.dfu
$(ECHO) "Writing $(BUILD)/firmware{0,1}.bin to the board via ST-LINK using OpenOCD"
$(Q)$(OPENOCD) -f $(OPENOCD_CONFIG) -c "stm_flash $(BUILD)/firmware0.bin $(FLASH_ADDR) $(BUILD)/firmware1.bin $(TEXT_ADDR)"
$(BUILD)/bootloader.dfu: $(BUILD)/bootloader.elf
$(BUILD)/firmware.dfu: $(BUILD)/firmware.elf
$(ECHO) "Create $@"
$(Q)$(OBJCOPY) -O binary -j .isr_vector $^ $(BUILD)/bootloader0.bin
$(Q)$(OBJCOPY) -O binary -j .text -j .data $^ $(BUILD)/bootloader1.bin
$(Q)$(PYTHON) $(DFU) -b $(FLASH_ADDR):$(BUILD)/bootloader0.bin -b $(TEXT_ADDR):$(BUILD)/bootloader1.bin $@
$(Q)$(OBJCOPY) -O binary -j .isr_vector $^ $(BUILD)/firmware0.bin
$(Q)$(OBJCOPY) -O binary -j .text -j .data $^ $(BUILD)/firmware1.bin
$(Q)$(PYTHON) $(DFU) -b $(FLASH_ADDR):$(BUILD)/firmware0.bin -b $(TEXT_ADDR):$(BUILD)/firmware1.bin $@
$(BUILD)/bootloader.hex: $(BUILD)/bootloader.elf
$(BUILD)/firmware.hex: $(BUILD)/firmware.elf
$(ECHO) "Create $@"
$(Q)$(OBJCOPY) -O ihex $< $@
$(BUILD)/bootloader.elf: $(OBJ)
$(BUILD)/firmware.elf: $(OBJ)
$(ECHO) "LINK $@"
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
$(Q)$(SIZE) $@