Commit 59e9f03b authored by Almir Okato's avatar Almir Okato Committed by almir-okato
Browse files

espressif: add checking for supported IDF version



Verify if IDF-based HAL version is supported

Signed-off-by: default avatarAlmir Okato <almir.okato@espressif.com>
parent 92862645
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ endif()
add_definitions(-DMCUBOOT_TARGET=${MCUBOOT_TARGET})
add_definitions(-D__ESPRESSIF__=1)

set(EXPECTED_IDF_HAL_VERSION "5.1.4")

if ("${MCUBOOT_TARGET}" STREQUAL "esp32" OR
    "${MCUBOOT_TARGET}" STREQUAL "esp32s2" OR
    "${MCUBOOT_TARGET}" STREQUAL "esp32s3")
@@ -92,6 +94,25 @@ if (NOT DEFINED ESP_HAL_PATH)
        endif()
    endif()
endif()
message(STATUS "Defined ESP_HAL_PATH: ${ESP_HAL_PATH}")

# Verify from which IDF version the HAL is based on
set(IDF_VER_HEADER_FILE "${ESP_HAL_PATH}/components/esp_common/include/esp_idf_version.h")

get_version_from_header("ESP_IDF_VERSION_MAJOR" ${IDF_VER_HEADER_FILE} IDF_VERSION_MAJOR)
get_version_from_header("ESP_IDF_VERSION_MINOR" ${IDF_VER_HEADER_FILE} IDF_VERSION_MINOR)
get_version_from_header("ESP_IDF_VERSION_PATCH" ${IDF_VER_HEADER_FILE} IDF_VERSION_PATCH)

set(IDF_VERSION "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}")

if (NOT IDF_VERSION VERSION_EQUAL ${EXPECTED_IDF_HAL_VERSION})
    message(FATAL_ERROR
            "Unsupported HAL version ${IDF_VERSION}, expected ${EXPECTED_IDF_HAL_VERSION}. \
             Verify if the RTOS repository, where you are trying to build from, is up to date, \
             or check the installation pointed on ESP_HAL_PATH.")
else ()
    message(STATUS "HAL based on ESP-IDF version: ${IDF_VERSION}")
endif()

execute_process(
    COMMAND git describe --tags
+13 −0
Original line number Diff line number Diff line
@@ -29,3 +29,16 @@ function(parse_and_set_config_file CONFIG_FILE)
        endif()
    endforeach()
endfunction()

# Auxiliar function to get IDF version from esp_idf_version.h file
function(get_version_from_header VAR_NAME HEADER_FILE VERSION_OUT)
    # Read the header file and extract the value of the specified macro
    file(READ "${HEADER_FILE}" CONTENTS)
    string(REGEX MATCH "#define ${VAR_NAME}[ ]+([0-9]+)" MATCH "${CONTENTS}")
    if(MATCH)
        string(REGEX REPLACE "#define ${VAR_NAME}[ ]+([0-9]+)" "\\1" VERSION "${MATCH}")
        set(${VERSION_OUT} "${VERSION}" PARENT_SCOPE)
    else()
        message(FATAL_ERROR "Could not find ${VAR_NAME} in ${HEADER_FILE}")
    endif()
endfunction()
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ install_imgtool() {

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

    $HOME/esp-idf/install.sh
+2 −0
Original line number Diff line number Diff line
- Added verification for supported IDF-based HAL version.
- Fixed missing macro for XMC flash devices on ESP32-S3