diff --git a/README.md b/README.md index 78d3934..6aa65db 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Free and open source (GPL-3.0), based on - + diff --git a/docs/webapp/editor/sloop-preview.wasm b/docs/webapp/editor/sloop-preview.wasm index 43eb7cf..1058ead 100644 Binary files a/docs/webapp/editor/sloop-preview.wasm and b/docs/webapp/editor/sloop-preview.wasm differ diff --git a/docs/webapp/installer/index.html b/docs/webapp/installer/index.html index 0e5fb03..9e04362 100644 --- a/docs/webapp/installer/index.html +++ b/docs/webapp/installer/index.html @@ -90,7 +90,7 @@


   
-  

+


@@ -514,7 +514,7 @@ const sayK = (k, arg = "") => { lastKey = k; lastArg = arg; $("status").textCont const say = (txt) => { lastKey = null; $("status").textContent = txt; }; const log = (t) => { $("log").textContent += t + "\n"; }; let image = null; -const meta = {"version": "2.7", "product": "FM-1_900", "pkg": "../../firmware/sloop-2.7.fwsc", "sha256": "194a254cc4df80e27b52efee58821c304391c1c0c4df8d61fa23c2c246f8c9b3"}; +const meta = {"version": "2.7.1", "product": "FM-1_900", "pkg": "../../firmware/sloop-2.7.1.fwsc", "sha256": "7c9d269d15d1c1a48e0ebada7ffa2c2aa196c19d51056fd3f760d322322b335f"}; let writing = false, stock = null; const lockAll = (on) => { diff --git a/docs/webapp/sw.js b/docs/webapp/sw.js index b96d88d..7a5b075 100644 --- a/docs/webapp/sw.js +++ b/docs/webapp/sw.js @@ -4,9 +4,9 @@ // https, so Web MIDI asks as usual (a downloaded file on Android opens as content://, where Chrome refuses MIDI). // Online the network always wins (the page as published, never an old one); the copy is only the fallback. // A new site (any file changed) is a new sw.js: the new copy replaces the old one. -const STAMP = "2.7-6e6066c0d589"; // version + a hash of the files +const STAMP = "2.7.1-c4ebf0d8d2aa"; // version + a hash of the files const CACHE = "sloop-site-" + STAMP; -const FILES = ["../firmware/sloop-2.7.fwsc", "editor/", "editor/FUKIAI-LICENSE.txt", "editor/fukiai.ttf", "editor/preview-worklet.js", "editor/preview.js", "editor/sloop-preview.wasm", "icon-192.png", "icon-512.png", "icon-maskable-512.png", "installer/", "sloop.webmanifest"]; // relative to this file +const FILES = ["../firmware/sloop-2.7.1.fwsc", "editor/", "editor/FUKIAI-LICENSE.txt", "editor/fukiai.ttf", "editor/preview-worklet.js", "editor/preview.js", "editor/sloop-preview.wasm", "icon-192.png", "icon-512.png", "icon-maskable-512.png", "installer/", "sloop.webmanifest"]; // relative to this file const KEEP = new Set(FILES.map((f) => new URL(f, self.location).href)); const key = (url) => { // the copy's name of a request: no query, index.html = the folder diff --git a/firmware/hal/fm1_cpu1.h b/firmware/hal/fm1_cpu1.h index 0b87dcb..7c2a00d 100644 --- a/firmware/hal/fm1_cpu1.h +++ b/firmware/hal/fm1_cpu1.h @@ -54,8 +54,7 @@ void __attribute__((section(".c1_text"), noreturn, used)) fm1_c1_main(void) static void fm1_cpu1_hold(void) { - FM1_C1_CON |= 0x2u; - FM1_C1_CON &= ~0x8u; + fm1_cpu1_halt(); /* (2.7.1, fm1_sys.h) the bus-invalid traps off around the hold */ FM1_C1_SYNC(); fm1_c1_on = 0; } diff --git a/firmware/hal/fm1_sys.h b/firmware/hal/fm1_sys.h index 4e1cf69..fbc1f6a 100644 --- a/firmware/hal/fm1_sys.h +++ b/firmware/hal/fm1_sys.h @@ -131,11 +131,44 @@ static void fm1_reset_reason(void) fm1_boot.wdt_con = fm1_p33_read(FM1_P3_WDT_CON); } +/* SLOOP 2.7.1, after Felucca 1.6.1 (Leo Kuroshita, GPL-3.0, fm1_sys.h fm1_cpu1_halt): hold the second core with the + * bus-invalid traps off. Holding core 1 cuts the access it has on the bus, and the chip flags that a few instructions + * later as a bus-invalid access (DBG_MSG bits 4, 5, 16..21): with the traps on (fm1_guard.h FM1_GUARD_BUS) core 0 took + * the exception. On a FM-1 whose core 1 once ran late (fm1_cpu1_wait: 8 ms, then one core), that was a FELUCCA CRASH + * screen in mix_block (vec 1, DBG_MSG bit 21) and a reboot instead of a glitch. So: traps off, hold, let the flag + * come, clear it, traps back as they were. Registers only: safe when core 1 never ran */ +#define FM1__C1_CON (*(volatile uint32_t *)0x1EEE004u) +#define FM1__DBG_WR_EN (*(volatile uint32_t *)0x1EEE240u) +#define FM1__DBG_MSG_CLR (*(volatile uint32_t *)0x1EEE248u) +#define FM1__DBG_EN (*(volatile uint32_t *)0x1EEE340u) +#define FM1__DBG_BUS 0x003F0030u /* bus-invalid traps: AXI rd/wr (4, 5), C0/C1 fetch/rd/wr (16..21) */ +FM1_INLINE void fm1_cpu1_halt(void) +{ + uint32_t locked = !(FM1__DBG_WR_EN & 1u), en, bus = FM1__DBG_BUS; + volatile uint32_t n; + __asm__("" : "+r"(bus)); /* (as Felucca: ~bus not folded into a constant) */ + if (locked) + FM1__DBG_WR_EN = 0xE7u; /* unlock (as fm1_guard.h) */ + en = FM1__DBG_EN; + FM1__DBG_EN = en & ~bus; + __asm__ volatile("csync" ::: "memory"); + FM1__C1_CON |= 0x2u; /* hold: bit 1 set, then bit 3 (enable) cleared */ + FM1__C1_CON &= ~0x8u; + __asm__ volatile("csync" ::: "memory"); + for (n = 0; n < 256u; n++) /* the flag comes some instructions after the hold */ + ; + FM1__DBG_MSG_CLR = bus; + __asm__ volatile("csync" ::: "memory"); + FM1__DBG_EN = en; + if (locked && (FM1__DBG_WR_EN & 1u)) + FM1__DBG_WR_EN = 0xE7u; /* lock again */ + __asm__ volatile("csync" ::: "memory"); +} + static void fm1_reboot(void) { __asm__ volatile("cli"); - *(volatile uint32_t *)0x1EEE004u |= 0x2u; /* the second core held (fm1_cpu1.h) */ - *(volatile uint32_t *)0x1EEE004u &= ~0x8u; + fm1_cpu1_halt(); /* the second core held (2.7.1: no bus flag to trap on) */ fm1_p33_or(FM1_P3_PR_PWR, 0x10); for (;;) ; @@ -173,6 +206,7 @@ FM1_INLINE void fm1_enter_update(const uint8_t *parm) if (!(*(volatile uint32_t *)0x1EEE240u & 1u)) /* drop CPU0 write limits, as fm1_enter_uboot */ *(volatile uint32_t *)0x1EEE240u = 0xE7u; *(volatile uint32_t *)0x1EEE348u = 0; + fm1_cpu1_halt(); /* (2.7.1) held with the traps off, before the record */ for (i = 0; i < FM1_UPDATA_PARM_LEN; i++) FM1_UPDATA_PARM[i] = parm[i]; fm1_core_reset(); diff --git a/firmware/src/main.c b/firmware/src/main.c index 6b0419d..fe3de9a 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -143,8 +143,18 @@ UI_SMALL static void fm1_fault(const fm1_crash_t *c) draw_text_box(10, 102, 220, &FONT_S, b, C_WHITE, 0); hexs(b, c->rets); draw_text_box(10, 120, 220, &FONT_S, b, C_WHITE, 0); + hexs(b, c->sp); /* (2.7.1) more to read on a photo of it: the stack, */ + draw_text_box(10, 144, 220, &FONT_S, b, C_WHITE, 0); + { /* the second core (state 3 = running, how many late jobs) */ + char t[28]; + str_cpy(t, "C1 ", sizeof t); + fmt_int(t + str_len(t), (int32_t)cpu1_state); + str_cpy(t + str_len(t), " LATE ", 7); + fmt_int(t + str_len(t), (int32_t)(cpu1_timeouts > 99u ? 99u : cpu1_timeouts)); + draw_text_box(10, 162, 220, &FONT_S, t, C_WHITE, 0); + } t0 = fm1_ticks(); - while ((uint32_t)(fm1_ticks() - t0) < 4000u * 1000u * FM1_TICKS_PER_US) + while ((uint32_t)(fm1_ticks() - t0) < 10000u * 1000u * FM1_TICKS_PER_US) /* (2.7.1: 10 s, time for a photo) */ ; fm1_reboot(); } diff --git a/firmware/src/ui.c b/firmware/src/ui.c index 0d362a2..f635141 100644 --- a/firmware/src/ui.c +++ b/firmware/src/ui.c @@ -3,7 +3,7 @@ /* Felucca user interface. Four columns map to KNOB 1..4. Rendering is lazy: * every element remembers what it last drew and is redrawn only on change. */ #ifndef FELUCCA_VERSION -#define FELUCCA_VERSION "SLOOP 2.7" /* the beat machine firmware for the FM-1 (based on Felucca) */ +#define FELUCCA_VERSION "SLOOP 2.7.1" /* the beat machine firmware for the FM-1 (based on Felucca) */ #endif static void project_save(uint32_t slot); static void arrangement_save(void);