mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
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
84 lines
3.5 KiB
CMake
84 lines
3.5 KiB
CMake
idf_build_get_property(target IDF_TARGET)
|
|
|
|
if(${target} STREQUAL "linux")
|
|
return() # This component is not supported by the POSIX/Linux simulator
|
|
endif()
|
|
|
|
idf_component_register(SRCS "esp_ota_ops.c"
|
|
INCLUDE_DIRS "include"
|
|
REQUIRES partition_table bootloader_support esp_app_format esp_bootloader_format esp_partition
|
|
PRIV_REQUIRES esptool_py efuse spi_flash)
|
|
|
|
if(CONFIG_SECURE_SIGNED_DATA_PARTITION)
|
|
idf_component_optional_requires(PRIVATE mbedtls)
|
|
endif()
|
|
|
|
idf_define_esp_err_codes(HEADERS include/esp_ota_ops.h)
|
|
|
|
if(NOT BOOTLOADER_BUILD)
|
|
partition_table_get_partition_info(otadata_offset "--partition-type data --partition-subtype ota" "offset")
|
|
partition_table_get_partition_info(otadata_size "--partition-type data --partition-subtype ota" "size")
|
|
|
|
# Add custom target for generating empty otadata partition for flashing
|
|
if(otadata_size AND otadata_offset)
|
|
idf_build_get_property(build_dir BUILD_DIR)
|
|
set(blank_otadata_file ${build_dir}/ota_data_initial.bin)
|
|
|
|
idf_build_get_property(idf_path IDF_PATH)
|
|
idf_build_get_property(python PYTHON)
|
|
|
|
idf_component_get_property(partition_table_dir partition_table COMPONENT_DIR)
|
|
|
|
add_custom_command(OUTPUT ${blank_otadata_file}
|
|
COMMAND ${python} ${partition_table_dir}/gen_empty_partition.py
|
|
${otadata_size} ${blank_otadata_file})
|
|
|
|
add_custom_target(blank_ota_data ALL DEPENDS ${blank_otadata_file})
|
|
add_dependencies(flash blank_ota_data)
|
|
if(CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT)
|
|
add_dependencies(encrypted-flash blank_ota_data)
|
|
endif()
|
|
|
|
set(otatool_py "${python}" "${COMPONENT_DIR}/otatool.py")
|
|
|
|
set(esptool_args --esptool-args before=${CONFIG_ESPTOOLPY_BEFORE} after=${CONFIG_ESPTOOLPY_AFTER})
|
|
set(otatool_args --partition-table-file ${PARTITION_CSV_PATH})
|
|
list(APPEND otatool_args --partition-table-offset ${PARTITION_TABLE_OFFSET})
|
|
|
|
idf_component_get_property(esptool_py_dir esptool_py COMPONENT_DIR)
|
|
|
|
add_custom_target(read-otadata DEPENDS "${PARTITION_CSV_PATH}"
|
|
COMMAND ${CMAKE_COMMAND}
|
|
-D "IDF_PATH=${idf_path}"
|
|
-D "SERIAL_TOOL=${otatool_py}"
|
|
-D "SERIAL_TOOL_ARGS=${esptool_args};${otatool_args};read_otadata"
|
|
-D "WORKING_DIRECTORY=${build_dir}"
|
|
-P ${esptool_py_dir}/run_serial_tool.cmake
|
|
WORKING_DIRECTORY "${build_dir}"
|
|
USES_TERMINAL
|
|
VERBATIM
|
|
)
|
|
add_deprecated_target_alias(read_otadata read-otadata)
|
|
|
|
add_custom_target(erase-otadata DEPENDS "${PARTITION_CSV_PATH}"
|
|
COMMAND ${CMAKE_COMMAND}
|
|
-D "IDF_PATH=${idf_path}"
|
|
-D "SERIAL_TOOL=${otatool_py}"
|
|
-D "SERIAL_TOOL_ARGS=${esptool_args};${otatool_args};erase_otadata"
|
|
-D "WORKING_DIRECTORY=${build_dir}"
|
|
-P ${esptool_py_dir}/run_serial_tool.cmake
|
|
WORKING_DIRECTORY "${build_dir}"
|
|
USES_TERMINAL
|
|
VERBATIM
|
|
)
|
|
add_deprecated_target_alias(erase_otadata erase-otadata)
|
|
|
|
idf_component_get_property(main_args esptool_py FLASH_ARGS)
|
|
idf_component_get_property(sub_args esptool_py FLASH_SUB_ARGS)
|
|
esptool_py_flash_target(otadata-flash "${main_args}" "${sub_args}")
|
|
esptool_py_flash_target_image(otadata-flash otadata "${otadata_offset}" "${blank_otadata_file}")
|
|
|
|
esptool_py_flash_target_image(flash otadata "${otadata_offset}" "${blank_otadata_file}")
|
|
endif()
|
|
endif()
|