What changed, and why it matters
This commit is a routine build-system update for the Trezor firmware. It changes where the build process looks for the MicroPython cross-compiler binary (mpy-cross) and synchronizes a configuration header with newer MicroPython code. There is no indication this fixes or introduces a security vulnerability.
No security action required. Treat as normal build maintenance; verify firmware builds succeed and frozen bytecode output is unchanged.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch updates paths to the mpy-cross binary after upstream MicroPython moved build artifacts into a build/ subdirectory. It also refreshes mpconfigport.h to match upstream symbol renames and feature additions (e.g., RV32 emitter, t-strings, const float math, MICROPY_MODULE___FILE__, MP_NORETURN, MP_ALWAYSINLINE). Removed local type definitions now rely on upstream defaults. No runtime cryptographic, memory-safety, or trust-boundary changes are visible.
Changed components
core/SConscript.firmwarecore/SConscript.unixcore/embed/upymod/build.rscore/embed/upymod/mpycross_include/mpconfigport.hInspect captured patch +18 / −26
diff --git a/core/SConscript.firmware b/core/SConscript.firmware
index ced67a24..6bc16164 100644
--- a/core/SConscript.firmware
+++ b/core/SConscript.firmware
@@ -561,7 +561,7 @@ env.Replace(
MAKEMODULEDEFS='$PYTHON vendor/micropython/py/makemoduledefs.py',
MAKECMAKELISTS='$PYTHON tools/make_cmakelists.py',
MPY_TOOL='$PYTHON vendor/micropython/tools/mpy-tool.py',
- MPY_CROSS='vendor/micropython/mpy-cross/mpy-cross -O' + BYTECODE_OPTIMIZATION,
+ MPY_CROSS='vendor/micropython/mpy-cross/build/mpy-cross -O' + BYTECODE_OPTIMIZATION,
PB2PY='$PYTHON ../common/protob/pb2py',
)
diff --git a/core/SConscript.unix b/core/SConscript.unix
index 98e3188f..5a858fd4 100644
--- a/core/SConscript.unix
+++ b/core/SConscript.unix
@@ -580,7 +580,7 @@ env.Replace(
MAKEMODULEDEFS='$PYTHON vendor/micropython/py/makemoduledefs.py',
MAKECMAKELISTS='$PYTHON tools/make_cmakelists.py',
MPY_TOOL='$PYTHON vendor/micropython/tools/mpy-tool.py',
- MPY_CROSS='vendor/micropython/mpy-cross/mpy-cross -O' + BYTECODE_OPTIMIZATION,
+ MPY_CROSS='vendor/micropython/mpy-cross/build/mpy-cross -O' + BYTECODE_OPTIMIZATION,
PB2PY='$PYTHON ../common/protob/pb2py',
)
diff --git a/core/embed/upymod/build.rs b/core/embed/upymod/build.rs
index 1e305950..591ff49d 100644
--- a/core/embed/upymod/build.rs
+++ b/core/embed/upymod/build.rs
@@ -787,7 +787,6 @@ impl<'a> MpyBuilder<'a> {
// Build mpy-cross in the folder common for all models and targets.
let build_dir = xbuild::cargo_target_dir()?.join("mpy-cross");
- let mpy_cross = build_dir.join("mpy-cross");
let source_dir = self.mpy_dir.join("mpy-cross");
let mpycross_include = self.crate_dir.join("mpycross_include");
@@ -797,7 +796,6 @@ impl<'a> MpyBuilder<'a> {
cmd.args(["-j", ¶llel_job_count.to_string()])
.args(["-C", &source_dir.to_string_lossy()])
.arg(format!("BUILD={}", &build_dir.to_string_lossy()))
- .arg(format!("PROG={}", &mpy_cross.to_string_lossy()))
.env("INC", format!("-I{}", &mpycross_include.to_string_lossy()));
let cmd_output = cmd
@@ -809,7 +807,7 @@ impl<'a> MpyBuilder<'a> {
bail!(xbuild::format_command_error(&cmd, &cmd_output));
}
- Ok(mpy_cross)
+ Ok(build_dir.join("mpy-cross"))
}
fn build_frozen_modules(&self, qstr_preprocessed: &Path) -> Result<PathBuf> {
diff --git a/core/embed/upymod/mpycross_include/mpconfigport.h b/core/embed/upymod/mpycross_include/mpconfigport.h
index 899f602a..e889fa68 100644
--- a/core/embed/upymod/mpycross_include/mpconfigport.h
+++ b/core/embed/upymod/mpycross_include/mpconfigport.h
@@ -28,6 +28,7 @@
#define MICROPY_ALLOC_PATH_MAX (PATH_MAX)
#define MICROPY_PERSISTENT_CODE_LOAD (0)
+#define MICROPY_PERSISTENT_CODE_LOAD_NATIVE (0)
#define MICROPY_PERSISTENT_CODE_SAVE (1)
#ifndef MICROPY_PERSISTENT_CODE_SAVE_FILE
@@ -47,11 +48,16 @@
#define MICROPY_EMIT_XTENSA (1)
#define MICROPY_EMIT_INLINE_XTENSA (1)
#define MICROPY_EMIT_XTENSAWIN (1)
+#define MICROPY_EMIT_RV32 (1)
+#define MICROPY_EMIT_INLINE_RV32 (1)
+#define MICROPY_EMIT_NATIVE_DEBUG (1)
+#define MICROPY_EMIT_NATIVE_DEBUG_PRINTER (&mp_stdout_print)
#define MICROPY_DYNAMIC_COMPILER (1)
#define MICROPY_COMP_CONST_FOLDING (1)
#define MICROPY_COMP_MODULE_CONST (1)
#define MICROPY_COMP_CONST (1)
+#define MICROPY_COMP_CONST_FLOAT (1)
#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1)
#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (1)
#define MICROPY_COMP_RETURN_IF_EXPR (1)
@@ -76,6 +82,7 @@
#define MICROPY_USE_INTERNAL_PRINTF (0)
#define MICROPY_PY_FSTRINGS (1)
+#define MICROPY_PY_TSTRINGS (1)
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
#if !(defined(MICROPY_GCREGS_SETJMP) || defined(__x86_64__) || \
@@ -86,11 +93,12 @@
#define MICROPY_GCREGS_SETJMP (1)
#endif
-#define MICROPY_PY___FILE__ (0)
+#define MICROPY_MODULE___FILE__ (0)
#define MICROPY_PY_ARRAY (0)
#define MICROPY_PY_ATTRTUPLE (0)
#define MICROPY_PY_COLLECTIONS (0)
-#define MICROPY_PY_MATH (0)
+#define MICROPY_PY_MATH (MICROPY_COMP_CONST_FLOAT)
+#define MICROPY_PY_MATH_CONSTANTS (MICROPY_COMP_CONST_FLOAT)
#define MICROPY_PY_CMATH (0)
#define MICROPY_PY_GC (0)
#define MICROPY_PY_IO (0)
@@ -98,23 +106,6 @@
// type definitions for the specific machine
-#ifdef __LP64__
-typedef long mp_int_t; // must be pointer size
-typedef unsigned long mp_uint_t; // must be pointer size
-#elif defined(__MINGW32__) && defined(_WIN64)
-#include <stdint.h>
-typedef __int64 mp_int_t;
-typedef unsigned __int64 mp_uint_t;
-#elif defined(_MSC_VER) && defined(_WIN64)
-typedef __int64 mp_int_t;
-typedef unsigned __int64 mp_uint_t;
-#else
-// These are definitions for machines where sizeof(int) == sizeof(void*),
-// regardless for actual size.
-typedef int mp_int_t; // must be pointer size
-typedef unsigned int mp_uint_t; // must be pointer size
-#endif
-
// 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;
@@ -125,7 +116,7 @@ typedef long mp_off_t;
#define MP_PLAT_PRINT_STRN(str, len) (void)0
// We need to provide a declaration/definition of alloca()
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
#include <stdlib.h>
#elif defined(_WIN32)
#include <malloc.h>
@@ -139,8 +130,9 @@ typedef long mp_off_t;
#ifdef _MSC_VER
#define MP_ENDIANNESS_LITTLE (1)
-#define NORETURN __declspec(noreturn)
+#define MP_NORETURN __declspec(noreturn)
#define MP_NOINLINE __declspec(noinline)
+#define MP_ALWAYSINLINE __forceinline
#define MP_LIKELY(x) (x)
#define MP_UNLIKELY(x) (x)
#define MICROPY_PORT_CONSTANTS {MP_ROM_QSTR(MP_QSTR_dummy), MP_ROM_PTR(NULL)}
@@ -169,3 +161,5 @@ typedef int ssize_t;
typedef mp_off_t off_t;
#endif
+
+extern const struct _mp_print_t mp_stdout_print;
Why this scored 15/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.