diff --git a/README.md b/README.md index 513d225..a693d23 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Free and open source (GPL-3.0). It grew out of #include "fm1_xip.h" +#include "fm1_flash_id.h" /* FL_JEDEC_OK: the flash parts the FM-1 ships with */ #define RAMFN __attribute__((section(".ram_text"), noinline, used)) #define RAMINL static inline __attribute__((always_inline)) @@ -148,7 +149,7 @@ 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 */ +static RAMFN uint32_t fl_jedec_ram(void) /* FL_JEDEC_OK (fm1_flash_id.h) */ { fl_saved_t s; uint32_t id; if (fl_enter(&s)) return 0; diff --git a/firmware/hal/fm1_flash_id.h b/firmware/hal/fm1_flash_id.h new file mode 100644 index 0000000..d2d2e1a --- /dev/null +++ b/firmware/hal/fm1_flash_id.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-3.0-only */ +/* The FM-1's flash parts: the JEDEC ids (0x9F) the firmware knows. Same size (1 MiB), the same plain SPI NOR commands + * (0x03/0x0B read, 0x02 program, 0x20 4 KiB erase, 0x05/0x35 status, 0x06 write enable). + * 0x856014 Puya P25Q80, the FM-1 as first sold + * 0xB36014 UC25HQ80, FM-1 units sold from late 2026 (mostly AliExpress) + * Any other id: the flash is left alone (saves stay in RAM, the update loader refuses). */ +#pragma once +#ifndef FL_JEDEC_OK +#define FL_JEDEC_OK(id) ((id) == 0x856014u || (id) == 0xB36014u) +#endif diff --git a/firmware/loader/loader.c b/firmware/loader/loader.c index ad1ffed..b1c4ea2 100644 --- a/firmware/loader/loader.c +++ b/firmware/loader/loader.c @@ -71,7 +71,7 @@ static void ldr_record_clear(void) { fm1_updata_parm_clear(); /* CRC 0: the SPL ignores it on a warm reset */ } -static int ldr_flash_known(void) { return fl_jedec_ram() == 0x856014u; } /* as the app (project.c) */ +static int ldr_flash_known(void) { return FL_JEDEC_OK(fl_jedec_ram()); } /* as the app (project.c) */ static void ldr_progress(uint32_t done, uint32_t total) { (void)done; (void)total; ldr_poll(); } #include "ldr_core.c" diff --git a/firmware/src/project.c b/firmware/src/project.c index 1f24541..dd65d87 100644 --- a/firmware/src/project.c +++ b/firmware/src/project.c @@ -1097,7 +1097,7 @@ UI_SMALL static void persist_boot(void) /* before settings_in #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)()); /* a known 1 MiB part (fm1_flash_id.h), else stay RAM-only */ irq_restore(f); if (!flash_ok) return; diff --git a/firmware/src/recovery.c b/firmware/src/recovery.c index 1b84fb2..98cdd94 100644 --- a/firmware/src/recovery.c +++ b/firmware/src/recovery.c @@ -56,7 +56,7 @@ static void recovery_main(void) recovery_last = recovery_usb_last = fm1_ticks(); recovery_fraction = fm1_ms = 0; /* No persist_boot or OTA cleanup: no flash write just for entering rescue. */ - flash_ok = FL_FAR(fl_jedec_ram)() == 0x856014u; + flash_ok = FL_JEDEC_OK(FL_FAR(fl_jedec_ram)()); lcd_init(); lcd_fill(0, 0, 240, 240, C_BLACK); draw_text_box(0, 64, 240, &FONT_S, "CLIPPER USB RESCUE", C_WHITE, 1); diff --git a/firmware/src/ui.c b/firmware/src/ui.c index 08e4c94..80e1dfd 100644 --- a/firmware/src/ui.c +++ b/firmware/src/ui.c @@ -6,7 +6,7 @@ #define UI_SMALL /* (gfx.c: minsize on the device; a test alone: nothing) */ #endif #ifndef FELUCCA_VERSION -#define FELUCCA_VERSION "CLIPPER 1.3" /* the synthesizer firmware for the FM-1 (from SLOOP 2.5, based on Felucca) */ +#define FELUCCA_VERSION "CLIPPER 1.3.1" /* the synthesizer firmware for the FM-1 (from SLOOP 2.5, based on Felucca) */ #endif static void project_save(uint32_t slot); static void arrangement_save(void); diff --git a/tests/recovery_test.c b/tests/recovery_test.c index 50139ad..9b59297 100644 --- a/tests/recovery_test.c +++ b/tests/recovery_test.c @@ -16,6 +16,7 @@ static uint32_t input_buttons, stop_at_retry; static jmp_buf exit_loop; #define FM1_TICKS_PER_US 24u #define FL_FAR(x) x +#include "../firmware/hal/fm1_flash_id.h" #define C_BLACK 0 #define C_WHITE 65535 #define FONT_S font @@ -96,6 +97,14 @@ int main(void) assert(jedec_reads == 1 && lcd_calls == 1); assert(services == 7 && sessions == 2); /* idle startup starts no update */ assert(bootguard_begin(&bootguard) == BOOT_ROM); - puts("recovery: boot failures, manual key, timer wrap, polled USB during OTA, retry, flash refusal and ROM fallback passed"); + /* the flash parts: the Puya P25Q80 and the UC25HQ80 known, anything else not (and recovery_main reads it) */ + assert(FL_JEDEC_OK(0x856014u) && FL_JEDEC_OK(0xB36014u) && !FL_JEDEC_OK(0xEF4014u) && !FL_JEDEC_OK(0u) && !FL_JEDEC_OK(0xFFFFFFu)); + jedec = 0xB36014u; flash_ok = 0; recovery_active = 0; retries = 0; stop_at_retry = 3; + if (!setjmp(exit_loop)) recovery_main(); + assert(flash_ok); + jedec = 0xEF4014u; flash_ok = 1; retries = 0; stop_at_retry = 3; + if (!setjmp(exit_loop)) recovery_main(); + assert(!flash_ok); + puts("recovery: boot failures, manual key, timer wrap, polled USB during OTA, retry, flash refusal and ROM fallback, the UC25HQ80 flash known passed"); return 0; } diff --git a/tools/publish_github.ps1 b/tools/publish_github.ps1 index 53e6bec..c7170be 100644 --- a/tools/publish_github.ps1 +++ b/tools/publish_github.ps1 @@ -1,18 +1,18 @@ # Clipper: publish the release on GitHub, from this folder (PUBLISH-GITHUB.bat). -# 1. the source: clipper-1.3.bundle -> the repository OWNER/REPO (created if it does not exist), branch main, the tag -# 2. the release v1.3 (the latest): docs/release-1.3.md, the firmware package (if INSTALL-CLIPPER.bat built it), +# 1. the source: clipper-1.3.1.bundle -> the repository OWNER/REPO (created if it does not exist), branch main, the tag +# 2. the release v1.3.1 (the latest): docs/release-1.3.1.md, the firmware package (if INSTALL-CLIPPER.bat built it), # the demo WAV # 3. the installer and the editor on GitHub Pages (branch gh-pages, from build\clipper-site) # Uses your own Git and GitHub CLI (gh) and your own GitHub login. Nothing is ever forced on main: a repository that # already has another history stops the script. gh-pages is generated: it is replaced each time. -param([string]$Owner = "", [string]$Repo = "clipper-fm1", [string]$Tag = "v1.3") +param([string]$Owner = "", [string]$Repo = "clipper-fm1", [string]$Tag = "v1.3.1") $ErrorActionPreference = 'Continue' Set-Location (Split-Path $PSScriptRoot) function Fail([string]$m) { Write-Host ""; Write-Host "ERROR: $m" -ForegroundColor Red; exit 1 } function Step([string]$m) { Write-Host "== $m" -ForegroundColor Cyan } Write-Host "" -Write-Host " C L I P P E R 1.3 -> GitHub" -ForegroundColor White +Write-Host " C L I P P E R 1.3.1 -> GitHub" -ForegroundColor White Write-Host " ---- ---- ---- ----" -ForegroundColor DarkGray # Git and GitHub CLI: on the PATH, else where their installers put them, else installed now with winget (asked first) function Find-Tool([string]$t) { @@ -52,7 +52,7 @@ if (-not $Owner) { $Owner = "$(gh api user --jq .login)".Trim() } if (-not $Owner) { Fail "could not read your GitHub user name" } $full = "$Owner/$Repo" $pages = "https://$Owner.github.io/$Repo" -$bundle = "clipper-1.3.bundle" +$bundle = "clipper-1.3.1.bundle" if (-not (Test-Path $bundle)) { Fail "$bundle not found in this folder" } $work = Join-Path "build" "publish" $repoDir = Join-Path $work "repo" @@ -82,13 +82,13 @@ if ($LASTEXITCODE -ne 0) { if ("$(git ls-remote --tags origin "refs/tags/$Tag")".Trim()) { Write-Host " (the tag $Tag is already on GitHub: kept as it is)" -ForegroundColor DarkGray } else { - git -c user.name="$Owner" -c user.email="$email" tag -a $Tag -m "Clipper 1.3" + git -c user.name="$Owner" -c user.email="$email" tag -a $Tag -m "Clipper 1.3.1" git push origin $Tag if ($LASTEXITCODE -ne 0) { Pop-Location; Fail "pushing the tag $Tag" } } $notes = Join-Path (Resolve-Path "..").Path "release-notes.md" -$src = Join-Path "docs" "release-1.3.md" -if (-not (Test-Path $src)) { Pop-Location; Fail "docs/release-1.3.md is missing from the bundle (an older bundle?)" } +$src = Join-Path "docs" "release-1.3.1.md" +if (-not (Test-Path $src)) { Pop-Location; Fail "docs/release-1.3.1.md is missing from the bundle (an older bundle?)" } $text = (Get-Content -Raw -Encoding UTF8 $src).Replace("https://isod89.github.io/clipper-fm1", $pages).Replace("isod89/clipper-fm1", $full) [IO.File]::WriteAllText($notes, $text, (New-Object Text.UTF8Encoding $false)) # (no BOM: GitHub shows the text as it is) Pop-Location @@ -100,16 +100,16 @@ $fw = Get-ChildItem (Join-Path (Join-Path $site "firmware") "clipper-*.fwsc") -E if ($fw) { $assets += $fw.FullName } else { Write-Host "(No firmware built: run INSTALL-CLIPPER.bat first. The release is published without the .fwsc; run this script again afterwards to add it.)" -ForegroundColor Yellow } $ed = Join-Path (Join-Path (Join-Path $site "webapp") "editor") "clipper-editor.html" # (1.2) the editor in one file, for offline use -if (Test-Path $ed) { $edc = Join-Path $work "clipper-editor-1.3.html"; Copy-Item $ed $edc; $assets += (Resolve-Path $edc).Path } +if (Test-Path $ed) { $edc = Join-Path $work "clipper-editor-1.3.1.html"; Copy-Item $ed $edc; $assets += (Resolve-Path $edc).Path } if (Test-Path "clipper-1.0-demo.wav") { $assets += (Resolve-Path "clipper-1.0-demo.wav").Path } gh release view $Tag --repo $full *> $null if ($LASTEXITCODE -eq 0) { Step "The release $Tag exists: updating its notes and files" - gh release edit $Tag --repo $full --prerelease=false --latest --title "Clipper 1.3" --notes-file $notes + gh release edit $Tag --repo $full --prerelease=false --latest --title "Clipper 1.3.1" --notes-file $notes if ($assets.Count -gt 0) { gh release upload $Tag @assets --repo $full --clobber } } else { Step "Creating the release $Tag" - gh release create $Tag @assets --repo $full --latest --title "Clipper 1.3" --notes-file $notes + gh release create $Tag @assets --repo $full --latest --title "Clipper 1.3.1" --notes-file $notes } if ($LASTEXITCODE -ne 0) { Fail "the release $Tag" } @@ -124,7 +124,7 @@ if (Test-Path (Join-Path (Join-Path (Join-Path $site "webapp") "installer") "ind git init --quiet git checkout --quiet -b gh-pages git add -A - git -c user.name="$Owner" -c user.email="$email" commit --quiet -m "Clipper 1.3: the installer and the editor" + git -c user.name="$Owner" -c user.email="$email" commit --quiet -m "Clipper 1.3.1: the installer and the editor" git push --force "https://github.com/$full.git" gh-pages $ok = $LASTEXITCODE -eq 0 Pop-Location