Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

espressif: add checking for supported IDF version #2160

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions boot/espressif/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions boot/espressif/hal/include/esp32s3/sdkconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
#define CONFIG_EFUSE_VIRTUAL_OFFSET 0x250000
#define CONFIG_EFUSE_VIRTUAL_SIZE 0x2000
#define CONFIG_EFUSE_MAX_BLK_LEN 256
#define CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT 1
13 changes: 13 additions & 0 deletions boot/espressif/tools/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion ci/espressif_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions docs/readme-espressif.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Documentation about the MCUboot bootloader design, operation and features can be

The current port is available for use in the following SoCs within the OSes:

| | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 | ESP32-C2 | ESP32-C6 | ESP32-H2 |
| :----: | :-----: | :-----: | :-----: | :-----: | :---------: | :-----: | :-----: |
| Zephyr | Supported | Supported | Supported | Supported | In progress | In progress | In progress |
| NuttX | Supported | Supported | Supported | Supported | In progress | In progress | In progress |
| | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 | ESP32-C2 | ESP32-C6 | ESP32-H2 |
| :----: | :-------: | :-------: | :-------: | :-------: | :---------: | :-------: | :---------: |
| Zephyr | Supported | Supported | Supported | Supported | Supported | Supported | In progress |
| NuttX | Supported | Supported | Supported | Supported | In progress | Supported | Supported |

Notice that any customization in the memory layout from the OS application must be done aware of
the bootloader own memory layout to avoid overlapping. More information on the section
Expand Down Expand Up @@ -94,6 +94,10 @@ Additional configuration related to MCUboot features and slot partitioning may b

1. Compile and generate the BIN:

```bash
cd <MCUBOOT_DIR>/boot/espressif
```

```bash
cmake -DCMAKE_TOOLCHAIN_FILE=tools/toolchain-<TARGET>.cmake -DMCUBOOT_TARGET=<TARGET> -DESP_HAL_PATH=<ESP_HAL_PATH> -DMCUBOOT_FLASH_PORT=<PORT> -B build -GNinja
```
Expand Down
2 changes: 2 additions & 0 deletions docs/release-notes.d/espressif-idf-version-checking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added verification for supported IDF-based HAL version.
- Fixed missing macro for XMC flash devices on ESP32-S3
Loading