From 0b83ba43dc6affce49e07dcacb125e357b6685dc Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Sat, 5 Sep 2026 09:11:30 -0700 Subject: [PATCH] py: set the Thumb bit on code pointers only when compiling for Thumb On Xtensa and RISC-V, bit 0 makes native calls jump to an odd address. ARM needs it for Thumb. Set it only when __thumb__ is defined. RP2 loads native .mpy with the emitter off, so not MICROPY_EMIT_THUMB. No change on main: no non-ARM port runs native code yet. Co-Authored-By: Claude Opus 4.8 --- py/circuitpy_mpconfig.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 89eeee606f5..3f813e30fa7 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -199,7 +199,12 @@ extern void common_hal_mcu_enable_interrupts(void); #define BYTES_PER_WORD (4) +// Bit 0 of a code pointer selects the Thumb instruction set. +#if defined(__thumb__) #define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1)) +#else +#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)(p)) +#endif // Track stack usage. Expose results via ustack module. #define MICROPY_MAX_STACK_USAGE (0)