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

168 lines
5.6 KiB
Makefile
Raw Normal View History

2016-05-11 12:39:28 +00:00
.PHONY: vendor
JOBS = 4
MAKE = make -j $(JOBS)
2017-08-07 10:04:11 +00:00
SCONS = scons -Q -j $(JOBS)
2017-08-07 10:04:11 +00:00
BOARDLOADER_BUILD_DIR = build/boardloader
BOOTLOADER_BUILD_DIR = build/bootloader
FIRMWARE_BUILD_DIR = build/firmware
2016-10-12 16:29:01 +00:00
2017-08-08 12:23:34 +00:00
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
UNIX_PORT_OPTS ?= TREZOR_X86=0
else
UNIX_PORT_OPTS ?= TREZOR_X86=1
endif
CROSS_PORT_OPTS ?= MICROPY_FORCE_32BIT=1
ifeq ($(DISPLAY_ILI9341V), 1)
CFLAGS += -DDISPLAY_ILI9341V=1
CFLAGS += -DDISPLAY_ST7789V=0
endif
ifeq ($(DISPLAY_VSYNC), 0)
CFLAGS += -DDISPLAY_VSYNC=0
endif
2017-08-08 12:23:34 +00:00
2017-09-26 13:10:56 +00:00
ifeq ($(STLINKv21), 1)
OPENOCD = openocd -f interface/stlink-v2-1.cfg -c "transport select hla_swd" -f target/stm32f4x.cfg
else
OPENOCD = openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg
endif
2017-03-25 13:46:38 +00:00
## help commands:
help: ## show this help
2017-03-25 13:46:38 +00:00
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36m make %-20s\033[0m %s\n", $$1, $$2} /^##(.*)/ {printf "\033[33m%s\n", substr($$0, 4)}' $(MAKEFILE_LIST)
## dependencies commands:
2016-05-11 12:39:28 +00:00
vendor: ## update git submodules
2017-03-28 13:25:40 +00:00
git submodule update --init
res: ## update resources
./tools/res_collect
2017-03-25 13:46:38 +00:00
## emulator commands:
2017-03-20 16:45:40 +00:00
run: ## run unix port
2017-08-07 10:04:11 +00:00
cd src ; ../build/unix/micropython
2017-03-20 16:45:40 +00:00
emu: ## run emulator
./emu.sh
2017-03-25 13:46:38 +00:00
## test commands:
2017-03-20 16:45:40 +00:00
test: ## run unit tests
cd tests ; ./run_tests.sh
testpy: ## run selected unit tests from python-trezor
cd tests ; ./run_tests_device.sh
2017-03-20 16:45:40 +00:00
2017-06-07 17:06:26 +00:00
pylint: ## run pylint on application sources
pylint -E $(shell find src -name *.py)
2017-06-07 17:06:26 +00:00
2017-06-13 17:35:14 +00:00
style: ## run code style check on application sources
flake8 $(shell find src -name *.py)
2017-06-13 17:35:14 +00:00
2017-03-25 13:46:38 +00:00
## build commands:
2017-04-10 17:24:21 +00:00
build: build_boardloader build_bootloader build_firmware build_unix build_cross ## build all
2017-02-20 10:36:07 +00:00
2017-04-10 17:11:44 +00:00
build_boardloader: ## build boardloader
$(SCONS) CFLAGS="$(CFLAGS)" build/boardloader/boardloader.bin
2017-03-18 11:02:39 +00:00
2017-04-10 17:24:21 +00:00
build_bootloader: ## build bootloader
$(SCONS) CFLAGS="$(CFLAGS)" build/bootloader/bootloader.bin
2017-03-20 14:41:21 +00:00
build_firmware: res build_cross ## build firmware with frozen modules
$(SCONS) CFLAGS="$(CFLAGS)" build/firmware/firmware.bin
$(SCONS) CFLAGS="$(CFLAGS)" build/firmware/firmware0.bin
build_unix: ## build unix port
2017-08-08 12:23:34 +00:00
$(SCONS) build/unix/micropython $(UNIX_PORT_OPTS)
2017-08-07 10:31:42 +00:00
build_unix_noui: ## build unix port without UI support
2017-08-08 12:23:34 +00:00
$(SCONS) build/unix/micropython $(UNIX_PORT_OPTS) TREZOR_NOUI=1
2017-08-07 10:31:42 +00:00
build_cross: ## build mpy-cross port
2017-02-24 12:19:00 +00:00
$(MAKE) -C vendor/micropython/mpy-cross $(CROSS_PORT_OPTS)
2017-03-25 13:46:38 +00:00
## clean commands:
2017-04-10 17:24:21 +00:00
clean: clean_boardloader clean_bootloader clean_firmware clean_unix clean_cross ## clean all
2017-04-10 17:11:44 +00:00
clean_boardloader: ## clean boardloader build
2017-08-07 10:04:11 +00:00
rm -rf build/boardloader
2017-03-20 16:45:40 +00:00
2017-04-10 17:24:21 +00:00
clean_bootloader: ## clean bootloader build
2017-08-07 10:04:11 +00:00
rm -rf build/bootloader
2017-03-20 16:45:40 +00:00
clean_firmware: ## clean firmware build
2017-08-07 10:04:11 +00:00
rm -rf build/firmware
2016-04-11 15:55:10 +00:00
clean_unix: ## clean unix build
2017-08-07 10:04:11 +00:00
rm -rf build/unix
2016-04-11 15:55:10 +00:00
clean_cross: ## clean mpy-cross build
2017-02-24 12:19:00 +00:00
$(MAKE) -C vendor/micropython/mpy-cross clean $(CROSS_PORT_OPTS)
2017-03-25 13:46:38 +00:00
## flash commands:
2017-09-26 13:10:56 +00:00
flash: flash_boardloader flash_bootloader flash_firmware ## flash everything using OpenOCD
flash_boardloader: $(BOARDLOADER_BUILD_DIR)/boardloader.bin ## flash boardloader using OpenOCD
$(OPENOCD) -c "init; reset halt; flash write_image erase $< 0x08000000; exit"
2017-09-26 13:10:56 +00:00
flash_bootloader: $(BOOTLOADER_BUILD_DIR)/bootloader.bin ## flash bootloader using OpenOCD
$(OPENOCD) -c "init; reset halt; flash write_image erase $< 0x08010000; exit"
2017-09-26 13:10:56 +00:00
flash_firmware: $(FIRMWARE_BUILD_DIR)/firmware.bin ## flash firmware using OpenOCD
$(OPENOCD) -c "init; reset halt; flash write_image erase $< 0x08020000; exit"
2017-09-26 13:10:56 +00:00
flash_firmware0: $(FIRMWARE_BUILD_DIR)/firmware0.bin ## flash firmware0 using OpenOCD
$(OPENOCD) -c "init; reset halt; flash write_image erase $< 0x08000000; exit"
2017-03-20 14:41:21 +00:00
2017-09-26 13:10:56 +00:00
flash_combine: $(FIRMWARE_BUILD_DIR)/combined.bin ## flash combined using OpenOCD
$(OPENOCD) -c "init; reset halt; flash write_image erase $< 0x08000000; exit"
2017-09-26 13:10:56 +00:00
flash_erase: ## erase all sectors in flash bank 0
$(OPENOCD) -c "init; reset halt; flash info 0; flash erase_sector 0 0 last; flash erase_check 0; exit"
2017-03-25 13:46:38 +00:00
## openocd debug commands:
openocd: ## start openocd which connects to the device
2017-09-26 13:10:56 +00:00
$(OPENOCD)
gdb: ## start remote gdb session which connects to the openocd
2017-03-20 14:41:21 +00:00
arm-none-eabi-gdb $(FIRMWARE_BUILD_DIR)/firmware.elf -ex 'target remote localhost:3333'
2017-04-10 14:40:41 +00:00
## misc commands:
vendorheader: ## construct default vendor header
./tools/build_vendorheader 'e28a8970753332bd72fef413e6b0b2ef1b4aadda7aa2c141f233712a6876b351:d4eec1869fb1b8a4e817516ad5a931557cb56805c3eb16e8f3a803d647df7869:772c8a442b7db06e166cfbc1ccbcbcde6f3eba76a4e98ef3ffc519502237d6ef' 1 0.0 SatoshiLabs assets/satoshilabs_120.toif embed/firmware/vendorheader.bin
./tools/binctl embed/firmware/vendorheader.bin -s 1 4444444444444444444444444444444444444444444444444444444444444444
2017-04-10 14:40:41 +00:00
binctl: ## print info about binary files
./tools/binctl $(BOOTLOADER_BUILD_DIR)/bootloader.bin
./tools/binctl embed/firmware/vendorheader.bin
./tools/binctl $(FIRMWARE_BUILD_DIR)/firmware.bin
2017-04-10 14:40:41 +00:00
bloaty: ## run bloaty size profiler
bloaty -d symbols -n 0 -s file $(FIRMWARE_BUILD_DIR)/firmware.elf | less
bloaty -d compileunits -n 0 -s file $(FIRMWARE_BUILD_DIR)/firmware.elf | less
sizecheck: ## check sizes of binary files
test 32768 -ge $(shell stat -c%s $(BOARDLOADER_BUILD_DIR)/boardloader.bin)
test 65536 -ge $(shell stat -c%s $(BOOTLOADER_BUILD_DIR)/bootloader.bin)
test 917504 -ge $(shell stat -c%s $(FIRMWARE_BUILD_DIR)/firmware.bin)
test 1048576 -ge $(shell stat -c%s $(FIRMWARE_BUILD_DIR)/firmware0.bin)
combine: ## combine boardloader + bootloader + firmware into one combined image
./tools/combine_firmware \
0x08000000 $(BOARDLOADER_BUILD_DIR)/boardloader.bin \
0x08010000 $(BOOTLOADER_BUILD_DIR)/bootloader.bin \
0x08020000 $(FIRMWARE_BUILD_DIR)/firmware.bin \
> $(FIRMWARE_BUILD_DIR)/combined.bin \