Root cause (verified against our exact IDF tree, not the community guess): the "258" in "sdio_write_task: Failed to send data: 258" is NOT a timeout (that is 263). 258 = 0x102 = ESP_ERR_INVALID_ARG. On the ESP32-P4, block- mode CMD53 writes require the SOURCE buffer to be 64-byte (cache-line) aligned; the IDF sdmmc driver rejects a misaligned source with INVALID_ARG BEFORE any bus activity. esp_hosts write loop then declares "Unrecoverable host sdio state" and reboots the whole P4. The audio TX payload is not 64-aligned, so streaming mic audio wedged on the very FIRST frame (which is exactly what we saw: listening -> instant Failed to send -> reboot). This also explains why buffer/queue/clock/retry tuning all did nothing: the write never reached the bus. And why our symptom was instant, not after ~100 writes (the community block-mode-desync theory) — it is the first misaligned buffer, every time. Fix: vendored esp_hosted 2.12.11 as an editable local component (overrides the registry copy) and bounce a misaligned TX payload through one aligned DMA scratch buffer in hosted_sdio_write_block (port_esp_hosted_host_sdio.c). TX is serialized by the bus lock so a single static bounce buffer is safe; freed in hosted_sdio_deinit. Host-only change — no C6 reflash. VERIFIED ON HARDWARE (autonomous self-test): 40s of continuous mic-audio upstream streaming — the traffic that previously wedged on the first frame — ran clean, zero timeouts, zero reboots. A guarded SDIO_TX_SELFTEST harness is kept (compiled out) for future SDIO stress testing. Credit: root cause + patch designed via multi-agent investigation; the precise 258=INVALID_ARG decode (correcting the upstream community timeout assumption) came from checking our actual esp_err.h. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
225 lines
9.1 KiB
Plaintext
225 lines
9.1 KiB
Plaintext
menu "Light Sleep Power Management"
|
|
|
|
choice ESP_HOSTED_LIGHT_SLEEP_POWER_MODE
|
|
prompt "Light Sleep Power Management"
|
|
default ESP_HOSTED_LIGHT_SLEEP_POWER_DISABLED
|
|
help
|
|
Configure light sleep power management for the slave device.
|
|
|
|
Light sleep suspends the CPU while peripherals like WiFi and Bluetooth
|
|
can remain operational (if modem sleep is enabled).
|
|
|
|
MODES:
|
|
• Disabled: No light sleep (default)
|
|
• Minimum: Auto-setup for development (console active)
|
|
• Maximum: Auto-setup for production (max power saving)
|
|
• Manual: Configure everything yourself
|
|
|
|
config ESP_HOSTED_LIGHT_SLEEP_POWER_DISABLED
|
|
bool "Disabled"
|
|
help
|
|
Light sleep is disabled.
|
|
Use this if you don't need power management.
|
|
|
|
config ESP_HOSTED_LIGHT_SLEEP_POWER_MIN
|
|
bool "Minimum Power Saving (development mode)"
|
|
select PM_ENABLE
|
|
select FREERTOS_USE_TICKLESS_IDLE
|
|
select ESP_PHY_MAC_BB_PD if BT_ENABLED
|
|
select BTDM_CTRL_MODEM_SLEEP if BT_ENABLED && IDF_TARGET_ESP32
|
|
select BT_LE_SLEEP_ENABLE if BT_ENABLED && !IDF_TARGET_ESP32
|
|
help
|
|
✓ One-click setup for development
|
|
|
|
AUTO-ENABLES:
|
|
• Power Management
|
|
• FreeRTOS Tickless Idle
|
|
• BT power saving (if BT enabled)
|
|
|
|
FEATURES:
|
|
• UART console active during sleep
|
|
• Easy debugging
|
|
• Moderate power saving
|
|
|
|
config ESP_HOSTED_LIGHT_SLEEP_POWER_MAX
|
|
bool "Maximum Power Saving (production mode)"
|
|
select PM_ENABLE
|
|
select FREERTOS_USE_TICKLESS_IDLE
|
|
select ESP_PHY_MAC_BB_PD if BT_ENABLED
|
|
select BTDM_CTRL_MODEM_SLEEP if BT_ENABLED && IDF_TARGET_ESP32
|
|
select BT_LE_SLEEP_ENABLE if BT_ENABLED && !IDF_TARGET_ESP32
|
|
select PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
|
|
select ESP_HOSTED_LIGHT_SLEEP_PERIPHERAL_POWERDOWN
|
|
help
|
|
✓ One-click setup for production
|
|
|
|
AUTO-ENABLES:
|
|
• All Minimum mode settings, plus:
|
|
• Peripheral power down in light sleep
|
|
|
|
FEATURES:
|
|
• Maximum power efficiency
|
|
• UART console disabled during sleep
|
|
• Best for battery applications
|
|
|
|
NOTE: Configure additional ESP-Hosted options below for optimal power.
|
|
|
|
config ESP_HOSTED_LIGHT_SLEEP_POWER_MANUAL
|
|
bool "Manual (I'll configure everything myself)"
|
|
help
|
|
Advanced mode: Configure each power option individually.
|
|
|
|
You must manually enable:
|
|
• Power Management
|
|
• FreeRTOS Tickless Idle
|
|
• BT power features (if using BT)
|
|
endchoice
|
|
|
|
# Helper config for code to check if light sleep is enabled at all
|
|
config ESP_HOSTED_LIGHT_SLEEP_ENABLE
|
|
bool
|
|
default y if ESP_HOSTED_LIGHT_SLEEP_POWER_MIN || ESP_HOSTED_LIGHT_SLEEP_POWER_MAX || ESP_HOSTED_LIGHT_SLEEP_POWER_MANUAL
|
|
default n
|
|
|
|
menu "Light Sleep Parameters"
|
|
depends on ESP_HOSTED_LIGHT_SLEEP_ENABLE
|
|
|
|
# Only show prerequisite warnings in MANUAL mode
|
|
if ESP_HOSTED_LIGHT_SLEEP_POWER_MANUAL
|
|
comment "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
comment "• Manual Mode: Check Prerequisites Below"
|
|
comment "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
|
|
comment "⚠️ Required: ✗ Power Management"
|
|
depends on !PM_ENABLE
|
|
comment " Enable: Component config → Power Management"
|
|
depends on !PM_ENABLE
|
|
|
|
comment "⚠️ Required: ✗ FreeRTOS Tickless Idle"
|
|
depends on !FREERTOS_USE_TICKLESS_IDLE
|
|
comment " Enable: Component config → FreeRTOS → Kernel → Tickless Idle"
|
|
depends on !FREERTOS_USE_TICKLESS_IDLE
|
|
|
|
comment "⚠️ Required: ✗ BT Modem Sleep (ESP32)"
|
|
depends on BT_ENABLED && !BTDM_CTRL_MODEM_SLEEP && IDF_TARGET_ESP32
|
|
comment " Enable: Component config → Bluetooth → Modem Sleep"
|
|
depends on BT_ENABLED && !BTDM_CTRL_MODEM_SLEEP && IDF_TARGET_ESP32
|
|
|
|
comment "⚠️ Required: ✗ BT LE Sleep (other chips)"
|
|
depends on BT_ENABLED && !BT_LE_SLEEP_ENABLE && !IDF_TARGET_ESP32
|
|
comment " Enable: Component config → Bluetooth → Controller Options → Enable BLE sleep"
|
|
depends on BT_ENABLED && !BT_LE_SLEEP_ENABLE && !IDF_TARGET_ESP32
|
|
|
|
comment "⚠️ Required: ✗ MAC BB Power Down (if BT enabled)"
|
|
depends on BT_ENABLED && !ESP_PHY_MAC_BB_PD
|
|
comment " Enable: Component config → PHY → Power Management → MAC BB power down"
|
|
depends on BT_ENABLED && !ESP_PHY_MAC_BB_PD
|
|
|
|
comment "ⓘ Recommended: Power down Digital Peripheral in light sleep"
|
|
depends on !PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
|
|
comment " Enable: Component config → Power Management → Power down Digital Peripheral"
|
|
depends on !PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
|
|
|
|
comment "✓ All prerequisites configured correctly!"
|
|
depends on PM_ENABLE && FREERTOS_USE_TICKLESS_IDLE && (!BT_ENABLED || (ESP_PHY_MAC_BB_PD && ((IDF_TARGET_ESP32 && BTDM_CTRL_MODEM_SLEEP) || (!IDF_TARGET_ESP32 && BT_LE_SLEEP_ENABLE))))
|
|
|
|
comment "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
endif
|
|
|
|
# Show clean status for MIN/MAX modes
|
|
if ESP_HOSTED_LIGHT_SLEEP_POWER_MIN
|
|
comment "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
comment "✓ Minimum Power Mode Active"
|
|
comment " • All prerequisites auto-configured"
|
|
comment " • UART console available during sleep"
|
|
comment " • Good for development and debugging"
|
|
comment "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
endif
|
|
|
|
if ESP_HOSTED_LIGHT_SLEEP_POWER_MAX
|
|
comment "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
comment "✓ Maximum Power Mode Active"
|
|
comment " • All prerequisites auto-configured"
|
|
comment " • UART console disabled during sleep"
|
|
comment " • Optimized for battery applications"
|
|
comment "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
endif
|
|
|
|
config ESP_HOSTED_LIGHT_SLEEP_MIN_FREQ_MHZ
|
|
int "Minimum CPU frequency (MHz)"
|
|
default 10 if IDF_TARGET_ESP32
|
|
default 10 if IDF_TARGET_ESP32S2
|
|
default 10 if IDF_TARGET_ESP32S3
|
|
default 10 if IDF_TARGET_ESP32C2
|
|
default 10 if IDF_TARGET_ESP32C3
|
|
default 12 if IDF_TARGET_ESP32C5
|
|
default 10 if IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32C61
|
|
default 10 if IDF_TARGET_ESP32H2
|
|
range 10 240 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C6
|
|
range 10 80 if IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2
|
|
range 12 96 if IDF_TARGET_ESP32C5
|
|
help
|
|
CPU frequency when idle. Lower = more power saving.
|
|
|
|
Chipset frequency ranges:
|
|
ESP32/S2/S3: 10-240 MHz
|
|
ESP32-C2/H2: 10-80 MHz
|
|
ESP32-C3: 10-160 MHz
|
|
ESP32-C5: 12-96 MHz
|
|
ESP32-C6: 10-160 MHz
|
|
|
|
# ESP-Hosted specific power options (only shown in Manual and Max modes)
|
|
menu "Advanced Light Sleep Config"
|
|
depends on ESP_HOSTED_LIGHT_SLEEP_POWER_MANUAL
|
|
visible if ESP_HOSTED_LIGHT_SLEEP_POWER_MANUAL
|
|
|
|
comment "ⓘ Tip: Also enable 'Unload BUS driver during host sleep'"
|
|
depends on !ESP_HOSTED_UNLOAD_BUS_DRIVER_DURING_HOST_SLEEP
|
|
comment " (Example Configuration → Allow host to power save → Unload...)"
|
|
depends on !ESP_HOSTED_UNLOAD_BUS_DRIVER_DURING_HOST_SLEEP
|
|
|
|
comment "ⓘ Recommended: Power down Digital Peripheral in light sleep"
|
|
depends on !PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
|
|
comment " Enable: Component config → Power Management → Power down Digital Peripheral"
|
|
depends on !PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
|
|
|
|
config ESP_HOSTED_LIGHT_SLEEP_PERIPHERAL_POWERDOWN
|
|
bool "Power down peripherals in light sleep (disables UART console)"
|
|
depends on ESP_HOSTED_UNLOAD_BUS_DRIVER_DURING_HOST_SLEEP && PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
|
|
default y if ESP_HOSTED_LIGHT_SLEEP_POWER_MAX
|
|
default n
|
|
help
|
|
Disables UART console during sleep for maximum power saving.
|
|
|
|
REQUIREMENTS:
|
|
• Bus driver unload during host sleep (ESP-Hosted option)
|
|
• PM peripheral powerdown (Component config)
|
|
|
|
RECOMMENDED FOR:
|
|
• Production deployments
|
|
• Battery-powered applications
|
|
|
|
endmenu
|
|
|
|
# General recommendations (always visible for reference)
|
|
menu "Additional Recommendations"
|
|
comment "ⓘ WiFi: Enable WiFi Modem Sleep"
|
|
depends on SOC_WIFI_SUPPORTED
|
|
comment " Component config → Wi-Fi → WiFi Power Management"
|
|
depends on SOC_WIFI_SUPPORTED
|
|
|
|
comment "ⓘ WiFi 6: Use ITWT for better power saving"
|
|
depends on SOC_WIFI_HE_SUPPORT
|
|
comment " Example: esp-hosted-mcu/examples/host_wifi_itwt"
|
|
depends on SOC_WIFI_HE_SUPPORT
|
|
|
|
comment "ⓘ Bluetooth: Disable if not needed"
|
|
depends on BT_ENABLED
|
|
comment " Component config → Bluetooth → [ ] Bluetooth"
|
|
depends on BT_ENABLED
|
|
endmenu
|
|
|
|
endmenu
|
|
|
|
endmenu
|