Skip to content

fix: flush SLIP reader after ReadFlash to prevent stale data corruption#34

Merged
deadprogram merged 2 commits into
tinygo-org:mainfrom
jgangemi:jae/slip-flush
Apr 24, 2026
Merged

fix: flush SLIP reader after ReadFlash to prevent stale data corruption#34
deadprogram merged 2 commits into
tinygo-org:mainfrom
jgangemi:jae/slip-flush

Conversation

@jgangemi
Copy link
Copy Markdown
Contributor

  • add slipReader.reset() to clear leftover buffer
  • update flushInput() to also reset SLIP reader state
  • call flushInput() after ReadFlash's raw block protocol completes
  • add public FlushInput() method for callers reusing connections
  • rename GetMD5 to FlashMD5

ReadFlash uses a non-standard SLIP protocol (block reads + ACKs + MD5
frame) that can leave stale bytes in the SLIP reader's leftover buffer.
These bytes corrupt subsequent command responses when the flasher
connection is reused across multiple operations.

jgangemi added a commit to dangernoodle-io/pogopin that referenced this pull request Apr 19, 2026
- add esp32p4-rev1 case to parseChipType mapping to espflasher.ChipESP32P4Rev1
- split .firmware/sdkconfig.defaults into board-agnostic base + per-target
  overlays (esp32s3: USB_CDC + 8MB; esp32p4: UART + 16MB)
- target ESP32-P4 ECO2 silicon (SELECTS_REV_LESS_V3 + REV_MIN_100) to avoid
  rev-3 illegal-instruction panic on Elecrow CrowPanel P4 HMI 7.0
- rewrite .firmware/README test plan with current tool names and per-target
  expected values; capture operational notes (erase-first for
  ValidateFlashOffsets, stale USB-JTAG unplug/replug)
- pin tinygo.org/x/espflasher to fork branch jgangemi/espflasher#jae/esp32p4
  via pseudo-version (SLIP flush, P4 Rev1, unixTightReset, hardReset DTR);
  upstream PRs tinygo-org/espflasher#34, #36, #37, #38

Validated end-to-end on T-Dongle-S3 and Elecrow P4 (both CH340 and
USB-JTAG paths).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
jgangemi added a commit to dangernoodle-io/pogopin that referenced this pull request Apr 19, 2026
- add esp32p4-rev1 case to parseChipType mapping to espflasher.ChipESP32P4Rev1
- split .firmware/sdkconfig.defaults into board-agnostic base + per-target
  overlays (esp32s3: USB_CDC + 8MB; esp32p4: UART + 16MB)
- target ESP32-P4 ECO2 silicon (SELECTS_REV_LESS_V3 + REV_MIN_100) to avoid
  rev-3 illegal-instruction panic on Elecrow CrowPanel P4 HMI 7.0
- rewrite .firmware/README test plan with current tool names and per-target
  expected values; capture operational notes (erase-first for
  ValidateFlashOffsets, stale USB-JTAG unplug/replug)
- pin tinygo.org/x/espflasher to fork branch jgangemi/espflasher#jae/esp32p4
  via pseudo-version (SLIP flush, P4 Rev1, unixTightReset, hardReset DTR);
  upstream PRs tinygo-org/espflasher#34, #36, #37, #38

Validated end-to-end on T-Dongle-S3 and Elecrow P4 (both CH340 and
USB-JTAG paths).

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
- add slipReader.reset() to clear leftover buffer
- update flushInput() to also reset SLIP reader state
- call flushInput() after ReadFlash's raw block protocol completes
- add public FlushInput() method for callers reusing connections
- rename GetMD5 to FlashMD5

ReadFlash uses a non-standard SLIP protocol (block reads + ACKs + MD5
frame) that can leave stale bytes in the SLIP reader's leftover buffer.
These bytes corrupt subsequent command responses when the flasher
connection is reused across multiple operations.
Comment thread pkg/espflasher/flasher.go Outdated
Addresses review feedback on tinygo-org#34 — FlashMD5 suggested flashing behavior;
GetFlashMD5 makes the read intent explicit.
@deadprogram
Copy link
Copy Markdown
Member

Thanks for the fix @jgangemi now squash/merging.

@deadprogram deadprogram merged commit 86ac8c0 into tinygo-org:main Apr 24, 2026
3 checks passed
@jgangemi jgangemi deleted the jae/slip-flush branch April 25, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants