Files
esp-idf/tools/test_apps/build_system/err_codes_check
Guillaume Souchere d670774f5c feat(esp_common): implement composable error code registration via link-time arrays
Refactor the esp_err_to_name() system to decouple esp_common from
higher-level components. Instead of a monolithic generated table,
each component registers its error codes into a dedicated linker
section (.esp_err_msg_table) via idf_define_esp_err_codes() in its
CMakeLists.txt.

New files:
- tools/err_codes_extract.py: extract ESP_ERR_* defines from headers to CSV
- tools/err_codes_to_c.py: generate C source placing entries into linker section
- tools/err_codes_to_rst.py: generate RST documentation from error codes
- tools/cmake/err_codes.cmake: CMake module providing idf_define_esp_err_codes()
- components/esp_common/include/esp_err_codes.h: esp_err_msg_t typedef
- components/esp_common/src/esp_err_to_name_new.c: new lookup using link-time array
- tools/test_apps/build_system/err_codes_check/: CI test app

Changes:
- Remove all optional component dependencies from esp_common/CMakeLists.txt
- Add .esp_err_msg_table section to all 5 linker scripts
- Register error codes in 18 components via idf_define_esp_err_codes()
- Add new scripts to .gitlab/ci/rules.yml build_check patterns
- use new scripts to generate doc and add CI validation
- Update esp_err.rst to add description of composable code registration
2026-05-28 09:53:32 +02:00
..

Supported Targets ESP32 Linux

Error Codes Registration Check

This test app verifies that all ESP_ERR_* error codes defined across ESP-IDF components are correctly registered via idf_define_esp_err_codes() and can be resolved by esp_err_to_name().

How it works

  1. At CMake configure time, err_codes_extract.py scans all ESP-IDF component headers to collect every ESP_ERR_* define.
  2. A test source file is generated that calls esp_err_to_name() for each collected error code and asserts the result matches the expected name.
  3. The app is built and run (e.g., in QEMU or on hardware).

Building and running

cd tools/test_apps/build_system/err_codes_check
idf.py set-target esp32
idf.py build
# Run in QEMU or flash to hardware