Files
desklock/firmware/components/esp_hosted/slave/main/CMakeLists.txt
T
jpmschweitzerandClaude Fable 5 cb5826e02b
Test, Build and Push / test-gateway (push) Successful in 12s
Test, Build and Push / release (push) Skipped
Test, Build and Push / build-gateway (push) Skipped
Fork fix: the SDIO wedge is FIXED (esp-hosted-mcu #167)
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>
2026-07-15 09:50:27 +02:00

116 lines
3.1 KiB
CMake

if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/common")
set(common_dir "${CMAKE_CURRENT_SOURCE_DIR}/common")
else()
set(common_dir "../../common")
endif()
set(COMPONENT_SRCS
"${common_dir}/proto/esp_hosted_rpc.pb-c.c"
"${common_dir}/utils/esp_hosted_cli.c"
"protocomm_pserial.c"
"esp_hosted_coprocessor.c"
"stats.c"
"host_power_save.c"
"slave_light_sleep.c"
"nw_split_router.c"
"slave_transport_gpio_pin_guard.c"
"slave_gpio_expander.c"
"slave_ext_coex.c"
"slave_control.c"
"slave_util.c"
)
if(CONFIG_ESP_HOSTED_USE_MEMPOOL)
list(APPEND COMPONENT_SRCS
"${common_dir}/mempool/mempool_ll.c"
"${common_dir}/mempool/mempool.c"
)
endif()
if(CONFIG_SOC_BT_SUPPORTED)
list(APPEND COMPONENT_SRCS "slave_bt.c")
endif()
if(CONFIG_ESP_HOSTED_CP_WIFI)
list(APPEND COMPONENT_SRCS "slave_wifi_std.c")
endif()
if(CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT)
list(APPEND COMPONENT_SRCS "slave_wifi_enterprise.c")
endif()
if (CONFIG_ESP_HOSTED_NETWORK_SPLIT_ENABLED)
list(APPEND COMPONENT_SRCS "slave_network_split.c")
endif()
if (CONFIG_ESP_HOSTED_OT_RCP_ENABLED)
list(APPEND COMPONENT_SRCS "slave_openthread.c")
endif()
set(COMPONENT_ADD_INCLUDEDIRS
"."
"${common_dir}"
"${common_dir}/log"
"${common_dir}/proto"
"${common_dir}/rpc"
"${common_dir}/transport"
"${common_dir}/mempool/include"
)
if(CONFIG_SOC_BT_SUPPORTED)
# Select BT UART code based on IDF Target
if(CONFIG_IDF_TARGET_ESP32)
list(APPEND COMPONENT_SRCS slave_bt_uart_esp32.c)
elseif(CONFIG_IDF_TARGET_ESP32C3 OR CONFIG_IDF_TARGET_ESP32S3)
list(APPEND COMPONENT_SRCS slave_bt_uart_esp32c3_s3.c)
else()
list(APPEND COMPONENT_SRCS slave_bt_uart_esp32xx.c)
endif()
endif()
if(CONFIG_ESP_SDIO_HOST_INTERFACE)
list(APPEND COMPONENT_SRCS sdio_slave_api.c)
elseif(CONFIG_ESP_SPI_HOST_INTERFACE)
list(APPEND COMPONENT_SRCS spi_slave_api.c)
elseif(CONFIG_ESP_SPI_HD_MODE)
list(APPEND COMPONENT_SRCS spi_hd_slave_api.c)
else(CONFIG_ESP_UART_HOST_INTERFACE)
list(APPEND COMPONENT_SRCS uart_slave_api.c)
endif()
if(CONFIG_ESP_HOSTED_ENABLE_PEER_DATA_TRANSFER)
list(APPEND COMPONENT_SRCS example_peer_data_transfer.c)
endif()
if(CONFIG_ESP_HOSTED_COPROCESSOR_EXAMPLE_LIGHT_SLEEP)
list(APPEND COMPONENT_SRCS example_light_sleep.c)
endif()
if(CONFIG_ESP_HOSTED_COPROCESSOR_EXAMPLE_MQTT)
list(APPEND COMPONENT_SRCS example_mqtt_client.c)
endif()
if(CONFIG_ESP_HOSTED_COPROCESSOR_EXAMPLE_HTTP_CLIENT)
list(APPEND COMPONENT_SRCS example_http_client.c)
endif()
# cli
list(APPEND COMPONENT_ADD_INCLUDEDIRS "${common_dir}/utils")
list(APPEND COMPONENT_SRCS "${common_dir}/utils/esp_hosted_cli.c")
register_component()
# Add directory of protocomm_priv.h to include paths
idf_component_get_property(protocomm_dir protocomm COMPONENT_DIR)
target_include_directories(${COMPONENT_LIB} PRIVATE "${protocomm_dir}/src/common")
# Add linker options to wrap esp_wifi_init function
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=esp_wifi_init")
if(DEFINED ENV{ESP_HOSTED_CI_PEDANTIC})
target_compile_options(${COMPONENT_LIB} PRIVATE
-Werror -Werror=deprecated-declarations -Werror=unused-variable
-Werror=unused-but-set-variable -Werror=unused-function
$<$<COMPILE_LANGUAGE:C>:-Wstrict-prototypes>)
endif()