1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

apps.debug: add debug app (that consumes debuglink messages)

This commit is contained in:
Pavol Rusnak 2016-11-14 22:13:32 +01:00
parent 5253bdef1d
commit 09c6309ebf
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,50 @@
from trezor.wire import register_type, protobuf_handler
from trezor.messages.wire_types import \
DebugLinkDecision, DebugLinkGetState, DebugLinkStop, \
DebugLinkMemoryRead, DebugLinkMemoryWrite, DebugLinkFlashErase
from trezor.debug import memaccess
async def dispatch_DebugLinkDecision(msg, session_id):
# TODO: apply button decision from msg.yes_no
pass
async def dispatch_DebugLinkGetState(msg, session_id):
from trezor.messages.DebugLinkState import DebugLinkState
f = DebugLinkState()
# TODO:
# f.pin = storage.get_pin()
# f.matrix = pinmatrix_get()
# f.reset_entropy = reset_get_internal_entropy()
# f.reset_word = reset_get_word()
# f.recovery_fake_word = recovery_get_fake_word()
# f.recovery_word_pos = recovery_get_word_pos()
# f.mnemonic = storage.get_mnemonic()
# f.node = storage.get_node()
# f.passphrase_protection = storage.get_passphrase_protection()
await write_message(session_id, f)
async def dispatch_DebugLinkStop(msg, session_id):
pass
async def dispatch_DebugLinkMemoryRead(msg, session_id):
from trezor.messages.DebugLinkMemory import DebugLinkMemory
length = max(msg.length, 1024)
f = DebugLinkMemory()
f.memory = memaccess(msg.address, length)
await write_message(session_id, f)
async def dispatch_DebugLinkMemoryWrite(msg, session_id):
# TODO memcpy((void *)msg.address, msg.memory, len(msg.memory))
pass
async def dispatch_DebugLinkFlashErase(msg, session_id):
# TODO: erase(msg.sector)
pass
def boot():
register_type(DebugLinkDecision, protobuf_handler, dispatch_DebugLinkDecision)
register_type(DebugLinkGetState, protobuf_handler, dispatch_DebugLinkGetState)
register_type(DebugLinkStop, protobuf_handler, dispatch_DebugLinkStop)
register_type(DebugLinkMemoryRead, protobuf_handler, dispatch_DebugLinkMemoryRead)
register_type(DebugLinkMemoryWrite, protobuf_handler, dispatch_DebugLinkMemoryWrite)
register_type(DebugLinkFlashErase, protobuf_handler, dispatch_DebugLinkFlashErase)

View File

@ -7,11 +7,13 @@ from trezor import wire
from apps import homescreen
from apps import management
from apps import wallet
from apps import debug
# Initialize all applications
homescreen.boot()
management.boot()
wallet.boot()
debug.boot()
# Change backlight to white for better visibility
ui.display.backlight(ui.BACKLIGHT_NORMAL)