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
|
|
|
BOARD=TREZORV2
|
|
|
|
|
|
|
|
STMHAL_BUILD_DIR=vendor/micropython/stmhal/build-$(BOARD)
|
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
|
|
|
|
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
|
|
|
|
2016-09-25 22:24:16 +00:00
|
|
|
build: build_stmhal build_unix build_cross ## build stmhal, unix and mpy-cross micropython ports
|
2016-03-30 16:30:22 +00:00
|
|
|
|
2017-02-16 12:48:28 +00:00
|
|
|
build_stmhal: vendor build_cross ## build stmhal port
|
2016-11-06 00:49:55 +00:00
|
|
|
$(MAKE) -C vendor/micropython/stmhal BOARD=$(BOARD)
|
2016-03-30 16:30:22 +00:00
|
|
|
|
2017-02-16 12:48:28 +00:00
|
|
|
build_stmhal_debug: vendor build_cross ## build stmhal port with debug symbols
|
2016-11-23 09:48:12 +00:00
|
|
|
$(MAKE) -C vendor/micropython/stmhal BOARD=$(BOARD) DEBUG=1
|
2016-09-13 14:45:42 +00:00
|
|
|
|
2016-09-29 11:35:00 +00:00
|
|
|
build_stmhal_frozen: vendor res build_cross ## build stmhal port with frozen modules (from /src)
|
2016-11-23 09:48:12 +00:00
|
|
|
$(MAKE) -C vendor/micropython/stmhal BOARD=$(BOARD) FROZEN_MPY_DIR=../../../src
|
2016-09-25 22:24:16 +00:00
|
|
|
|
2017-02-20 10:36:07 +00:00
|
|
|
build_trezorhal_frozen: vendor res build_cross ## build trezorhal port with frozen modules (from /src)
|
|
|
|
$(MAKE) -C vendor/micropython/trezorhal FROZEN_MPY_DIR=../../../src
|
|
|
|
|
2017-01-22 18:47:21 +00:00
|
|
|
build_bootloader: vendor ## build bootloader
|
2017-01-23 09:21:48 +00:00
|
|
|
$(MAKE) -C vendor/micropython/stmhal -f Makefile.bootloader BOARD=$(BOARD) BUILD=build-$(BOARD)_bootloader
|
2017-01-22 18:47:21 +00:00
|
|
|
|
2016-10-03 15:23:21 +00:00
|
|
|
build_unix: vendor ## build unix port
|
2016-10-12 16:29:01 +00:00
|
|
|
$(MAKE) -C vendor/micropython/unix MICROPY_FORCE_32BIT=1
|
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
|
2016-10-12 16:29:01 +00:00
|
|
|
$(MAKE) -C vendor/micropython/unix MICROPY_FORCE_32BIT=1 DEBUG=1
|
2016-09-13 14:45:42 +00:00
|
|
|
|
2016-09-29 11:35:00 +00:00
|
|
|
build_unix_frozen: vendor res build_cross ## build unix port with frozen modules (from /src)
|
2016-10-12 16:29:01 +00:00
|
|
|
$(MAKE) -C vendor/micropython/unix MICROPY_FORCE_32BIT=1 FROZEN_MPY_DIR=../../../src
|
2016-03-30 14:36:39 +00:00
|
|
|
|
2016-10-03 15:23:21 +00:00
|
|
|
build_cross: vendor ## build mpy-cross port
|
2016-10-12 16:29:01 +00:00
|
|
|
$(MAKE) -C vendor/micropython/mpy-cross MICROPY_FORCE_32BIT=1
|
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-02-20 10:36:07 +00:00
|
|
|
clean: clean_stmhal clean_trezorhal clean_bootloader clean_unix clean_cross ## clean all builds
|
2016-04-11 15:55:10 +00:00
|
|
|
|
|
|
|
clean_stmhal: ## clean stmhal build
|
2016-11-06 00:49:55 +00:00
|
|
|
$(MAKE) -C vendor/micropython/stmhal clean BOARD=$(BOARD)
|
2016-04-11 15:55:10 +00:00
|
|
|
|
2017-02-20 10:36:07 +00:00
|
|
|
clean_trezorhal: ## clean trezorhal build
|
|
|
|
$(MAKE) -C vendor/micropython/trezorhal clean
|
|
|
|
|
2017-01-23 09:21:48 +00:00
|
|
|
clean_bootloader: ## clean stmhal build
|
|
|
|
$(MAKE) -C vendor/micropython/stmhal -f Makefile.bootloader clean BOARD=$(BOARD) BUILD=build-$(BOARD)_bootloader
|
|
|
|
|
2016-04-11 15:55:10 +00:00
|
|
|
clean_unix: ## clean unix build
|
2016-10-12 16:29:01 +00:00
|
|
|
$(MAKE) -C vendor/micropython/unix clean
|
2016-04-11 15:55:10 +00:00
|
|
|
|
2016-09-19 15:08:41 +00:00
|
|
|
clean_cross: ## clean mpy-cross build
|
2016-10-12 16:29:01 +00:00
|
|
|
$(MAKE) -C vendor/micropython/mpy-cross clean
|
2016-09-19 15:08:41 +00:00
|
|
|
|
2016-04-12 16:09:23 +00:00
|
|
|
test: ## run unit tests
|
2016-11-06 16:04:25 +00:00
|
|
|
cd tests ; ./run_tests.sh
|
2016-04-12 16:09:23 +00:00
|
|
|
|
2016-11-24 13:27:30 +00:00
|
|
|
testpy: ## run selected unit tests from python-trezor
|
|
|
|
cd tests ; ./run_tests_python_trezor.sh
|
|
|
|
|
2016-03-30 14:36:39 +00:00
|
|
|
flash: ## flash firmware using st-flash
|
2017-02-21 10:23:50 +00:00
|
|
|
st-flash write $(STMHAL_BUILD_DIR)/firmware.bin 0x8000000
|
2016-03-30 14:36:39 +00:00
|
|
|
|
2016-10-03 15:23:21 +00:00
|
|
|
flash_bl: vendor ## flash bootloader using st-flash
|
2017-02-21 10:23:50 +00:00
|
|
|
st-flash write $(STMHAL_BUILD_DIR)_bootloader/firmware.bin 0x8000000
|
2016-09-28 16:15:06 +00:00
|
|
|
|
2016-10-03 15:23:21 +00:00
|
|
|
openocd_flash: $(STMHAL_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" \
|
2016-10-03 15:23:21 +00:00
|
|
|
-c "flash write_image $(STMHAL_BUILD_DIR)/firmware.hex" \
|
2016-09-29 11:30:23 +00:00
|
|
|
-c "reset" \
|
|
|
|
-c "shutdown"
|
|
|
|
|
2017-01-23 09:21:48 +00:00
|
|
|
openocd_flash_bl: $(STMHAL_BUILD_DIR)_bootloader/firmware.hex ## flash bootloader 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-01-23 09:21:48 +00:00
|
|
|
-c "flash write_image $(STMHAL_BUILD_DIR)_bootloader/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
|
2016-09-29 12:38:31 +00:00
|
|
|
arm-none-eabi-gdb $(STMHAL_BUILD_DIR)/firmware.elf -ex 'target remote localhost:3333'
|
2016-03-31 14:48:57 +00:00
|
|
|
|
2016-10-03 15:23:21 +00:00
|
|
|
gdb_bl: ## start remote gdb session which connects to the openocd
|
2017-01-23 09:21:48 +00:00
|
|
|
arm-none-eabi-gdb $(STMHAL_BUILD_DIR)_bootloader/firmware.elf -ex 'target remote localhost:3333'
|
2016-09-29 11:22:31 +00:00
|
|
|
|
2016-04-03 23:46:46 +00:00
|
|
|
load: ## load contents of src into mass storage of trezor
|
2016-03-31 14:48:57 +00:00
|
|
|
rm -rf /run/media/${USER}/PYBFLASH/*
|
2016-04-29 14:02:18 +00:00
|
|
|
cp -a src/apps /run/media/${USER}/PYBFLASH/
|
2016-04-27 20:44:37 +00:00
|
|
|
cp -a src/lib /run/media/${USER}/PYBFLASH/
|
|
|
|
cp -a src/trezor /run/media/${USER}/PYBFLASH/
|
|
|
|
cp -a src/*.py /run/media/${USER}/PYBFLASH/
|
2016-04-04 11:58:21 +00:00
|
|
|
sync
|