Files
DigiRadio/Software
micheleandClaude Sonnet 5 c0eee4a4ad Firmware review pass: BT1035 boot retry, BluetoothJson tests, doc catch-up
BT1035Driver::boot() had zero retry on the reset+AT-init sequence — a
single hardware RESET# pulse followed immediately by AT commands,
with no second attempt if the module didn't come up in time. This is
the most plausible explanation for the intermittent "no spontaneous
UART bytes after hardware reset" / "AT init failed" boot failures
logged in docs/si4684-rf-investigation-report.md and observed again
live this morning on otherwise-identical hardware/wiring — classic
power-up timing jitter, not a permanent fault. Extracted the reset+
init sequence into resetAndInitOnce() and wrapped it in a 3-attempt
retry loop with a short delay between attempts; the one-time GPIO
config and UART driver install stay outside the loop since they don't
need repeating. Root cause of the underlying jitter is still open.

BluetoothJson.hpp was the only *Json.hpp module in the core with zero
host test coverage (status/scan/paired serialisation, auto-reconnect/
connect/speaker parsing) — every sibling module already has one.
Added bluetooth_json_test.cpp following the existing tuner_json_test
pattern; ctest now covers 20 suites instead of 19.

Documentation catch-up, found doing a full firmware re-review at the
user's request:
- POST /api/tuner/calibrate-antenna and the antcap field on
  POST /api/tuner/tune (added in a previous commit, never documented)
  are now in ch-api.tex.
- kFirmwareVersion was still hardcoded "0.8.5" despite the RF fixes,
  BLE provisioning, phone streaming, antenna calibration, and generic
  DSP param API landed since that version's actual release commit
  (0a1188a). Bumped to 0.9.0 everywhere it's mentioned (health JSON,
  the manual's title page, intro, classes, and API chapters).
- instructions.md and docs/TODO.md still described the firmware as
  frozen at 0.8.5 awaiting hardware-in-the-loop testing that has since
  happened extensively; docs/TODO.md's H5 verdict specifically still
  said "suspect U6 RF ground (re-open PCBWay)" for a bug that turned
  out to be firmware, not hardware — actively misleading, corrected.
  Both files now summarise the post-0.8.5 HIL findings and current
  open items (BT1035 root cause, intermittent HTTP unresponsiveness
  under load, antenna-limited signal quality, possibly-undersized 24 KB
  nvs partition).

Verified: idf.py build, doxygen (0 warnings), check-manual-sync,
check_si4684_blobs, ctest (20/20), two-pass xelatex manual build all
green. Flashed and confirmed live: fw reports 0.9.0, BT1035 booted on
the first attempt post-flash.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0178rASQ6ZETPMUamvpoR2KR
2026-08-19 09:23:36 +02:00
..
2026-07-06 01:12:37 +02:00
2026-07-06 01:12:37 +02:00

DigiRadio Firmware

Open-source Hi-Fi DAB+/FM receiver firmware for the ESP32-S3.

Status: fw 0.8.5 on main — BT1035 I2S slave boot init, dual OTA + DSP blob updates, EEPROM identity, NVS + flash encryption (development mode), tabbed Web UI with System uploads, 15 host tests, 4 CI jobs. Agent tasks T1T12 complete; device HIL pending first PCB.

Area Shipped in 0.8.5
Boot Si4684 HOST_LOAD, ADAU1701 RAM program, BT1035 I2S slave init (AUXCFG=3, I2SCFG=67)
Tuner FM/DAB tune, seek up/down, RSQ, RDS, DAB services + DLS
Audio 6-band EQ, mixer, stereo/bass enhance, NVS profile
Updates ESP32 dual-OTA, ADAU1701 dsp partition blob replay
Identity 24AA025E48 EUI-48 → serial, SoftAP/BT name suffix
Presets CRUD, reorder, integrated recall + last-preset at boot
Network SoftAP/STA, tabbed gzipped SPA, typed JSON REST API
Security initEncryptedStorage() — see docs/security-flash-nvs.md
Quality Doxygen, manual sync, Si4684 blob policy check

Architecture: functional core (components/core, host-tested, no ESP-IDF) + imperative shell (drivers, services, net, secure_store). Rules: AGENTS.md · backlog: docs/TODO.md

Prerequisites

Si4684 blobs (proprietary, local only — not in git):

