Files
desklock/firmware/components/esp_hosted/.gitlab/ci/templates.yml
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

327 lines
16 KiB
YAML

# Holds templates used for jobs
.premerge_check_template:
stage: pre
tags:
- build
script:
- source ${IDF_PATH}/export.sh
# check the exported fw versions
- python tools/check_fw_versions.py
# check the changelog
- python tools/check_changelog.py
# check weak functions # Can also pass --functions optionally # Can also pass --functions optionally.
- python tools/check_weak_functions.py --file host/api/src/esp_wifi_weak.c
.build_template_coprocessor:
stage: build_coprocessor
tags:
- build
dependencies: []
artifacts:
when: always
expire_in: 4 days
script:
- export IDF_PYTHON_CHECK_CONSTRAINTS=yes
- ${IDF_PATH}/install.sh --enable-ci
- source ${IDF_PATH}/export.sh
- SDKCONFIG_PATTERN="sdkconfig.ci.${SLAVE_CI_FILE}"
# Build with IDF pedantic flags and IDF build apps script
- export ESP_HOSTED_CI_PEDANTIC=1
- export EXTRA_CFLAGS="-DIDF_CI_BUILD"
- export EXTRA_CXXFLAGS="-DIDF_CI_BUILD"
- |
if [[ -n ${CONFIG_OVERRIDE} ]]; then
CONFIG_OVERRIDE_STRING="--override-sdkconfig-items=${CONFIG_OVERRIDE}"
echo "adding ${CONFIG_OVERRIDE_STRING} to build"
fi
- cd slave
# use --enable-preview-targets to build for all targets
- idf-build-apps find -p . --enable-preview-targets --config ${SDKCONFIG_PATTERN} ${CONFIG_OVERRIDE_STRING} -vv --target ${IDF_TARGET}
- idf-build-apps build -p . --enable-preview-targets --config ${SDKCONFIG_PATTERN} ${CONFIG_OVERRIDE_STRING} -vv --target ${IDF_TARGET}
.build_template_example:
stage: build_example
tags:
- build
dependencies: []
artifacts:
when: always
expire_in: 4 days
script:
- export IDF_PYTHON_CHECK_CONSTRAINTS=yes
- ${IDF_PATH}/install.sh --enable-ci
- source ${IDF_PATH}/export.sh
# Need to rename the cloned "esp_hosted_mcu" directory since the injected component name is "esp_hosted"
- cd .. && rm -rf esp_hosted && mv esp_hosted_mcu esp_hosted && cd esp_hosted
# Create components directory and link esp_hosted component
- export OVERRIDE_PATH=`pwd`
- cd examples/${EXAMPLE_TO_BUILD}
# Create components directory and link esp_hosted component
- mkdir -p components
- ln -sf ${OVERRIDE_PATH} components/esp_hosted
# Override component dependency as backup only if not already present
- |
if ! grep -q "esp_hosted" main/idf_component.yml 2>/dev/null; then
cat ${OVERRIDE_PATH}/.gitlab-ci-override-idf-component.yml >> main/idf_component.yml
echo "Added esp_hosted override to idf_component.yml"
fi
# Add slave target configuration if specified
# Also add wi-fi remote slave target for supported targets (not ESP32-H2)
- |
if [ ! -z "${IDF_SLAVE_TARGET}" ]; then
if [[ "${IDF_SLAVE_TARGET}" != "esp32h2" ]]; then
echo "CONFIG_SLAVE_IDF_TARGET_${IDF_SLAVE_TARGET^^}=y" >> sdkconfig.defaults
echo "Added target CONFIG_SLAVE_IDF_TARGET_${IDF_SLAVE_TARGET^^}=y to sdkconfig.defaults"
fi
echo "CONFIG_ESP_HOSTED_CP_TARGET_${IDF_SLAVE_TARGET^^}=y" >> sdkconfig.defaults
echo "Added target CONFIG_ESP_HOSTED_CP_TARGET_${IDF_SLAVE_TARGET^^}=y to sdkconfig.defaults"
fi
# Append sdkconfig.ci.common if available
- |
if [ -f sdkconfig.ci.common ]; then
cat sdkconfig.ci.common >> sdkconfig.defaults
echo "Appended sdkconfig.ci.common to sdkconfig.defaults"
fi
# Build with IDF pedantic flags and IDF build apps script
- export ESP_HOSTED_CI_PEDANTIC=1
- export EXTRA_CFLAGS="-DIDF_CI_BUILD"
- export EXTRA_CXXFLAGS="-DIDF_CI_BUILD"
# Build with extra ci config file if specified
- |
if [ ! -z "${EXAMPLE_CI_FILE}" ]; then
idf-build-apps find -p . -vv --config sdkconfig.ci.${EXAMPLE_CI_FILE} --target ${IDF_TARGET}
idf-build-apps build -p . -vv --config sdkconfig.ci.${EXAMPLE_CI_FILE} --target ${IDF_TARGET}
else
idf-build-apps find -p . -vv --target ${IDF_TARGET}
idf-build-apps build -p . -vv --target ${IDF_TARGET}
fi
# build mqtt example from examples/protocol/mqtt
# the example may be mqtt or mqtt/tcp, depending on IDF version
.build_template_example_mqtt:
stage: build
tags:
- build
artifacts:
paths:
- "artifacts_*/"
when: always
expire_in: 4 days
script:
- export IDF_PYTHON_CHECK_CONSTRAINTS=yes
- ${IDF_PATH}/install.sh --enable-ci
- source ${IDF_PATH}/export.sh
# Need to rename the cloned "esp_hosted_mcu" directory since the injected component name is "esp_hosted"
- cd .. && rm -rf esp_hosted && mv esp_hosted_mcu esp_hosted && cd esp_hosted
- export OVERRIDE_PATH=`pwd`
# get path to mqtt example to build
- |
# Check if the newer path structure exists (latest and release-v6.0)
if [ -f "${IDF_PATH}/examples/protocols/mqtt/main/idf_component.yml" ]; then
MQTT_EXAMPLE_PATH="${IDF_PATH}/examples/protocols/mqtt"
# Fall back to older path structure (release-v5.x and earlier)
elif [ -f "${IDF_PATH}/examples/protocols/mqtt/tcp/main/idf_component.yml" ]; then
MQTT_EXAMPLE_PATH="${IDF_PATH}/examples/protocols/mqtt/tcp"
else
echo "Error: Could not find MQTT example at either path"
ls -la ${IDF_PATH}/examples/protocols/mqtt/ || true
exit 1
fi
echo "Using MQTT example path: ${MQTT_EXAMPLE_PATH}"
- cd ${MQTT_EXAMPLE_PATH}
# Create components directory and link esp_hosted component
- mkdir -p components
- ln -sf ${OVERRIDE_PATH} components/esp_hosted
# Override component dependency as backup only if not already present
- |
if ! grep -q "esp_hosted" main/idf_component.yml 2>/dev/null; then
cat ${OVERRIDE_PATH}/.gitlab-ci-override-idf-component.yml >> main/idf_component.yml
echo "Added esp_hosted override to idf_component.yml"
fi
# Add slave target configuration if specified
# Also add wi-fi remote slave target for supported targets (not ESP32-H2)
- |
if [ ! -z "${IDF_SLAVE_TARGET}" ]; then
if [[ "${IDF_SLAVE_TARGET}" != "esp32h2" ]]; then
echo "CONFIG_SLAVE_IDF_TARGET_${IDF_SLAVE_TARGET^^}=y" >> sdkconfig.defaults
echo "Added target CONFIG_SLAVE_IDF_TARGET_${IDF_SLAVE_TARGET^^}=y to sdkconfig.defaults"
fi
echo "CONFIG_ESP_HOSTED_CP_TARGET_${IDF_SLAVE_TARGET^^}=y" >> sdkconfig.defaults
echo "Added target CONFIG_ESP_HOSTED_CP_TARGET_${IDF_SLAVE_TARGET^^}=y to sdkconfig.defaults"
fi
# Append sdkconfig.ci.common if available
- |
if [ -f sdkconfig.ci.common ]; then
cat sdkconfig.ci.common >> sdkconfig.defaults
echo "Appended sdkconfig.ci.common to sdkconfig.defaults"
fi
# Build with IDF pedantic flags and IDF build apps script
- export ESP_HOSTED_CI_PEDANTIC=1
- export EXTRA_CFLAGS="-DIDF_CI_BUILD"
- export EXTRA_CXXFLAGS="-DIDF_CI_BUILD"
# use --config-file to override default IDF config file
# use --enable-preview-targets to build for all targets
# use --override-sdkconfig-items to override (possibly incorrect) build target that may be in provided config file
- idf-build-apps find -p . --enable-preview-targets --config-file "${OVERRIDE_PATH}/.idf_build_apps.toml" --override-sdkconfig-items=CONFIG_IDF_TARGET=${IDF_TARGET} -vv --target ${IDF_TARGET}
- idf-build-apps build -p . --enable-preview-targets --config-file "${OVERRIDE_PATH}/.idf_build_apps.toml" --override-sdkconfig-items=CONFIG_IDF_TARGET=${IDF_TARGET} -vv --target ${IDF_TARGET}
# Copy config files back to project directory for artifacts
- mkdir -p ${OVERRIDE_PATH}/artifacts_${IDF_TARGET}_${IDF_SLAVE_TARGET}
- cp sdkconfig* ${OVERRIDE_PATH}/artifacts_${IDF_TARGET}_${IDF_SLAVE_TARGET}/ 2>/dev/null || echo "No sdkconfig files found"
- cp main/idf_component.yml ${OVERRIDE_PATH}/artifacts_${IDF_TARGET}_${IDF_SLAVE_TARGET}/ 2>/dev/null || echo "No component file found"
# Clean up the component symlink
- unlink components/esp_hosted
- echo "Cleaned up esp_hosted component symlink"
# Rename back, since post scripts expect the original name
- cd ${OVERRIDE_PATH} && cd .. && mv esp_hosted esp_hosted_mcu
# build mqtt/tcp example from espressif/mqtt Registry Component
.build_template_mqtt_tcp_component:
stage: build
tags:
- build
artifacts:
paths:
- "artifacts_*/"
when: always
expire_in: 4 days
script:
- export IDF_PYTHON_CHECK_CONSTRAINTS=yes
- ${IDF_PATH}/install.sh --enable-ci
- source ${IDF_PATH}/export.sh
# Need to rename the cloned "esp_hosted_mcu" directory since the injected component name is "esp_hosted"
- cd .. && rm -rf esp_hosted && mv esp_hosted_mcu esp_hosted && cd esp_hosted
- export OVERRIDE_PATH=`pwd`
# get the example from Component Registry
- echo "Checking out example ${IDF_REGISTRY_COMPONENT}:${IDF_REGISTRY_COMPONENT_EXAMPLE}"
- cd ..
- idf.py create-project-from-example "${IDF_REGISTRY_COMPONENT}:${IDF_REGISTRY_COMPONENT_EXAMPLE}"
- cd "${IDF_REGISTRY_COMPONENT_EXAMPLE}"
# Override esp_hosted component in example's deps with the one from the current repository
- mkdir -p components
- ln -sf ${OVERRIDE_PATH} components/esp_hosted
# Add slave target configuration if specified
# Also add wi-fi remote slave target for supported targets (not ESP32-H2)
- |
if [ ! -z "${IDF_SLAVE_TARGET}" ]; then
if [[ "${IDF_SLAVE_TARGET}" != "esp32h2" ]]; then
echo "CONFIG_SLAVE_IDF_TARGET_${IDF_SLAVE_TARGET^^}=y" >> sdkconfig.defaults
echo "Added target CONFIG_SLAVE_IDF_TARGET_${IDF_SLAVE_TARGET^^}=y to sdkconfig.defaults"
fi
echo "CONFIG_ESP_HOSTED_CP_TARGET_${IDF_SLAVE_TARGET^^}=y" >> sdkconfig.defaults
echo "Added slave target CONFIG_ESP_HOSTED_CP_TARGET_${IDF_SLAVE_TARGET^^}=y to sdkconfig.defaults"
fi
# EXAMPLE_CI_FILE: use sdkconfig CI file in example directory
- |
if [ ! -z "${SDKCONFIG_CI_FILE}" ]; then
cp ${OVERRIDE_PATH}/${SDKCONFIG_CI_FILE} ./sdkconfig.ci.custom
echo "Using custom sdkconfig: ${SDKCONFIG_CI_FILE}"
SDKCONFIG_PATTERN="sdkconfig.ci.custom"
elif [ ! -z "${EXAMPLE_CI_FILE}" ]; then
echo "Using CI sdkconfig file in example: ${EXAMPLE_CI_FILE}"
SDKCONFIG_PATTERN="./${EXAMPLE_CI_FILE}"
else
SDKCONFIG_PATTERN="sdkconfig.ci*"
fi
- echo "SDKCONFIG_PATTERN is ${SDKCONFIG_PATTERN}"
# Build with IDF pedantic flags and IDF build apps script
- export ESP_HOSTED_CI_PEDANTIC=1
- export EXTRA_CFLAGS="-DIDF_CI_BUILD"
- export EXTRA_CXXFLAGS="-DIDF_CI_BUILD"
# use --config-file to override default IDF config file
# use --enable-preview-targets to build for all targets
# use --override-sdkconfig-items to override (possibly incorrect) build target that may be in provided config file
- idf-build-apps find -p . --enable-preview-targets --config-file "${OVERRIDE_PATH}/.idf_build_apps.toml" --config ${SDKCONFIG_PATTERN} --override-sdkconfig-items=CONFIG_IDF_TARGET=${IDF_TARGET} -vv --target ${IDF_TARGET}
- idf-build-apps build -p . --enable-preview-targets --config-file "${OVERRIDE_PATH}/.idf_build_apps.toml" --config ${SDKCONFIG_PATTERN} --override-sdkconfig-items=CONFIG_IDF_TARGET=${IDF_TARGET} -vv --target ${IDF_TARGET}
# Copy config files back to project directory for artifacts
- mkdir -p ${OVERRIDE_PATH}/artifacts_${IDF_TARGET}_${IDF_SLAVE_TARGET}
- cp sdkconfig* ${OVERRIDE_PATH}/artifacts_${IDF_TARGET}_${IDF_SLAVE_TARGET}/ 2>/dev/null || echo "No sdkconfig files found"
- cp main/idf_component.yml ${OVERRIDE_PATH}/artifacts_${IDF_TARGET}_${IDF_SLAVE_TARGET}/ 2>/dev/null || echo "No component file found"
# Clean up the component symlink
- unlink components/esp_hosted
- echo "Cleaned up esp_hosted component symlink"
# Rename back, since post scripts expect the original name
- cd ${OVERRIDE_PATH} && cd .. && mv esp_hosted esp_hosted_mcu
.build_template:
stage: build
tags:
- build
artifacts:
paths:
- "artifacts_*/"
when: always
expire_in: 4 days
script:
- export IDF_PYTHON_CHECK_CONSTRAINTS=yes
- ${IDF_PATH}/install.sh --enable-ci
- source ${IDF_PATH}/export.sh
# Need to rename the cloned "esp_hosted_mcu" directory since the injected component name is "esp_hosted"
- cd .. && rm -rf esp_hosted && mv esp_hosted_mcu esp_hosted && cd esp_hosted
# Replaces esp_hosted component in example's deps with the one from the current repository
- export OVERRIDE_PATH=`pwd`
- cd ${IDF_PATH}/${IDF_EXAMPLE_PATH}
# Create components directory and link esp_hosted component
- mkdir -p components
- ln -sf ${OVERRIDE_PATH} components/esp_hosted
- echo "Created components directory with esp_hosted link:"
- ls -la components/
# Override component dependency as backup only if not already present
- |
if ! grep -q "esp_hosted" main/idf_component.yml 2>/dev/null; then
cat ${OVERRIDE_PATH}/.gitlab-ci-override-idf-component.yml >> main/idf_component.yml
echo "Added esp_hosted override to idf_component.yml"
fi
# Add slave target configuration if specified
# Also add wi-fi remote slave target for supported targets (not ESP32-H2)
- |
if [ ! -z "${IDF_SLAVE_TARGET}" ]; then
if [[ "${IDF_SLAVE_TARGET}" != "esp32h2" ]]; then
echo "CONFIG_SLAVE_IDF_TARGET_${IDF_SLAVE_TARGET^^}=y" >> sdkconfig.defaults
echo "Added target CONFIG_SLAVE_IDF_TARGET_${IDF_SLAVE_TARGET^^}=y to sdkconfig.defaults"
fi
echo "CONFIG_ESP_HOSTED_CP_TARGET_${IDF_SLAVE_TARGET^^}=y" >> sdkconfig.defaults
echo "Added slave target CONFIG_ESP_HOSTED_CP_TARGET_${IDF_SLAVE_TARGET^^}=y to sdkconfig.defaults"
fi
# HOSTED_CI_FILE: use custom sdkconfig CI file from esp_hosted directory, or
# EXAMPLE_CI_FILE: use sdkconfig CI file in example directory
- |
if [ ! -z "${SDKCONFIG_CI_FILE}" ]; then
cp ${OVERRIDE_PATH}/${SDKCONFIG_CI_FILE} ./sdkconfig.ci.custom
echo "Using custom sdkconfig: ${SDKCONFIG_CI_FILE}"
SDKCONFIG_PATTERN="sdkconfig.ci.custom"
elif [ ! -z "${EXAMPLE_CI_FILE}" ]; then
echo "Using CI sdkconfig file in example: ${EXAMPLE_CI_FILE}"
SDKCONFIG_PATTERN="./${EXAMPLE_CI_FILE}"
else
SDKCONFIG_PATTERN="sdkconfig.ci*"
fi
- echo "SDKCONFIG_PATTERN is ${SDKCONFIG_PATTERN}"
# Build with IDF pedantic flags and IDF build apps script
- export ESP_HOSTED_CI_PEDANTIC=1
- export EXTRA_CFLAGS="-DIDF_CI_BUILD"
- export EXTRA_CXXFLAGS="-DIDF_CI_BUILD"
# Remove the conflicting extconn config that disables hosted
- rm -f sdkconfig.ci.*extconn*
# use --config-file to override default IDF config file
# use --enable-preview-targets to build for all targets
# use --override-sdkconfig-items to override (possibly incorrect) build target that may be in provided config file
- idf-build-apps find -p . --enable-preview-targets --config-file "${OVERRIDE_PATH}/.idf_build_apps.toml" --config ${SDKCONFIG_PATTERN} --override-sdkconfig-items=CONFIG_IDF_TARGET=${IDF_TARGET} -vv --target ${IDF_TARGET}
- idf-build-apps build -p . --enable-preview-targets --config-file "${OVERRIDE_PATH}/.idf_build_apps.toml" --config ${SDKCONFIG_PATTERN} --override-sdkconfig-items=CONFIG_IDF_TARGET=${IDF_TARGET} -vv --target ${IDF_TARGET}
# - echo "----------- last sdkconfig.defaults,ci* used (${IDF_TARGET}-${IDF_SLAVE_TARGET}) --------------"
# - cat sdkconfig.defaults
# - cat sdkconfig.ci*
# - echo "----------- last (generated) sdkconfig used (${IDF_TARGET}-${IDF_SLAVE_TARGET}) --------------"
# - cat sdkconfig
# - echo "----------------------------------------------"
# Copy config files back to project directory for artifacts
- mkdir -p ${OVERRIDE_PATH}/artifacts_${IDF_TARGET}_${IDF_SLAVE_TARGET}
- cp sdkconfig* ${OVERRIDE_PATH}/artifacts_${IDF_TARGET}_${IDF_SLAVE_TARGET}/ 2>/dev/null || echo "No sdkconfig files found"
- cp main/idf_component.yml ${OVERRIDE_PATH}/artifacts_${IDF_TARGET}_${IDF_SLAVE_TARGET}/ 2>/dev/null || echo "No component file found"
# Clean up the component symlink
- unlink components/esp_hosted
- echo "Cleaned up esp_hosted component symlink"
# Rename back, since post scripts expect the original name
- cd ${OVERRIDE_PATH} && cd .. && mv esp_hosted esp_hosted_mcu