Commit 62ec6f2
Add 02-stage-audiodriver-2michat-v2 pi-gen stage for ReSpeaker V2.0 HAT (#41)
* feat(audiodriver): add 02-stage-audiodriver-2michat-v2 for V2.0 HAT
The ReSpeaker 2-Mics Pi HAT V2.0 replaces the WM8960 codec (V1, I2C 0x1a)
with a TLV320AIC3104 codec (I2C 0x18). The mainline kernel already ships
the `snd-soc-tlv320aic3x` driver, so no DKMS module is needed — but a
device-tree overlay and a separate set of mixer defaults are required.
Without these two bits the card either never appears or appears silent.
The new stage mirrors the v1 layout:
- prerun.sh — copy_previous guard, same as v1
- 01-driver/
- 01-packages — build deps only (no dkms, no kernel headers needed)
- 03-run-chroot.sh — clone seeed-linux-dtoverlays, compile
respeaker-2mic-v2_0-overlay.dtbo with dtc, install into /boot/overlays,
enable I2C + dtoverlay=respeaker-2mic-v2_0 in /boot/config.txt
- 02-set-audio-volume/
- 01-run.sh — install script + oneshot unit (same pattern as v1)
- files/configure_audio.sh — TLV320-aware defaults: PCM 85%
(digital pre-DAC, 100% clips on typical JST speakers), HP DAC and
Line DAC to 100% (defaults sit at -23.5 dB), HP and Line output amps
unmuted at 100%, then alsactl store + wpctl sink to 1.0
- files/configure_audio.service — After=sound.target alsa-restore.service,
no dependency on a seeed-voicecard.service (none needed for v2)
The v2 stage is additive; the existing v1 stage is untouched. A build
can pick v1 or v2 by including the matching directory in stage selection.
* fix(2michat-v2): wire CI, guard mixer service, drop dead code
Follow-up to the initial 02-stage-audiodriver-2michat-v2 commit:
- build-all.yml: add build-2michat-v2 and build-2michat-v2-lva jobs and
include them in generate-rpi-imager-json.needs. Without this the new
stage exists but no image is ever produced.
- configure_audio.service: add ConditionPathExists=!/var/lib/configure_audio/success
+ ExecStartPost touch marker so mixer tuning runs once on first boot
and subsequent manual amixer + alsactl store customisations survive
reboots. Without the guard every boot reset the mixer to the stage's
canned defaults.
- configure_audio.sh: drop the wpctl block. The service runs as root
under systemd; wpctl requires the PipeWire user session (uid 1000)
and the existing `|| true` made it a silent no-op.
- 01-driver/01-packages: drop i2c-tools (no runtime hardware detection
on v2 — the overlay is fixed) and libasound2-plugins (v2 does not
install a custom asound.conf that references resample plugins).
- docs/hardware_2mic_v2.md + README.md: add a v2 hardware page and
two README rows (base + LVA) mirroring the v1 entries.
* fix(2michat-v2): run mixer tune every boot, propagate amixer failures
Address review feedback on #41: drop the first-boot guard so the mixer
tuning runs on every boot. PipeWire / WirePlumber manage ALSA state per
session and can reset controls to 0% between reboots, which would leave
users stuck silent if the service only ran once.
Also make configure_audio.sh surface amixer set failures (previously
swallowed by unconditional return 0), so that a broken tuning exits
non-zero and the systemd Restart=on-failure path actually retries
instead of falsely claiming success and persisting the broken state
via alsactl store.
Verified with a shim-based test harness (5 cases: happy path, single
amixer set failure, missing control, multiple failures, card timeout).
* fix(2michat-v2): align with #42 — add wpctl unity + user@1000 dep
Match the post-#42 pattern already used by 02-stage-audiodriver-2michat-v1:
call `wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0` after the amixer tune so
the PipeWire default sink lands at unity, and add `After=/Wants=user@1000.service`
+ `Environment=XDG_RUNTIME_DIR=/run/user/1000` to the unit so wpctl can
reach the user PipeWire socket.
Drop the `PCM 85%` amixer set: PipeWire drives PCM as hardware volume
passthrough, so wpctl unity immediately overwrites whatever we set PCM
to. Verified on satellite-bedroom: `amixer set PCM 50%` then
`wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0` leaves PCM at 100%.
Keeping the line made the intent misleading ("85% for headroom") while
having zero effect on the final state.
The rest of the amixer tuning stays — unlike WM8960 on v1 or the
DSP-driven lite board, the TLV320AIC3104 on the V2.0 HAT ships with
`HP DAC` at -23.5 dB and `HP` at ~89%. Those stages are downstream of
the PipeWire-managed PCM, so wpctl unity on its own still yields a
stuck-quiet card.
* fix(2michat-v2): boost capture PGA for wake-word detection
TLV320AIC3104 ships with the input PGA at 27% (16 dB), which is too
quiet for reliable microWakeWord triggering on a Pi Zero 2 W at typical
speaking distance. Verified on satellite-bedroom: at 27% 'Hey Jarvis'
never fires; at 80% (47.5 dB) it does. The output-side tune handled
audibility; this handles detectability.
---------
Co-authored-by: Florian Asche <github@florian-asche.de>1 parent a71b63f commit 62ec6f2
8 files changed
Lines changed: 218 additions & 0 deletions
File tree
- .github/workflows
- 02-stage-audiodriver-2michat-v2
- 01-driver
- 02-set-audio-volume
- files
- docs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
54 | 73 | | |
55 | 74 | | |
56 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 44 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 80 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
0 commit comments