mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
build: add combine and flash_combine make targets
This commit is contained in:
parent
5a41b4497b
commit
cd7ee79c67
10
Makefile
10
Makefile
@ -102,6 +102,9 @@ flash_bootloader: ## flash bootloader using st-flash
|
||||
flash_firmware: ## flash firmware using st-flash
|
||||
st-flash write $(FIRMWARE_BUILD_DIR)/firmware.bin 0x08020000
|
||||
|
||||
flash_combine: ## flash combined image using st-flash
|
||||
st-flash write $(FIRMWARE_BUILD_DIR)/combined.bin 0x08000000
|
||||
|
||||
## openocd debug commands:
|
||||
|
||||
openocd: ## start openocd which connects to the device
|
||||
@ -129,3 +132,10 @@ 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)
|
||||
|
||||
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 \
|
||||
|
24
tools/combine_firmware
Executable file
24
tools/combine_firmware
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
|
||||
def pairwise(iterable):
|
||||
a = iter(iterable)
|
||||
return zip(a, a)
|
||||
|
||||
files = sys.argv[1:]
|
||||
files = list(pairwise(files))
|
||||
|
||||
offset = int(files[0][0], 16)
|
||||
|
||||
out = bytearray()
|
||||
|
||||
for addr, fn in files:
|
||||
addr = int(addr, 16) - offset
|
||||
data = open(fn, 'rb').read()
|
||||
if len(out) < addr:
|
||||
out += b'\x00' * (addr - len(out))
|
||||
if len(out) != addr:
|
||||
raise Exception('Alignment failed')
|
||||
out += data
|
||||
|
||||
sys.stdout.buffer.write(out)
|
Loading…
Reference in New Issue
Block a user