Files
desklock/firmware/components/esp_hosted/tools/check_changelog.py
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

69 lines
2.4 KiB
Python

#!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
# check that the CHANGELOG.md file contains the changelog for the version
# in idf_component.yml
# exit with 0 if ok
# exit with 1 if fail
# to be run whenever idf_component.yml is updated
import argparse
import re
import sys
# paths to files to check
yml_file = "idf_component.yml"
changelog_file = "CHANGELOG.md"
def get_idf_yml_version_as_string() -> str:
# read the yml file
file_info = open(yml_file, "r")
info = file_info.read()
file_info.close()
# extract the version info
ver = re.search("^version: \"([0-9.]+)\"", info)
# print("yml:", ver.group(1))
return ver.group(1)
def changelog_has_version(ver_string: str, debug: bool = False) -> int:
# iterate over the changelog file
escaped_ver = re.escape(ver_string)
# Match the colored version heading format:
# # $${\color{COLOR} \text{VERSION}}$$ (with optional trailing text e.g. " - Some Title")
pattern = r'^# \$\$\{\\color\{[a-z]+\} \\text\{' + escaped_ver + r'\}\}\$\$'
if debug:
print(f"[debug] Looking for version : {ver_string}")
print(f"[debug] Using pattern : {pattern}")
print(f"[debug] Scanning : {changelog_file}")
print()
with open(changelog_file, "r") as changelog:
for lineno, line in enumerate(changelog, start=1):
stripped = line.rstrip('\n')
if re.match(pattern, stripped):
if debug:
print(f"[debug] MATCH at line {lineno}: {stripped!r}")
return 0
elif debug and stripped.startswith('# '):
print(f"[debug] heading line {lineno:4d}: {stripped!r}")
return 1
def check(debug: bool = False) -> int:
yml_string = get_idf_yml_version_as_string()
if debug:
print(f"[debug] Version from {yml_file}: {yml_string}")
print()
result = changelog_has_version(yml_string, debug=debug)
if result:
print(f"Changelog for version {yml_string} not found in {changelog_file}")
if not debug:
print(f"Tip: re-run with --debug for more details")
return 1
return 0
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="Check that CHANGELOG.md contains an entry for the version in idf_component.yml"
)
parser.add_argument(
"--debug",
action="store_true",
help="Print the pattern used and all # headings found in the changelog to help diagnose failures"
)
args, _ = parser.parse_known_args() # parse_known_args ignores filenames passed by pre-commit
sys.exit(check(debug=args.debug))