2016-05-11 12:39:28 +00:00
|
|
|
.PHONY: vendor
|
|
|
|
|
2016-10-12 16:29:01 +00:00
|
|
|
JOBS=4
|
|
|
|
MAKE=make -j $(JOBS)
|
2016-11-06 00:49:55 +00:00
|
|
|
|
2017-03-19 14:29:48 +00:00
|
|
|
BOOTLOADER_BUILD_DIR=micropython/bootloader/build
|
2017-03-20 14:41:21 +00:00
|
|
|
LOADER_BUILD_DIR=micropython/loader/build
|
|
|
|
FIRMWARE_BUILD_DIR=micropython/firmware/build
|
2017-02-24 12:19:00 +00:00
|
|
|
|
2017-03-06 16:33:42 +00:00
|
|
|
TREZORHAL_PORT_OPTS=FROZEN_MPY_DIR=src
|
2017-02-24 12:19:00 +00:00
|
|
|
UNIX_PORT_OPTS=MICROPY_FORCE_32BIT=1 MICROPY_PY_BTREE=0 MICROPY_PY_TERMIOS=0 MICROPY_PY_FFI=0 MICROPY_PY_USSL=0 MICROPY_SSL_AXTLS=0
|
|
|
|
CROSS_PORT_OPTS=MICROPY_FORCE_32BIT=1
|
2016-10-12 16:29:01 +00:00
|
|
|
|
2016-03-30 14:36:39 +00:00
|
|
|
help: ## show this help
|
2016-09-25 22:24:16 +00:00
|
|
|
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36mmake %-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
2016-03-30 14:36:39 +00:00
|
|
|
|
2016-05-11 12:39:28 +00:00
|
|
|
vendor: ## update git submodules
|
2017-03-06 16:33:42 +00:00
|
|
|
# git submodule update --init
|
2016-04-01 18:04:59 +00:00
|
|
|
|
2016-09-29 11:35:00 +00:00
|
|
|
res: ## update resources
|
2017-02-08 15:36:19 +00:00
|
|
|
./tools/res_collect
|
2016-09-29 11:35:00 +00:00
|
|
|
|
2017-03-20 14:41:21 +00:00
|
|
|
build: build_firmware build_unix build_cross ## build firmware, unix and mpy-cross micropython ports
|
2016-09-25 22:24:16 +00:00
|
|
|
|
2017-03-20 14:41:21 +00:00
|
|
|
build_firmware: vendor res build_cross ## build firmware with frozen modules
|
2017-03-06 16:33:42 +00:00
|
|
|
$(MAKE) -f Makefile.firmware $(TREZORHAL_PORT_OPTS)
|
2017-02-20 10:36:07 +00:00
|
|
|
|
2017-03-20 14:41:21 +00:00
|
|
|
build_firmware_debug: vendor res build_cross ## build firmware with frozen modules and debug symbols
|
2017-03-06 16:33:42 +00:00
|
|
|
$(MAKE) -f Makefile.firmware $(TREZORHAL_PORT_OPTS) DEBUG=1
|
2017-01-22 18:47:21 +00:00
|
|
|
|
2017-03-18 11:02:39 +00:00
|
|
|
build_bootloader: vendor ## build bootloader
|
2017-03-20 14:58:47 +00:00
|
|
|
mkdir -p $(BOOTLOADER_BUILD_DIR)/genhdr
|
|
|
|
touch $(BOOTLOADER_BUILD_DIR)/genhdr/qstrdefs.generated.h
|
2017-03-18 11:02:39 +00:00
|
|
|
$(MAKE) -f Makefile.bootloader $(TREZORHAL_PORT_OPTS)
|
|
|
|
|
2017-03-20 14:41:21 +00:00
|
|
|
build_loader: vendor ## build loader
|
2017-03-20 14:58:47 +00:00
|
|
|
mkdir -p $(LOADER_BUILD_DIR)/genhdr
|
|
|
|
touch $(LOADER_BUILD_DIR)/genhdr/qstrdefs.generated.h
|
2017-03-20 14:41:21 +00:00
|
|
|
$(MAKE) -f Makefile.loader $(TREZORHAL_PORT_OPTS)
|
|
|
|
|
2016-10-03 15:23:21 +00:00
|
|
|
build_unix: vendor ## build unix port
|
2017-03-07 16:50:55 +00:00
|
|
|
$(MAKE) -f ../../../micropython/unix/Makefile -C vendor/micropython/unix $(UNIX_PORT_OPTS)
|
2016-04-29 14:02:18 +00:00
|
|
|
|
2016-10-03 15:23:21 +00:00
|
|
|
build_unix_debug: vendor ## build unix port with debug symbols
|
2017-03-07 16:50:55 +00:00
|
|
|
$(MAKE) -f ../../../micropython/unix/Makefile -C vendor/micropython/unix $(UNIX_PORT_OPTS) DEBUG=1
|
2016-03-30 14:36:39 +00:00
|
|
|
|
2016-10-03 15:23:21 +00:00
|
|
|
build_cross: vendor ## build mpy-cross port
|
2017-02-24 12:19:00 +00:00
|
|
|
$(MAKE) -C vendor/micropython/mpy-cross $(CROSS_PORT_OPTS)
|
2016-05-17 15:17:23 +00:00
|
|
|
|
2016-04-29 19:46:34 +00:00
|
|
|
run: ## run unix port
|
2016-04-11 09:10:43 +00:00
|
|
|
cd src ; ../vendor/micropython/unix/micropython
|
2016-04-08 09:29:15 +00:00
|
|
|
|
2016-04-29 19:46:34 +00:00
|
|
|
emu: ## run emulator
|
|
|
|
./emu.sh
|
|
|
|
|
2017-03-20 14:41:21 +00:00
|
|
|
clean: clean_firmware clean_unix clean_cross ## clean all builds
|
2016-04-11 15:55:10 +00:00
|
|
|
|
2017-03-20 14:41:21 +00:00
|
|
|
clean_firmware: ## clean firmware build
|
2017-03-06 16:33:42 +00:00
|
|
|
$(MAKE) -f Makefile.firmware clean $(TREZORHAL_PORT_OPTS)
|
2017-01-23 09:21:48 +00:00
|
|
|
|
2016-04-11 15:55:10 +00:00
|
|
|
clean_unix: ## clean unix build
|
2017-03-07 16:50:55 +00:00
|
|
|
$(MAKE) -f ../../../micropython/unix/Makefile -C vendor/micropython/unix clean $(UNIX_PORT_OPTS)
|
2017-03-17 13:14:00 +00:00
|
|
|
# workaround for relative paths containing ../.. in unix Makefile
|
|
|
|
rm -rf vendor/micropython/micropython
|
2016-04-11 15:55:10 +00:00
|
|
|
|
2016-09-19 15:08:41 +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)
|
2016-11-24 13:27:30 +00:00
|
|
|
|
2016-03-30 14:36:39 +00:00
|
|
|
flash: ## flash firmware using st-flash
|
2017-03-20 14:41:21 +00:00
|
|
|
st-flash write $(FIRMWARE_BUILD_DIR)/firmware.bin 0x8000000
|
2016-09-28 16:15:06 +00:00
|
|
|
|
2017-03-19 14:29:48 +00:00
|
|
|
flash_bootloader: ## flash bootloader using st-flash
|
|
|
|
st-flash write $(BOOTLOADER_BUILD_DIR)/bootloader.bin 0x8000000
|
|
|
|
|
2017-03-20 14:41:21 +00:00
|
|
|
flash_loader: ## flash loader using st-flash
|
|
|
|
st-flash write $(LOADER_BUILD_DIR)/loader.bin 0x8000000
|
|
|
|
|
|
|
|
flash_openocd: $(FIRMWARE_BUILD_DIR)/firmware.hex ## flash firmware using openocd
|
2016-09-29 11:30:23 +00:00
|
|
|
openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg \
|
|
|
|
-c "init" \
|
|
|
|
-c "reset init" \
|
|
|
|
-c "stm32f4x mass_erase 0" \
|
2017-03-20 14:41:21 +00:00
|
|
|
-c "flash write_image $(FIRMWARE_BUILD_DIR)/firmware.hex" \
|
2016-09-29 11:30:23 +00:00
|
|
|
-c "reset" \
|
|
|
|
-c "shutdown"
|
|
|
|
|
2016-03-30 14:36:39 +00:00
|
|
|
openocd: ## start openocd which connects to the device
|
2016-04-27 16:45:00 +00:00
|
|
|
openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg
|
2016-03-30 14:36:39 +00:00
|
|
|
|
|
|
|
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-02-24 12:19:00 +00:00
|
|
|
|
|
|
|
test: ## run unit tests
|
|
|
|
cd tests ; ./run_tests.sh
|
|
|
|
|
|
|
|
testpy: ## run selected unit tests from python-trezor
|
|
|
|
cd tests ; ./run_tests_python_trezor.sh
|