From 73a9719b2602a53193cf9312da34b8acd224b16c Mon Sep 17 00:00:00 2001 From: Brad Barnett <127794626+bdbarnett@users.noreply.github.com> Date: Sun, 8 Nov 2026 00:23:58 -0600 Subject: [PATCH] MicroPython: the assert handler links on stm32 lv_micropython_assert_failed used strrchr to trim the file name, and the stm32 port's C library has none, so the Arduino GIGA build failed to link. A loop does the same job. --- ports/micropython/src/lv_assert_micropython.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ports/micropython/src/lv_assert_micropython.c b/ports/micropython/src/lv_assert_micropython.c index 8351ebe..2245aa2 100644 --- a/ports/micropython/src/lv_assert_micropython.c +++ b/ports/micropython/src/lv_assert_micropython.c @@ -32,7 +32,6 @@ #include "lvgl/src/core/lv_global.h" #include "lvgl/src/display/lv_display_private.h" -#include void lv_micropython_assert_failed(const char *file, int line, const char *func); @@ -50,11 +49,14 @@ static void lv_micropython_end_pass(void) { } void lv_micropython_assert_failed(const char *file, int line, const char *func) { - const char *base = strrchr(file, '/'); - if (base == NULL) { - base = strrchr(file, '\\'); + // Keep only the file's own name. A loop, not strrchr: some ports' + // C libraries (stm32's) don't provide it. + const char *base = file; + for (const char *p = file; *p; p++) { + if (*p == '/' || *p == '\\') { + base = p + 1; + } } - base = base ? base + 1 : file; if (mp_lv_nesting_depth() == 0) { lv_micropython_end_pass(); }