diff options
| author | Adam Soltys <[email protected]> | 2026-09-04 19:09:00 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-09-04 20:12:58 -0700 |
| commit | ada2d0dbb5442fc6828d4521dd2b32ad955c7cb3 (patch) | |
| tree | 19b6dfb3038d261fc867b44b03aa0cfcbea4e6ac /src/routes | |
| parent | e63f86a603ebae0e7c66f94bfdea69905f36f80c (diff) | |
| download | coinos-ui-ada2d0dbb5442fc6828d4521dd2b32ad955c7cb3.tar.gz coinos-ui-ada2d0dbb5442fc6828d4521dd2b32ad955c7cb3.zip | |
pos: hard-reset the device after flashing
esptool-js leaves the chip in the ROM bootloader stub after writeFlash,
so the device appeared dead until power-cycled. Pulse RTS the way
esptool.py does, drop the port (the C3 re-enumerates), and show a
"device restarted" message next to the Connect button.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_014gVYGi29FjTeLdNTiutkZx
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/(app)/pos/+page.svelte | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/routes/(app)/pos/+page.svelte b/src/routes/(app)/pos/+page.svelte index 36869fba..5ad1c99e 100644 --- a/src/routes/(app)/pos/+page.svelte +++ b/src/routes/(app)/pos/+page.svelte @@ -70,6 +70,27 @@ } }; + // Pulse RTS to hard-reset the chip out of the ROM bootloader so it boots + // the app with the new flash contents. Same sequence esptool.py uses + // ("Hard resetting via RTS pin"); on the C3's USB-JTAG-serial port RTS + // drives EN, so the device re-enumerates and must be reconnected. + let resetDevice = async () => { + try { + await transport.setDTR(false); + await transport.setRTS(true); + await new Promise((r) => setTimeout(r, 100)); + await transport.setRTS(false); + } catch (e) { + console.warn("reset failed", e); + } + try { + await transport.disconnect(); + } catch (e) {} + esploader = undefined; + connected = false; + portInfo = "Device reset. Reconnect to flash again."; + }; + let flashConfig = async () => { if (!esploader || !bytes) return; if (bytes.length !== 0x20000) { @@ -92,6 +113,7 @@ }); configDone = true; + await resetDevice(); }; function onPickFw(e) { @@ -142,6 +164,7 @@ }); fwDone = true; + await resetDevice(); } catch (e) { console.error(e); fwError = e?.message || "Flash failed."; @@ -156,6 +179,11 @@ {#if !connected} <div class="text-center"> + {#if configDone} + <div class="text-2xl mb-3">Config written ✔ Device restarted</div> + {:else if fwDone} + <div class="text-2xl mb-3">Firmware written ✔ Device restarted</div> + {/if} <button class="btn" onclick={connect}>Connect</button> <div class="text-sm mt-2 opacity-70">{portInfo}</div> </div> |
