machine/usb: implement consistent device state transitions
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- embedded-iot, go
- 領域
- embedded-iot
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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)
- 主要言語
- Go
- スター
- 17.8k
- フォーク
- 1.1k
- 平均マージ
- 1日 4時間
- マージ済み PR(30日)
- 380
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tinygo-org/tinygo のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tinygo-org/tinygo#6727 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
tinygo-org/tinygo#6711 ·
メンテナーはふだん 1 日以内に返信
-
Builds are not reproducible: cgo snippet paths in debug info対応中かも @tridev-tej が 1 日前に担当しました。 オープンenhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tinygo-org/tinygo#6619 ·
メンテナーはふだん 1 日以内に返信
-
Fix the targets that tinygo build -target rejects対応中かも @narguis が 2 日前に担当しました。 オープンbug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
tinygo-org/tinygo#6617 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
tinygo-org/tinygo#6312 ·
メンテナーはふだん 1 日以内に返信
tinygo-org/tinygo の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sresarehumantoo/cc-artex#456 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ollama/ollama#20021 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
factory:subtask
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
release
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
github/gh-aw-mcpg#17603 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
bboerst/stratum-work#351 ·
メンテナーはふだん 1 日以内に返信