Skip to content

Commit 59e9f03

Browse files
committed
espressif: add checking for supported IDF version
Verify if IDF-based HAL version is supported Signed-off-by: Almir Okato <[email protected]>
1 parent 9286264 commit 59e9f03

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

boot/espressif/CMakeLists.txt

+21
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ endif()
1414
add_definitions(-DMCUBOOT_TARGET=${MCUBOOT_TARGET})
1515
add_definitions(-D__ESPRESSIF__=1)
1616

17+
set(EXPECTED_IDF_HAL_VERSION "5.1.4")
18+
1719
if ("${MCUBOOT_TARGET}" STREQUAL "esp32" OR
1820
"${MCUBOOT_TARGET}" STREQUAL "esp32s2" OR
1921
"${MCUBOOT_TARGET}" STREQUAL "esp32s3")
@@ -92,6 +94,25 @@ if (NOT DEFINED ESP_HAL_PATH)
9294
endif()
9395
endif()
9496
endif()
97+
message(STATUS "Defined ESP_HAL_PATH: ${ESP_HAL_PATH}")
98+
99+
# Verify from which IDF version the HAL is based on
100+
set(IDF_VER_HEADER_FILE "${ESP_HAL_PATH}/components/esp_common/include/esp_idf_version.h")
101+
102+
get_version_from_header("ESP_IDF_VERSION_MAJOR" ${IDF_VER_HEADER_FILE} IDF_VERSION_MAJOR)
103+
get_version_from_header("ESP_IDF_VERSION_MINOR" ${IDF_VER_HEADER_FILE} IDF_VERSION_MINOR)
104+
get_version_from_header("ESP_IDF_VERSION_PATCH" ${IDF_VER_HEADER_FILE} IDF_VERSION_PATCH)
105+
106+
set(IDF_VERSION "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}")
107+
108+
if (NOT IDF_VERSION VERSION_EQUAL ${EXPECTED_IDF_HAL_VERSION})
109+
message(FATAL_ERROR
110+
"Unsupported HAL version ${IDF_VERSION}, expected ${EXPECTED_IDF_HAL_VERSION}. \
111+
Verify if the RTOS repository, where you are trying to build from, is up to date, \
112+
or check the installation pointed on ESP_HAL_PATH.")
113+
else ()
114+
message(STATUS "HAL based on ESP-IDF version: ${IDF_VERSION}")
115+
endif()
95116

96117
execute_process(
97118
COMMAND git describe --tags

boot/espressif/tools/utils.cmake

+13
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,16 @@ function(parse_and_set_config_file CONFIG_FILE)
2929
endif()
3030
endforeach()
3131
endfunction()
32+
33+
# Auxiliar function to get IDF version from esp_idf_version.h file
34+
function(get_version_from_header VAR_NAME HEADER_FILE VERSION_OUT)
35+
# Read the header file and extract the value of the specified macro
36+
file(READ "${HEADER_FILE}" CONTENTS)
37+
string(REGEX MATCH "#define ${VAR_NAME}[ ]+([0-9]+)" MATCH "${CONTENTS}")
38+
if(MATCH)
39+
string(REGEX REPLACE "#define ${VAR_NAME}[ ]+([0-9]+)" "\\1" VERSION "${MATCH}")
40+
set(${VERSION_OUT} "${VERSION}" PARENT_SCOPE)
41+
else()
42+
message(FATAL_ERROR "Could not find ${VAR_NAME} in ${HEADER_FILE}")
43+
endif()
44+
endfunction()

ci/espressif_install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ install_imgtool() {
1010

1111
install_idf() {
1212
pushd $HOME
13-
git clone --depth=1 https://github.com/espressif/esp-idf.git --branch release/v5.1
13+
git clone --depth=1 https://github.com/espressif/esp-idf.git --branch v5.1.4
1414
[[ $? -ne 0 ]] && exit 1
1515

1616
$HOME/esp-idf/install.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Added verification for supported IDF-based HAL version.
2+
- Fixed missing macro for XMC flash devices on ESP32-S3

0 commit comments

Comments
 (0)