refactor(core): micropython-1.28.0 embedded fixups
What changed, and why it matters
This commit updates the Trezor firmware's embedded MicroPython runtime to version 1.28.0. It swaps in newer ARM assembly helpers for garbage collection, removes some old event-polling macros, and adds support for a new exception-handling callback mechanism. There is no direct evidence in the commit or supplied references that this fixes a security vulnerability; it reads as a routine upstream synchronization/refactoring.
Treat as a normal dependency/refactoring update. If security relevance is suspected, review upstream MicroPython 1.28.0 release notes and the referenced upstream commits for any disclosed security fixes, and run regression tests on firmware and emulator builds.
Security signals we found
No security-relevant language in commit title or message
No CVE, advisory, or bug bounty reference in commit or supplied materials
Changes are mechanical alignment with upstream MicroPython 1.28.0
Removed custom MICROPY_EVENT_POLL_HOOK macros (could affect runtime behavior but no evidence of vulnerability)
Added NLR jump callback plumbing (standard upstream feature, not a security fix per se)
Evidence from the diff
The diff is a maintenance refactor to align Trezor’s embedded MicroPython port with upstream MicroPython 1.28.0. Changes include: replacing gchelper_m3.s with gchelper_thumb.s/gchelper_thumb2.s in the firmware and Rust build scripts; removing MICROPY_EVENT_POLL_HOOK and MICROPY_BEGIN/END_ATOMIC_SECTION macros from firmware and unix port headers; and adding nlr_push_jump_callback/nlr_pop_jump_callback implementations in nlrthumb.c to support upstream’s new NLR jump callbacks. No changelog entry is present and no security context is provided.
Changed components
core/SConscript.firmwarecore/embed/projects/firmware/mpconfigport.hcore/embed/projects/firmware/nlrthumb.ccore/embed/projects/unix/mpconfigport.hcore/embed/upymod/build.rsInspect captured patch +19 / −19
diff --git a/core/SConscript.firmware b/core/SConscript.firmware
index 00b62db7..937deadf 100644
--- a/core/SConscript.firmware
+++ b/core/SConscript.firmware
@@ -329,8 +329,8 @@ SOURCE_MICROPYTHON = [
'vendor/micropython/extmod/moductypes.c',
'vendor/micropython/shared/libc/abort_.c',
'vendor/micropython/shared/libc/printf.c',
- 'vendor/micropython/shared/runtime/gchelper_m3.s',
'vendor/micropython/shared/runtime/gchelper_native.c',
+ 'vendor/micropython/shared/runtime/gchelper_thumb.s'
'vendor/micropython/shared/runtime/interrupt_char.c',
'vendor/micropython/shared/runtime/pyexec.c',
'vendor/micropython/shared/runtime/stdout_helpers.c',
diff --git a/core/embed/projects/firmware/mpconfigport.h b/core/embed/projects/firmware/mpconfigport.h
index 7f40150f..86f3a755 100644
--- a/core/embed/projects/firmware/mpconfigport.h
+++ b/core/embed/projects/firmware/mpconfigport.h
@@ -197,15 +197,6 @@ typedef int mp_int_t; // must be pointer size
typedef unsigned int mp_uint_t; // must be pointer size
typedef long mp_off_t;
-#define MICROPY_BEGIN_ATOMIC_SECTION() (0)
-#define MICROPY_END_ATOMIC_SECTION(state) (void)(state)
-#define MICROPY_EVENT_POLL_HOOK \
- do { \
- extern void mp_handle_pending(bool); \
- mp_handle_pending(true); \
- __WFI(); \
- } while (0);
-
#define MICROPY_HW_BOARD_NAME "TREZORv2"
#define MICROPY_HW_MCU_NAME "STM32F427xx"
#define MICROPY_HW_HAS_SDCARD 1
diff --git a/core/embed/projects/firmware/nlrthumb.c b/core/embed/projects/firmware/nlrthumb.c
index 4cf92ddb..12d976c1 100644
--- a/core/embed/projects/firmware/nlrthumb.c
+++ b/core/embed/projects/firmware/nlrthumb.c
@@ -115,6 +115,22 @@ void nlr_pop(void) {
*top = (*top)->prev;
}
+void nlr_push_jump_callback(nlr_jump_callback_node_t *node, nlr_jump_callback_fun_t fun) {
+ nlr_jump_callback_node_t **top = &MP_STATE_THREAD(nlr_jump_callback_top);
+ node->prev = *top;
+ node->fun = fun;
+ *top = node;
+}
+
+void nlr_pop_jump_callback(bool run_callback) {
+ nlr_jump_callback_node_t **top = &MP_STATE_THREAD(nlr_jump_callback_top);
+ nlr_jump_callback_node_t *cur = *top;
+ *top = (*top)->prev;
+ if (run_callback) {
+ cur->fun(cur);
+ }
+}
+
NORETURN __attribute__((naked)) void nlr_jump(void *val) {
nlr_buf_t **top_ptr = &MP_STATE_THREAD(nlr_top);
nlr_buf_t *top = *top_ptr;
diff --git a/core/embed/projects/unix/mpconfigport.h b/core/embed/projects/unix/mpconfigport.h
index 1692cd08..ff066ddf 100644
--- a/core/embed/projects/unix/mpconfigport.h
+++ b/core/embed/projects/unix/mpconfigport.h
@@ -251,13 +251,6 @@ typedef unsigned int mp_uint_t; // must be pointer size
#endif
#endif
-#define MICROPY_EVENT_POLL_HOOK \
- do { \
- extern void mp_handle_pending(bool); \
- mp_handle_pending(true); \
- mp_hal_delay_us(500); \
- } while (0);
-
// Cannot include <sys/types.h>, as it may lead to symbol name clashes
#if _FILE_OFFSET_BITS == 64 && !defined(__LP64__)
typedef long long mp_off_t;
diff --git a/core/embed/upymod/build.rs b/core/embed/upymod/build.rs
index b8564174..850ec365 100644
--- a/core/embed/upymod/build.rs
+++ b/core/embed/upymod/build.rs
@@ -273,7 +273,7 @@ fn main() -> Result<()> {
"shared/runtime/interrupt_char.c",
"shared/runtime/pyexec.c",
"shared/runtime/stdout_helpers.c",
- // "shared/runtime/gchelper_m3.s", // This file is added later
+ // "shared/runtime/gchelper_thumb2.s", // This file is added later
],
);
} else {
@@ -302,7 +302,7 @@ fn main() -> Result<()> {
if cfg!(not(feature = "emulator")) {
// This file must not be preprocessed in MpyBuilder so it is added here
// after the build_genhdr step
- lib.add_sources_in_dir(mpy_dir, ["shared/runtime/gchelper_m3.s"]);
+ lib.add_sources_in_dir(mpy_dir, ["shared/runtime/gchelper_thumb2.s"]);
}
Ok(())
Why this scored 11/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.