mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-06 13:31:00 +00:00
src/apps/debug: do not mess with imports
This commit is contained in:
parent
0ad58aad2b
commit
72aa5e5204
@ -1,3 +1,7 @@
|
|||||||
|
import micropython
|
||||||
|
import gc
|
||||||
|
from uctypes import bytes_at, bytearray_at
|
||||||
|
|
||||||
from trezor import log
|
from trezor import log
|
||||||
from trezor import loop
|
from trezor import loop
|
||||||
from trezor.utils import unimport
|
from trezor.utils import unimport
|
||||||
@ -5,62 +9,50 @@ from trezor.wire import register, protobuf_workflow
|
|||||||
from trezor.messages.wire_types import \
|
from trezor.messages.wire_types import \
|
||||||
DebugLinkDecision, DebugLinkGetState, DebugLinkStop, \
|
DebugLinkDecision, DebugLinkGetState, DebugLinkStop, \
|
||||||
DebugLinkMemoryRead, DebugLinkMemoryWrite, DebugLinkFlashErase
|
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):
|
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)
|
signal.send(CONFIRMED if msg.yes_no else CANCELLED)
|
||||||
|
|
||||||
|
|
||||||
@unimport
|
|
||||||
async def dispatch_DebugLinkGetState(ctx, msg):
|
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 = DebugLinkState()
|
||||||
m.mnemonic = storage.get_mnemonic()
|
m.mnemonic = storage.get_mnemonic()
|
||||||
m.passphrase_protection = storage.has_passphrase()
|
m.passphrase_protection = storage.has_passphrase()
|
||||||
m.reset_entropy = reset_device.internal_entropy
|
m.reset_entropy = reset_device.internal_entropy
|
||||||
m.reset_word = reset_device.current_word
|
m.reset_word = reset_device.current_word
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
|
||||||
@unimport
|
|
||||||
async def dispatch_DebugLinkStop(ctx, msg):
|
async def dispatch_DebugLinkStop(ctx, msg):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@unimport
|
|
||||||
async def dispatch_DebugLinkMemoryRead(ctx, msg):
|
async def dispatch_DebugLinkMemoryRead(ctx, msg):
|
||||||
from trezor.messages.DebugLinkMemory import DebugLinkMemory
|
|
||||||
from uctypes import bytes_at
|
|
||||||
m = DebugLinkMemory()
|
m = DebugLinkMemory()
|
||||||
m.memory = bytes_at(msg.address, msg.length)
|
m.memory = bytes_at(msg.address, msg.length)
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
|
||||||
@unimport
|
|
||||||
async def dispatch_DebugLinkMemoryWrite(ctx, msg):
|
async def dispatch_DebugLinkMemoryWrite(ctx, msg):
|
||||||
from uctypes import bytearray_at
|
|
||||||
l = len(msg.memory)
|
l = len(msg.memory)
|
||||||
data = bytearray_at(msg.address, l)
|
data = bytearray_at(msg.address, l)
|
||||||
data[0:l] = msg.memory
|
data[0:l] = msg.memory
|
||||||
|
|
||||||
|
|
||||||
@unimport
|
|
||||||
async def dispatch_DebugLinkFlashErase(ctx, msg):
|
async def dispatch_DebugLinkFlashErase(ctx, msg):
|
||||||
# TODO: erase(msg.sector)
|
# TODO: erase(msg.sector)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
async def memory_stats(interval):
|
async def memory_stats(interval):
|
||||||
import micropython
|
|
||||||
import gc
|
|
||||||
|
|
||||||
sleep = loop.sleep(interval * 1000 * 1000)
|
sleep = loop.sleep(interval * 1000 * 1000)
|
||||||
while True:
|
while True:
|
||||||
micropython.mem_info()
|
micropython.mem_info()
|
||||||
|
Loading…
Reference in New Issue
Block a user