machine/usb: implement consistent device state transitions
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- embedded-iot, go
- Ambito
- embedded-iot
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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)
- 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 ·