From ada2d0dbb5442fc6828d4521dd2b32ad955c7cb3 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 4 Sep 2026 19:09:00 -0700 Subject: 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 Claude-Session: https://claude.ai/code/session_014gVYGi29FjTeLdNTiutkZx --- src/routes/(app)/pos/+page.svelte | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src') 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}
+ {#if configDone} +
Config written ✔ Device restarted
+ {:else if fwDone} +
Firmware written ✔ Device restarted
+ {/if}
{portInfo}
-- cgit v1.2.3