mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-02 10:51:06 +00:00
debug: do not rely on mp_optimise_value
Reflects micropython commit 3f420c0c27bd6daa5af39517925be55b9b9a9ab3 Replaces usage of mp_optimise_value with calls from python code.
This commit is contained in:
parent
658975d4fc
commit
7630201a57
@ -35,10 +35,6 @@
|
|||||||
/// '''
|
/// '''
|
||||||
STATIC mp_obj_t mod_trezorconfig_init(void) {
|
STATIC mp_obj_t mod_trezorconfig_init(void) {
|
||||||
storage_init();
|
storage_init();
|
||||||
// wipe storage when debug build is used
|
|
||||||
if (MP_STATE_VM(mp_optimise_value) == 0) {
|
|
||||||
storage_wipe();
|
|
||||||
}
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorconfig_init_obj, mod_trezorconfig_init);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorconfig_init_obj, mod_trezorconfig_init);
|
||||||
|
@ -58,10 +58,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorui_Display_clear_obj, mod_trezorui_Di
|
|||||||
/// Refresh display (update screen).
|
/// Refresh display (update screen).
|
||||||
/// '''
|
/// '''
|
||||||
STATIC mp_obj_t mod_trezorui_Display_refresh(mp_obj_t self) {
|
STATIC mp_obj_t mod_trezorui_Display_refresh(mp_obj_t self) {
|
||||||
// draw red square in upper-right corner when debug build is used
|
|
||||||
if (MP_STATE_VM(mp_optimise_value) == 0) {
|
|
||||||
display_bar(DISPLAY_RESX - 8, 0, 8, 8, 0xF800);
|
|
||||||
}
|
|
||||||
display_refresh();
|
display_refresh();
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
@ -70,9 +70,6 @@ int main(void)
|
|||||||
mp_obj_list_init(mp_sys_path, 0);
|
mp_obj_list_init(mp_sys_path, 0);
|
||||||
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script)
|
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script)
|
||||||
|
|
||||||
// Set optimization level
|
|
||||||
MP_STATE_VM(mp_optimise_value) = PYOPT;
|
|
||||||
|
|
||||||
// Execute the main script
|
// Execute the main script
|
||||||
printf("CORE: Executing main script\n");
|
printf("CORE: Executing main script\n");
|
||||||
pyexec_frozen_module("main.py");
|
pyexec_frozen_module("main.py");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
if not __debug__:
|
if not __debug__:
|
||||||
from trezor.utils import halt
|
from trezor.utils import halt
|
||||||
halt("debug mode inactive")
|
halt('debug mode inactive')
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
from trezor import loop
|
from trezor import loop
|
||||||
@ -18,6 +18,7 @@ if __debug__:
|
|||||||
swipe_signal = loop.signal()
|
swipe_signal = loop.signal()
|
||||||
input_signal = loop.signal()
|
input_signal = loop.signal()
|
||||||
|
|
||||||
|
|
||||||
async def dispatch_DebugLinkDecision(ctx, msg):
|
async def dispatch_DebugLinkDecision(ctx, msg):
|
||||||
if msg.yes_no is not None:
|
if msg.yes_no is not None:
|
||||||
confirm_signal.send(confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED)
|
confirm_signal.send(confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED)
|
||||||
@ -26,6 +27,7 @@ if __debug__:
|
|||||||
if msg.input is not None:
|
if msg.input is not None:
|
||||||
input_signal.send(msg.input)
|
input_signal.send(msg.input)
|
||||||
|
|
||||||
|
|
||||||
async def dispatch_DebugLinkGetState(ctx, msg):
|
async def dispatch_DebugLinkGetState(ctx, msg):
|
||||||
m = DebugLinkState()
|
m = DebugLinkState()
|
||||||
m.mnemonic = storage.get_mnemonic()
|
m.mnemonic = storage.get_mnemonic()
|
||||||
@ -36,6 +38,10 @@ if __debug__:
|
|||||||
m.reset_word = ' '.join(reset_current_words)
|
m.reset_word = ' '.join(reset_current_words)
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
|
||||||
def boot():
|
def boot():
|
||||||
|
# wipe storage when debug build is used
|
||||||
|
storage.wipe()
|
||||||
|
|
||||||
register(wire_types.DebugLinkDecision, protobuf_workflow, dispatch_DebugLinkDecision)
|
register(wire_types.DebugLinkDecision, protobuf_workflow, dispatch_DebugLinkDecision)
|
||||||
register(wire_types.DebugLinkGetState, protobuf_workflow, dispatch_DebugLinkGetState)
|
register(wire_types.DebugLinkGetState, protobuf_workflow, dispatch_DebugLinkGetState)
|
||||||
|
@ -13,8 +13,15 @@ from trezor.utils import model
|
|||||||
|
|
||||||
display = Display()
|
display = Display()
|
||||||
|
|
||||||
# for desktop platforms, we need to refresh the display after each frame
|
# in debug mode, display an indicator in top right corner
|
||||||
if model() == 'EMU':
|
if __debug__:
|
||||||
|
def debug_display_refresh():
|
||||||
|
display.bar(Display.WIDTH - 8, 0, 8, 8, 0xF800)
|
||||||
|
display.refresh()
|
||||||
|
loop.after_step_hook = debug_display_refresh
|
||||||
|
|
||||||
|
# in both debug and production, emulator needs to draw the screen explicitly
|
||||||
|
elif model() == 'EMU':
|
||||||
loop.after_step_hook = display.refresh
|
loop.after_step_hook = display.refresh
|
||||||
|
|
||||||
# import constants from modtrezorui
|
# import constants from modtrezorui
|
||||||
|
Loading…
Reference in New Issue
Block a user