USB CDC RX silently drops data when the receive buffer is full
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 28/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go, raspberry-pi
- Lĩnh vực
- embedded-iot
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Go
- Star
- 17.8k
- Fork
- 1.1k
- Merge trung bình
- 1 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 380
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của tinygo-org/tinygo
-
avr: SPI Mode2 runs as mode 1Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
tinygo-org/tinygo#6727 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
tinygo-org/tinygo#6711 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Builds are not reproducible: cgo snippet paths in debug infoCó thể đã có người làm @tridev-tej đã nhận 1 ngày trước. Đang mởenhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
tinygo-org/tinygo#6619 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Fix the targets that tinygo build -target rejectsCó thể đã có người làm @narguis đã nhận 2 ngày trước. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
tinygo-org/tinygo#6617 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
tinygo-org/tinygo#6312 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của tinygo-org/tinygo
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
sresarehumantoo/cc-artex#456 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ollama/ollama#20021 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
factory:subtask
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
release
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
github/gh-aw-mcpg#17603 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
bboerst/stratum-work#351 ·
Maintainer thường phản hồi trong vòng 1 ngày