1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00

src/apps/debug: do not mess with imports

This commit is contained in:
Jan Pochyla 2018-02-24 23:22:37 +01:00
parent 0ad58aad2b
commit 72aa5e5204

View File

@ -1,3 +1,7 @@
import micropython
import gc
from uctypes import bytes_at, bytearray_at
from trezor import log
from trezor import loop
from trezor.utils import unimport
@ -5,62 +9,50 @@ from trezor.wire import register, protobuf_workflow
from trezor.messages.wire_types import \
DebugLinkDecision, DebugLinkGetState, DebugLinkStop, \
DebugLinkMemoryRead, DebugLinkMemoryWrite, DebugLinkFlashErase
from trezor.messages.DebugLinkMemory import DebugLinkMemory
from trezor.messages.DebugLinkState import DebugLinkState
from trezor.ui.confirm import CONFIRMED, CANCELLED
from apps.common.confirm import signal
from apps.common import storage
from apps.management import reset_device
@unimport
async def dispatch_DebugLinkDecision(ctx, msg):
from trezor.ui.confirm import CONFIRMED, CANCELLED
from apps.common.confirm import signal
signal.send(CONFIRMED if msg.yes_no else CANCELLED)
@unimport
async def dispatch_DebugLinkGetState(ctx, msg):
from trezor.messages.DebugLinkState import DebugLinkState
from apps.common import storage
from apps.management import reset_device
m = DebugLinkState()
m.mnemonic = storage.get_mnemonic()
m.passphrase_protection = storage.has_passphrase()
m.reset_entropy = reset_device.internal_entropy
m.reset_word = reset_device.current_word
return m
@unimport
async def dispatch_DebugLinkStop(ctx, msg):
pass
@unimport
async def dispatch_DebugLinkMemoryRead(ctx, msg):
from trezor.messages.DebugLinkMemory import DebugLinkMemory
from uctypes import bytes_at
m = DebugLinkMemory()
m.memory = bytes_at(msg.address, msg.length)
return m
@unimport
async def dispatch_DebugLinkMemoryWrite(ctx, msg):
from uctypes import bytearray_at
l = len(msg.memory)
data = bytearray_at(msg.address, l)
data[0:l] = msg.memory
@unimport
async def dispatch_DebugLinkFlashErase(ctx, msg):
# TODO: erase(msg.sector)
pass
async def memory_stats(interval):
import micropython
import gc
sleep = loop.sleep(interval * 1000 * 1000)
while True:
micropython.mem_info()