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>
63 lines
3.2 KiB
CMake
63 lines
3.2 KiB
CMake
# The following lines of boilerplate have to be in your project's CMakeLists
|
|
# in this exact order for cmake to work correctly
|
|
cmake_minimum_required(VERSION 3.5)
|
|
|
|
# Add the wrap flag for esp_wifi_init
|
|
add_compile_options(-Wl,--wrap=esp_wifi_init)
|
|
|
|
# Read version from header file before project() call
|
|
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/main/esp_hosted_coprocessor_fw_ver.h" HEADER_CONTENTS)
|
|
set(PROJECT_VERSION_REGEX "#define[ \t]+PROJECT_VERSION_MAJOR_1[ \t]+([0-9]+)[ \t\n]+#define[ \t]+PROJECT_VERSION_MINOR_1[ \t]+([0-9]+)[ \t\n]+#define[ \t]+PROJECT_VERSION_PATCH_1[ \t]+([0-9]+)")
|
|
string(REGEX MATCH "${PROJECT_VERSION_REGEX}" PROJECT_VERSION_MATCH "${HEADER_CONTENTS}")
|
|
|
|
if(PROJECT_VERSION_MATCH)
|
|
set(PROJECT_VERSION_MAJOR_1 "${CMAKE_MATCH_1}")
|
|
set(PROJECT_VERSION_MINOR_1 "${CMAKE_MATCH_2}")
|
|
set(PROJECT_VERSION_PATCH_1 "${CMAKE_MATCH_3}")
|
|
# Set PROJECT_VER before project() call to override git versioning
|
|
set(PROJECT_VER "${PROJECT_VERSION_MAJOR_1}.${PROJECT_VERSION_MINOR_1}.${PROJECT_VERSION_PATCH_1}")
|
|
message(STATUS "Setting PROJECT_VER to: ${PROJECT_VER}")
|
|
endif()
|
|
|
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
|
list(APPEND EXCLUDE_COMPONENTS lwip esp_netif)
|
|
|
|
set(COMPONENTS esp_timer esptool_py bootloader main nvs_flash esp_rom esp_wifi protocomm driver mqtt wpa_supplicant wifi_provisioning esp_driver_sdio esp_pm openthread)
|
|
|
|
#list(APPEND COMPONENTS esp_gdbstub) # in case gdbstub needed
|
|
project(network_adapter)
|
|
idf_build_set_property(COMPILE_OPTIONS "-fdiagnostics-color=always" APPEND)
|
|
|
|
if(EXISTS "${PROJECT_DIR}/../common")
|
|
set(common_dir "${PROJECT_DIR}/../common")
|
|
message(STATUS "common: ${common_dir}")
|
|
elseif(EXISTS "${PROJECT_DIR}/main/common")
|
|
set(common_dir "${PROJECT_DIR}/main/common")
|
|
message(STATUS "common: ${common_dir}")
|
|
else()
|
|
message(FATAL_ERROR "Could not find 'common' directory in either '${PROJECT_DIR}/../common' or '${PROJECT_DIR}/main/common'")
|
|
endif()
|
|
|
|
|
|
if(CONFIG_ESP_HOSTED_NETWORK_SPLIT_ENABLED)
|
|
if(EXISTS "${common_dir}/esp_hosted_lwip_src_port_hook.h")
|
|
idf_component_get_property(lwip lwip COMPONENT_LIB)
|
|
if(TARGET ${lwip})
|
|
# Use generator expressions to only apply to non-INTERFACE targets
|
|
get_target_property(lwip_type ${lwip} TYPE)
|
|
if(NOT lwip_type STREQUAL "INTERFACE_LIBRARY")
|
|
#target_include_directories(${lwip} PRIVATE "${common_dir}")
|
|
#target_compile_definitions(${lwip} PRIVATE "-DESP_IDF_LWIP_HOOK_FILENAME=\"${common_dir}/esp_hosted_lwip_src_port_hook.h\"")
|
|
# Some IDF release/v5.4 commits fail to attach hook file for udp.c, so mandate attach for every file in lwip build
|
|
message(STATUS "********** Configuring LWIP for network split port configs **********")
|
|
target_compile_options(${lwip} PRIVATE "-include" "${common_dir}/esp_hosted_lwip_src_port_hook.h")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
### Display FW Version (already read before project() call)
|
|
message(*************************************************************************************)
|
|
message(" Building ESP-Hosted-MCU FW :: ${PROJECT_VER} ")
|
|
message(*************************************************************************************)
|