python3 tools/fetch_si4684_firmware.py --dab-only
python3 tools/fetch_si4684_firmware.py --si46xx-dir /path/to/si46xx_firmware
python3 tools/check_si4684_blobs.py

See Firmware/Si4684-Firmware/README.md.

ESP-IDF v5.5.x, target esp32s3.

Quick start

Open this directory (Software/) as the Cursor project so AGENTS.md and .cursor/rules/ load automatically.

idf.py set-target esp32s3
idf.py build
idf.py erase-flash flash   # once when first enabling encryption (0.8.3+)
idf.py -p <port> monitor

Production flash-encryption release mode: overlay sdkconfig.defaults.production (see security doc — irreversible on chip).

Host tests

Pure core, no hardware (needs C++23 compiler on macOS — Homebrew llvm or GCC 14):

cmake -S components/core/test -B build-host \
      -DCMAKE_CXX_COMPILER="$(brew --prefix llvm)/bin/clang++"
cmake --build build-host
ctest --test-dir build-host --output-on-failure

Quality gates (CI on every push to main)

Run from Software/:

doxygen Doxyfile
python3 tools/check-manual-sync.py
python3 tools/check_si4684_blobs.py
tools/gzip-www.sh   # after editing components/net/www/index.html

CI jobs: host-tests, doxygen, manual-sync, si4684-blobs (.github/workflows/ci.yml).

Web UI

Gzipped single-page app at / — tabs: Now (RDS/DLS), Radio, Presets, Audio (6-band EQ), BT, WiFi, System (firmware OTA + DSP upload). Header shows EEPROM serial from /api/health. Source: components/net/www/index.html · regenerate embed: tools/gzip-www.sh.

HTTP API (fw 0.8.5)

Method Path Purpose
GET /api/health Status, firmware version, serial, companion-chip flags
POST /api/wifi Provision STA credentials; reboot on success
GET /api/tuner/status Tuner snapshot (DAB/FM, RDS/DLS metadata)
GET /api/tuner/services DAB service list for current ensemble
POST /api/tuner/tune Tune DAB ensemble or FM frequency
POST /api/tuner/play Start DAB service playback
POST /api/tuner/seek FM seek up or down ({"direction":"up|down"})
GET/PUT /api/audio/profile Read/apply ADAU1701 mixer + 6-band EQ
POST /api/audio/reset Factory-flat audio profile
POST /api/audio/stereo-enhance Stereo depth overlay (0100)
POST /api/audio/bass-enhance Bass enhance overlay (0100)
POST /api/dsp/program Upload ADAU1701 DRAD blob (raw bytes, reboot)
POST /api/system/ota Upload ESP32 firmware image (raw bytes, reboot)
GET /api/bluetooth/status BT1035 boot, pairing, A2DP, name, auto-reconnect
GET /api/bluetooth/paired Paired-device list from module
POST /api/bluetooth/pair Enter discoverable mode
POST /api/bluetooth/pair/stop Leave discoverable mode
POST /api/bluetooth/disconnect Release A2DP session
POST /api/bluetooth/auto-reconnect Set auto-reconnect count (015)
GET /api/stations List saved presets
POST /api/stations Add preset
POST /api/stations/remove Remove preset by index
POST /api/stations/reorder Move preset (from/to indices)
POST /api/stations/tune Recall preset (tuner + audio profile + NVS)

Wire schemas: docs/manual/ch-api.tex · C++ API: doxygen Doxyfiledocs/api/html/index.html.

Layout

Path Role
Firmware/ Si4684 .bin (local) + ADAU1701 SigmaStudio export
components/core/ Pure domain (host-tested)
components/drivers/ Si4684, ADAU1701, BT1035
components/services/ Tuner, audio, Bluetooth, station, integration
components/secure_store/ Encrypted NVS: credentials, profiles, presets
components/net/ Wi-Fi, HTTP server, gzipped web UI
sdkconfig.defaults C++23, NVS + flash encryption (dev mode)
partitions.csv nvs, otadata, dual OTA (ota_0/ota_1), dsp blob, nvs_keys
docs/manual/ LaTeX technical manual
docs/security-flash-nvs.md Encryption + device HIL checklist
docs/TODO.md Completed tasks + HIL backlog
tools/ Blob fetch, CI policy checks, UI gzip

Manual PDF: cd docs/manual && latexmk -lualatex manual.tex

Licence

Apache-2.0 — see LICENSE.