Si4684 boot fix: flash encryption off, 16MB flash, NVS enc off, main task stack 8KB, CTS timeout 10s (fixes BootCmd error 6), DMA-safe HOST_LOAD buffer

This commit is contained in:
2026-08-05 08:57:43 +02:00
parent a28120b44e
commit 34f247019a
19 changed files with 396 additions and 53 deletions
+5
View File
@@ -2,6 +2,11 @@ idf_component_register(
SRCS
"main.cpp"
"hardware_bootstrap.cpp"
"$<$<BOOL:${CONFIG_TEST_FIRMWARE}>:test_firmware.cpp>"
INCLUDE_DIRS "."
REQUIRES core net secure_store adau1701 si4684 tuner audio bt1035 bluetooth station integration ota eeprom24aa
)
if(CONFIG_TEST_FIRMWARE)
set(EXTRA_COMPONENT_DIRS "${EXTRA_COMPONENT_DIRS}" "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
+2 -2
View File
@@ -92,7 +92,7 @@ std::expected<void, HardwareBootError> HardwareBootstrap::boot()
}
if (auto tunerResult = gSi4684.boot(si4684::Si4684Band::Dab); !tunerResult) {
ESP_LOGE(kTag, "Si4684 boot failed");
ESP_LOGE(kTag, "Si4684 boot failed: error %d", static_cast<int>(tunerResult.error()));
return std::unexpected(HardwareBootError::Si4684BootFailed);
}
@@ -104,7 +104,7 @@ std::expected<void, HardwareBootError> HardwareBootstrap::boot()
}
}
const auto* busHandle =
auto* busHandle =
static_cast<i2c_master_bus_handle_t>(gAdau1701.i2cBusHandle());
eeprom24aa::Eeprom24aa eeprom(busHandle,
static_cast<std::uint8_t>(
+17
View File
@@ -0,0 +1,17 @@
## IDF Component Manager Manifest File
dependencies:
## Required IDF version
idf:
version: '>=4.1.0'
# # Put list of dependencies here
# # For components maintained by Espressif:
# component: "~1.0.0"
# # For 3rd party components:
# username/component: ">=1.0.0,<2.0.0"
# username2/component2:
# version: "~1.0.0"
# # For transient dependencies `public` flag can be set.
# # `public` flag doesn't have an effect dependencies of the `main` component.
# # All dependencies of `main` are public by default.
# public: true
espressif/mdns: '*'
+10
View File
@@ -17,6 +17,7 @@
#include "net/NetBootstrap.hpp"
#include "ota/OtaService.hpp"
#include "secure_store/NvsSecureStore.hpp"
#include "si4684/Si4684Tuner.hpp"
#include "station/StationService.hpp"
#include "tuner/TunerService.hpp"
@@ -24,6 +25,10 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#if CONFIG_TEST_FIRMWARE
#include "test_firmware.hpp"
#endif
namespace {
constexpr char kTag[] = "digiradio";
@@ -59,6 +64,11 @@ extern "C" void app_main()
return;
}
#if CONFIG_TEST_FIRMWARE
test_firmware::runTestFirmware();
return;
#endif
static secure_store::NvsSecureStore store;
static tuner::TunerService tunerService(
+194
View File
@@ -0,0 +1,194 @@
/**
* @file test_firmware.cpp
* @brief Minimal firmware sequence for board, ADAU1701, Si4684 and BT1035 tests.
*
* DigiRadio firmware — https://github.com/manvalan/DigiRadio
*
* Copyright 2026 Michele Bigi
* SPDX-License-Identifier: Apache-2.0
*/
#include "adau1701/Adau1701Dsp.hpp"
#include "adau1701/Adau1701Driver.hpp"
#include "adau1701/EmbeddedDspProgramSource.hpp"
#include "adau1701/FallbackDspProgramSource.hpp"
#include "adau1701/FlashDspProgramSource.hpp"
#include "board_pins.hpp"
#include "bt1035/Bt1035Driver.hpp"
#include "core/Bt1035At.hpp"
#include "core/FrequencyKHz.hpp"
#include "esp_log.h"
#include "esp_system.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "si4684/Si4684Band.hpp"
#include "si4684/Si4684Driver.hpp"
#include "si4684/Si4684EmbeddedImages.hpp"
#include "test_firmware.hpp"
namespace test_firmware {
namespace {
constexpr char kTag[] = "testfw";
void logChipInfo()
{
esp_chip_info_t info;
esp_chip_info(&info);
ESP_LOGI(kTag, "ESP32 chip: %d cores, rev %d, features=0x%x",
info.cores, info.revision, info.features);
}
void logError(const char* stage, int code)
{
ESP_LOGE(kTag, "%s failed (err=%d)", stage, code);
}
void logStage(const char* stage)
{
ESP_LOGI(kTag, "==== %s ====", stage);
}
const char* a2dpStateToken(core::Bt1035A2dpState state) noexcept
{
using core::Bt1035A2dpState;
switch (state) {
case Bt1035A2dpState::Unsupported:
return "unsupported";
case Bt1035A2dpState::Standby:
return "standby";
case Bt1035A2dpState::Connecting:
return "connecting";
case Bt1035A2dpState::Connected:
return "connected";
case Bt1035A2dpState::Streaming:
return "streaming";
case Bt1035A2dpState::Paused:
return "paused";
}
return "unknown";
}
} // namespace
void runTestFirmware()
{
logStage("Board check");
logChipInfo();
logStage("Boot ADAU1701");
adau1701::EmbeddedDspProgramSource embeddedDspProgram;
adau1701::FlashDspProgramSource flashDspProgram;
adau1701::FallbackDspProgramSource dspProgramSource(
flashDspProgram, embeddedDspProgram);
adau1701::Adau1701Driver adau(
adau1701::Adau1701Pins{
.i2cSda = board::pins::Adau1701Sda,
.i2cScl = board::pins::Adau1701Scl,
.resetGpio = board::pins::Adau1701Reset,
.i2cAddr7 = board::pins::Adau1701Addr,
},
dspProgramSource);
if (auto result = adau.boot(); !result) {
logError("ADAU1701 boot", static_cast<int>(result.error()));
return;
}
ESP_LOGI(kTag, "ADAU1701 boot succeeded");
logStage("Boot Si4684");
si4684::Si4684EmbeddedImages images;
si4684::Si4684Driver si4684(
si4684::Si4684Pins{
.spiHost = SPI2_HOST,
.csGpio = board::pins::Si4684Cs,
.misoGpio = board::pins::Si4684Miso,
.mosiGpio = board::pins::Si4684Mosi,
.sclkGpio = board::pins::Si4684Sclk,
.rstbGpio = board::pins::Si4684Rstb,
.intbGpio = board::pins::Si4684Intb,
},
images.romPatch(),
images.dabFirmware(),
images.fmFirmware());
if (auto result = si4684.boot(si4684::Si4684Band::Fm); !result) {
logError("Si4684 boot", static_cast<int>(result.error()));
return;
}
ESP_LOGI(kTag, "Si4684 FM boot succeeded");
logStage("BT1035 boot");
bt1035::Bt1035Driver bt(
bt1035::Bt1035Pins{
.uartTx = board::pins::Bt1035UartTx,
.uartRx = board::pins::Bt1035UartRx,
.rtsGpio = board::pins::Bt1035Rts,
.ctsGpio = board::pins::Bt1035Cts,
.resetGpio = board::pins::Bt1035Reset,
.sysCtlGpio = board::pins::Bt1035SysCtl,
});
if (auto result = bt.boot(); !result) {
logError("BT1035 boot", static_cast<int>(result.error()));
return;
}
ESP_LOGI(kTag, "BT1035 boot succeeded");
if (auto nameResult = bt.queryDeviceName(); nameResult) {
ESP_LOGI(kTag, "BT1035 name=%s", nameResult->c_str());
}
if (auto result = bt.setDeviceName("DigiRadio-Test"); !result) {
logError("BT1035 setDeviceName", static_cast<int>(result.error()));
}
if (auto result = bt.enterPairingMode(); !result) {
logError("BT1035 pairing mode", static_cast<int>(result.error()));
} else {
ESP_LOGI(kTag, "BT1035 pairing mode enabled");
}
if (auto states = bt.queryA2dpState(); states) {
ESP_LOGI(kTag, "BT1035 A2DP state=%s",
a2dpStateToken(states.value()));
}
if (auto listResult = bt.queryPairedList(); listResult) {
ESP_LOGI(kTag, "BT1035 paired devices=%zu", listResult->size());
}
logStage("Radio test: tune FM");
auto frequency = core::FrequencyKHz::tryFromKhz(100700U);
if (!frequency) {
ESP_LOGE(kTag, "Invalid FM frequency");
return;
}
if (auto result = si4684.tuneFm(*frequency); !result) {
logError("Si4684 tune FM", static_cast<int>(result.error()));
} else {
ESP_LOGI(kTag, "Si4684 tuned FM to %u kHz", frequency->value());
}
if (auto result = si4684.setVolume(16); !result) {
logError("Si4684 setVolume", static_cast<int>(result.error()));
}
if (auto rsqResult = si4684.readFmRsq(); rsqResult) {
ESP_LOGI(kTag,
"FM RSQ: snr=%u, afc=%d, blend=%u, stere=%u, rssi=%d",
rsqResult->snr, rsqResult->afc, rsqResult->blend,
rsqResult->stere, rsqResult->rssi);
} else {
logError("Si4684 read FM RSQ", static_cast<int>(rsqResult.error()));
}
ESP_LOGI(kTag, "Test firmware finished. Keep running for manual pairing and audio verification.");
while (true) {
vTaskDelay(pdMS_TO_TICKS(10000));
}
}
} // namespace test_firmware
+16
View File
@@ -0,0 +1,16 @@
/**
* @file test_firmware.hpp
* @brief Minimal DigiRadio hardware test firmware entrypoint.
*
* DigiRadio firmware — https://github.com/manvalan/DigiRadio
*
* Copyright 2026 Michele Bigi
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
namespace test_firmware {
void runTestFirmware();
} // namespace test_firmware