Repository navigation
A11c: pico2_uac2, the bench's independent clock - #96
Merged
Merged
Conversation
A Raspberry Pi Pico 2 as a USB Audio Class 2.0 asynchronous-mode device on its own crystal (the roadmap's Q1): 48 kHz stereo S16 at Full Speed, playback and capture on asynchronous isochronous endpoints. The device's clock is the RP2350's 1 MHz timer (the 12 MHz crystal), frames(t) = floor(t * 6 * (10^6 + ppm) / (125 * 10^6)) in exact integers. Playback drains the endpoint FIFO at that clock; TinyUSB's FIFO-count feedback endpoint makes the host follow it. Capture sends each packet the frames the clock produced since the last, with the callback's times filtered by a second-order DLL (Adriaensen, LAC 2005; 1 Hz): modelled over 600 s with up to 0.4 ms of callback lateness and a 3 ms stall every 10 s, every packet is 47, 48 or 49 frames, with a constant 58-frame lag and an exact rate. PICO2_UAC2_PPM (-1000..1000) injects a known offset so two bench runs check the fit against an exact difference. Core 1 prints a status line a second on UART0, so serial output never stalls the USB loop. Built with arm-none-eabi-gcc 13.2.1 against the Pico SDK 2.1.1 (TinyUSB 0.18.0) at -Wall -Wextra (-Wconversion for C++) with no warning; the configuration descriptor (218 bytes) walked from the ELF. CI's Pico 2 job builds it at offsets 0 and -250. It has not been enumerated by a host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
This is the last of the three PRs for the roadmap's A11. It adds
async/examples/pico2_uac2/, standalone firmware for a Raspberry Pi Pico 2 (RP2350). The board enumerates as a USB Audio Class 2.0 device in asynchronous mode, clocked by its own crystal. This is the asynchronous-mode device that Q1 chose for the bench.PICO2_UAC2_PPM(an integer in −1000..1000,async's charter; default 0) injects a known offset on top of the crystal's own error. Two bench runs at different settings must differ by exactly that much inalsa_bridge_report.py's fit, which checks the bench against an exact number.async/README.md,async/docs/HARDWARE_TESTING.md(Setup 1 now says how to check that a device is asynchronous), a new section in the book'spart5/hardware.md, and the ROADMAP A11 note.Why
Block B's verdict on
async(P8) rests on clock recovery measured between independent crystals. Many cheap USB dongles are adaptive or synchronous endpoints locked to the host's USB frames, so two of them share one effective clock (B0). A run on such a pair proves nothing. This device can't fail that way, and its injected offset gives the bench a known truth to check its own fit against.Verification
Builds. I built the firmware with arm-none-eabi-gcc 13.2.1 against the Pico SDK 2.1.1 (TinyUSB 0.18.0):
-Wall -Wextra(C) and-Wall -Wextra -Wconversion(C++);PICO2_UAC2_PPM0 and −250;.textand 16,692 B of.bss.CMake refuses
PICO2_UAC2_PPM=2000with the intended message.Descriptors. I dumped the configuration descriptor from the ELF and walked it one descriptor at a time:
Capture schedule, simulated. I modelled the schedule in Python, using the firmware's own arithmetic, over 600 s of packets.
Style: clang-format and
scripts/check_retired_words.pyare clean. Like the other Pico firmwares, this one is outside the clang-tidy gate's compile database.Not verified: the device has never been enumerated by a host. Whether Linux accepts the descriptors, how the feedback converges on a real bus, and the UART output are all Block B's first minutes. CI is the gate here for the build only.
Notes for the reviewer
-fno-exceptionsquestion (Q5).🤖 Generated with Claude Code
https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
Generated by Claude Code