mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
add tools support for reading bootloader from debug link enabled device (#99)
This commit is contained in:
parent
fe4662d389
commit
71d0c483f8
@ -7,6 +7,14 @@ from trezorlib.transport_hid import HidTransport
|
||||
import binascii
|
||||
import sys
|
||||
|
||||
# usage examples
|
||||
# read entire bootloader: ./mem_read.py 8000000 8000
|
||||
# read initial stack pointer: ./mem_read.py 8000000 4
|
||||
# an entire bootloader can be later disassembled with:
|
||||
# arm-none-eabi-objdump -D -b binary -m arm -M force-thumb memory.dat
|
||||
# note that in order for this to work, your trezor device must
|
||||
# be running a firmware that was built with debug link enabled
|
||||
|
||||
def main():
|
||||
# List all connected TREZORs on USB
|
||||
devices = HidTransport.enumerate()
|
||||
@ -24,9 +32,16 @@ def main():
|
||||
client = TrezorClient(transport)
|
||||
debug = DebugLink(debug_transport)
|
||||
|
||||
mem = debug.memory_read(int(sys.argv[1],16), int(sys.argv[2],16))
|
||||
arg1 = int(sys.argv[1], 16)
|
||||
arg2 = int(sys.argv[2], 16)
|
||||
step = 0x400 if arg2 >= 0x400 else arg2
|
||||
|
||||
f = open('memory.dat', 'w')
|
||||
f.write(mem)
|
||||
|
||||
for addr in range(arg1, arg1 + arg2, step):
|
||||
mem = debug.memory_read(addr, step)
|
||||
f.write(mem)
|
||||
|
||||
f.close()
|
||||
|
||||
client.close()
|
||||
|
Loading…
Reference in New Issue
Block a user