machine/usb: implement consistent device state transitions
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- embedded-iot, go
- Lĩnh vực
- embedded-iot
Hướng nghiên cứu
Start with src/machine/usb.go and compare its shared configuration and interface tracking with the USB 2.0 specification §9.1, Figure 9-1; then trace RP2040 driver handling, including interrupt paths and waits. Check how state changes interact with tasks and cores. Done means implementing consistent, synchronized state transitions and verifying that interrupt, endpoint, transfer, and wait handling respects them in both configurations.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
USB 2.0 Specification §9.1 (Figure 9-1) defines USB device states and their transitions. TinyGo's USB stack does not manage these states consistently. The shared code in src/machine/usb.go tracks configuration and interface selection but has no unified device state model. Some drivers handle parts of the state on their own, for example suspend handling in the STM32 OTG FS driver. Numerous USB-related issues have been reported, and incomplete state management may be a contributing factor.
Timeout-based waits and busy-wait loops are common across TinyGo's USB drivers. Some of these do not account for device state, so they can keep running after the state has changed.
Hang during Detach/Attach (#5651, #6085)
- With
tasks, a bus reset afterDetach()could make the E5 workaround wait for SE0 to end, which never happens with the pull-up off. The IRQ path didn't account for the detached state. #6085 addresses this. - With
cores, if core 1 callsDetach()after core 0 has passed the pull-up check added in #6085, core 0 stays in the SE0 wait loop until core 1 callsAttach(). @davecheney reported this in #6085, and it also reproduces ondev.
The tasks case shows this is not only a cores problem. Even on a single core, USB interrupts can preempt API calls while they update shared state. With cores, USB code can also run concurrently on both cores, and disabling interrupts on one core does not stop the other from changing shared state.
Proposed work
- Define and implement consistent USB device state transitions based on the USB specification.
- Make interrupt handlers, endpoint handling, and transfer processing respect the current state.
- Synchronize state transitions across interrupts and cores.
- Review timeout-based and unbounded waits, and replace them with state-aware handling where appropriate.
- Verify behavior with both
tasksandcores.
I plan to start with RP2040, where the problem has been confirmed.
The goal is to address the underlying state management problem rather than continue fixing individual symptoms.
References
- USB 2.0 Specification, §9.1, Figure 9-1
- #5651 (repeated Detach/Attach stalls)
- #6085 (fix for the
taskshang)
- 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