USB CDC RX silently drops data when the receive buffer is full
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 28/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- go, raspberry-pi
- Ambito
- embedded-iot
Direzione di ricerca
Start from cdcCallbackRx, which copies incoming USB data into the RX ring buffer and drops whatever exceeds USB.rx.Free(). Reproduce with the linked s1 program on a Pico, then look at how cdc.USB.ReadByte() drains that buffer. Done means the transfer is backpressured instead of truncated, so a 1024-byte send with a 5-second read pause arrives intact. The fix needs a flow-control design choice, so confirm the approach with a maintainer first.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
As mentioned in #6253, I found this while setting up a test environment for that work. Since it causes silent data loss, I'm reporting it separately.
USB CDC RX data is lost on a Raspberry Pi Pico when the application stops reading for 5 seconds.
With the same test program, a 512-byte transfer is received correctly (byte count and SHA-256 match), but a 1024-byte transfer results in only 513 bytes being read.
Steps to reproduce
Minimal reproducer: https://github.com/rdon-key/tinygo-usb-test/tree/main/s1
From the repository root, flash the Pico with TinyGo 0.44.0:
tinygo flash -target=pico -scheduler=tasks ./s1/tinygo/main.go
Run the host program on Windows (adjust the port as needed):
go -C s1/host run . -port COM12 -size 512
Reset the Pico, then run it again with 1024 bytes:
go -C s1/host run . -port COM12 -size 1024
The host sends size bytes where data[i] = byte(i).
On the Pico, the program reads the first byte using cdc.USB.ReadByte(), sleeps for 5 seconds without reading, and then reads for another 3 seconds.
The Pico sends back the number of bytes actually read and their SHA-256 hash. The host compares both with the transmitted data.
Actual result
512 bytes — PASS
S1 - USB CDC RX Data Loss Reproducer
Sent : 512 B
Received : 512 B
SHA-256 : MATCH
Result : PASS
1024 bytes — FAIL
S1 - USB CDC RX Data Loss Reproducer
Sent : 1024 B
Received : 513 B
SHA-256 : MISMATCH
Result : FAIL
Expected result
USB CDC should not silently lose data when the application temporarily stops reading.
When the receiver cannot accept more data, USB transfers should be backpressured rather than silently discarded.
Environment
- Board: Raspberry Pi Pico (RP2040)
- TinyGo: 0.44.0
- Target:
pico - Scheduler:
tasks - Host: Windows AMD64
Notes
The CDC RX ring buffer has a capacity of 512 bytes.
In TinyGo 0.44.0, cdcCallbackRx limits incoming data to the available RX buffer space:
free := USB.rx.Free()
USB.rx.Put(b[:min(len(b), int(free))])
This silently discards any bytes that do not fit. It matches the observed result: 1 byte consumed by ReadByte() + 512 bytes buffered = 513 bytes.
The results above were obtained on Windows. It has not been tested with a Linux host yet.
- Lingua principale
- Go
- Stelle
- 17.8k
- Fork
- 1.1k
- Merge medio
- 1g 4h
- PR unite (30g)
- 380
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di tinygo-org/tinygo
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
tinygo-org/tinygo#6727 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
tinygo-org/tinygo#6711 ·
I maintainer di solito rispondono entro 1 giorno
-
Builds are not reproducible: cgo snippet paths in debug infoForse già presa @tridev-tej l’ha presa 1 giorno fa. Apertaenhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
tinygo-org/tinygo#6619 ·
I maintainer di solito rispondono entro 1 giorno
-
Fix the targets that tinygo build -target rejectsForse già presa @narguis l’ha presa 2 giorni fa. Apertabug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
tinygo-org/tinygo#6617 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
tinygo-org/tinygo#6312 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di tinygo-org/tinygo
Issue simili
-
release
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
github/gh-aw-mcpg#17603 ·
I maintainer di solito rispondono entro 1 giorno
-
help wanted
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 94/100
oras-project/oras-go#1827 ·
I maintainer di solito rispondono entro 1 giorno
-
docs: database/sql Sessions example never commits its batch, and its "Full Example" link is a 404Apertadocumentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
ClickHouse/clickhouse-go#2185 ·
I maintainer di solito rispondono entro 1 giorno
-
bug needs triage receiver/podman
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
open-telemetry/opentelemetry-collector-contrib#53700 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
tagvalue.Read fails with "token too long" on lines over 64 KiBForse già presa @G26karthik l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
spdx/tools-golang#319 ·