feat: add USB CDC support, ReadFlash, and ESP32-S3 post-connect#22
Closed
jgangemi wants to merge 1 commit intotinygo-org:mainfrom
Closed
feat: add USB CDC support, ReadFlash, and ESP32-S3 post-connect#22jgangemi wants to merge 1 commit intotinygo-org:mainfrom
jgangemi wants to merge 1 commit intotinygo-org:mainfrom
Conversation
5d0323c to
5558114
Compare
- chunk SLIP writes to 64 bytes for USB CDC endpoint compatibility - use 1KB RAM upload blocks for USB connections - detect USB-OTG and USB-JTAG/Serial interfaces on ESP32-S3 - disable RTC WDT and enable SWD auto-feed for USB-JTAG/Serial - add ReadFlash protocol with SLIP-framed blocks and cumulative ACKs - add SLIP leftover buffer for multi-frame USB transfers - add port re-open recovery for TinyUSB CDC re-enumeration
5558114 to
41716e8
Compare
Member
|
Hello @jgangemi
I think it would better to add that support in this PR, probably. If you were to add the implementations I am sure there are people who would help test, including myself. |
Contributor
Author
|
closing this in favor of breaking it apart further for easier review. #24 supersedes this and will need to be merged before the individual chip PRs are submitted so we don't get merge conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full USB CDC device support for ESP32-S3 (and similar chips with USB-OTG or USB-JTAG/Serial interfaces):
UART_DEV_BUF_NOregisterReadFlashprotocol with SLIP-framed data blocks and cumulative ACKsMotivation
USB CDC endpoints (TinyUSB on ESP32-S3, for example) have limited buffer sizes. Without chunking, large SLIP frames overflow the endpoint buffer and cause data loss. The upstream stub loader's 6KB RAM upload blocks also time out on USB CDC — 1KB blocks resolve this. Device-tested on LILYGO T-Dongle S3 (USB-OTG via TinyUSB CDC).
Known limitation: ESP32-S3 only
The
PostConnecthook and USB interface detection are currently implemented only for ESP32-S3. Other chips with USB interfaces (ESP32-S2, ESP32-C3, ESP32-C6, ESP32-H2) would benefit from similar treatment — each has its ownUART_DEV_BUF_NOregister address and watchdog registers. ThePostConnectfield onchipDefis designed to support this; I only have ESP32-S3 hardware to test on currently. Happy to add the other targets in a follow-up if someone can verify on those chips.Test plan
go test -v ./pkg/espflasher/...— all tests passTestSendCommandChunkingverifies 64-byte write chunksTestUploadToRAMUSBBlockSizeverifies 1KB blocks for USBTestReadFlashRequiresStubverifies stub guardTestESP32S3PostConnect*tests USB-JTAG, USB-OTG, and UART detection pathsgolangci-lint run ./pkg/espflasher/...— no new issues