From 599f37428d27fcbcaf346ca4a8a665f7ffab2816 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Nov 2026 12:36:12 -0300 Subject: [PATCH] Accept the UC25HQ80 flash (0xB36014) as well as the Puya P25Q80 (0x856014) Some FM-1 units sold recently (mostly AliExpress) carry a UC25HQ80 1 MiB SPI NOR with JEDEC ID 0xB36014. Same size and plain SPI NOR commands as the Puya part, but persist_boot only accepted 0x856014, so those units stayed RAM-only ("flash error"). FL_JEDEC_OK(id) accepts both IDs; persist_boot uses it. The update loader does not read the JEDEC ID anywhere in this tree (its flash access goes through fl_read_ram / fl_erase4k_ram / fl_prog_ram), so nothing changed there. Host tests persistence_test, backup_test and fm6bank_test pass (they stub the ID to 0). Not tested on a real FM-1. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01QUF6pQ1NkTwmBC8SR8AK94 --- firmware/hal/fm1_flash.h | 6 +++++- firmware/src/project.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/firmware/hal/fm1_flash.h b/firmware/hal/fm1_flash.h index 9434d8b..f4be4be 100644 --- a/firmware/hal/fm1_flash.h +++ b/firmware/hal/fm1_flash.h @@ -148,7 +148,11 @@ RAMINL int fl_wait_ready(uint32_t max_us, uint32_t *took_us) /* ---- entry points: IRQs OFF, args/buffers in RAM ---- */ -static RAMFN uint32_t fl_jedec_ram(void) /* expect 0x856014 */ +/* the 1 MiB parts the FM-1 ships with: Puya P25Q80 (0x856014) and UC25HQ80 (0xB36014, AliExpress units). + * Same size, same plain SPI NOR commands. */ +#define FL_JEDEC_OK(id) ((id) == 0x856014u || (id) == 0xB36014u) + +static RAMFN uint32_t fl_jedec_ram(void) /* expect 0x856014 or 0xB36014 (FL_JEDEC_OK) */ { fl_saved_t s; uint32_t id; if (fl_enter(&s)) return 0; diff --git a/firmware/src/project.c b/firmware/src/project.c index b02a666..9834e6b 100644 --- a/firmware/src/project.c +++ b/firmware/src/project.c @@ -1179,7 +1179,7 @@ static void persist_boot(void) /* before settings_init / pane #if FELUCCA_FLASH persist_t p; uint32_t f = irq_save(); - flash_ok = FL_FAR(fl_jedec_ram)() == 0x856014u; /* the expected 1 MiB part, else stay RAM-only */ + flash_ok = FL_JEDEC_OK(FL_FAR(fl_jedec_ram)()); /* the expected 1 MiB part, else stay RAM-only */ irq_restore(f); if (!flash_ok) return;