@@ -17,7 +17,7 @@ set(MCUBOOT_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
1717set (ESPRESSIF_PORT_DIR ${MCUBOOT_ROOT_DIR} /boot/espressif)
1818set (APP_NAME mcuboot_${MCUBOOT_TARGET} )
1919set (APP_EXECUTABLE ${APP_NAME} .elf)
20- set (EXPECTED_IDF_HAL_VERSION "5.1.6 " )
20+ set (EXPECTED_IDF_HAL_VERSION "6.0.0 " )
2121
2222project (mcuboot_${MCUBOOT_TARGET} )
2323
@@ -34,17 +34,21 @@ if("${MCUBOOT_TARGET}" STREQUAL "esp32" OR
3434 "${MCUBOOT_TARGET} " STREQUAL "esp32s2" OR
3535 "${MCUBOOT_TARGET} " STREQUAL "esp32s3" )
3636 set (MCUBOOT_ARCH "xtensa" )
37- elseif ("${MCUBOOT_TARGET} " STREQUAL "esp32c3" OR
37+ elseif ("${MCUBOOT_TARGET} " STREQUAL "esp32c2" OR
38+ "${MCUBOOT_TARGET} " STREQUAL "esp32c3" OR
3839 "${MCUBOOT_TARGET} " STREQUAL "esp32c6" OR
39- "${MCUBOOT_TARGET} " STREQUAL "esp32c2" OR
4040 "${MCUBOOT_TARGET} " STREQUAL "esp32h2" )
4141 set (MCUBOOT_ARCH "riscv" )
4242endif ()
4343
44+ if ("${MCUBOOT_ARCH} " STREQUAL "riscv" )
45+ add_definitions (-D__riscv )
46+ endif ()
47+
4448# Set MCUboot Espressif Port configuration file
4549if (NOT DEFINED MCUBOOT_CONFIG_FILE)
4650 set (MCUBOOT_CONFIG_FILE "${ESPRESSIF_PORT_DIR} /port/${MCUBOOT_TARGET} /bootloader.conf" )
47- message ("MCUBOOT_CONFIG_FILE: ${MCUBOOT_CONFIG_FILE} " )
51+ message (STATUS "MCUBOOT_CONFIG_FILE: ${MCUBOOT_CONFIG_FILE} " )
4852endif ()
4953
5054string (REPLACE " " ";" MCUBOOT_CONFIG_FILE_LIST "${MCUBOOT_CONFIG_FILE} " )
@@ -58,7 +62,7 @@ endforeach()
5862# Fetch and set toolchain
5963if (NOT DEFINED CMAKE_TOOLCHAIN_FILE )
6064 if (DEFINED TOOLCHAIN_BIN_DIR)
61- message ("CMAKE_TOOLCHAIN_FILE not defined, searching for toolchain compiler in TOOLCHAIN_BIN_DIR: ${TOOLCHAIN_BIN_DIR} " )
65+ message (STATUS "CMAKE_TOOLCHAIN_FILE not defined, searching for toolchain compiler in TOOLCHAIN_BIN_DIR: ${TOOLCHAIN_BIN_DIR} " )
6266 set (CMAKE_SYSTEM_NAME Generic)
6367
6468 file (GLOB C_COMPILER_BIN "${TOOLCHAIN_BIN_DIR} /*${MCUBOOT_ARCH} *elf-gcc" )
@@ -67,26 +71,26 @@ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
6771 endif ()
6872 set (CMAKE_C_COMPILER ${C_COMPILER_BIN} )
6973 set (CMAKE_ASM_COMPILER ${C_COMPILER_BIN} )
70- message ("C compiler found: ${CMAKE_C_COMPILER} " )
74+ message (STATUS "C compiler found: ${CMAKE_C_COMPILER} " )
7175
7276 file (GLOB CXX_COMPILER_BIN "${TOOLCHAIN_BIN_DIR} /*${MCUBOOT_ARCH} *elf-g++" )
7377 if (NOT CXX_COMPILER_BIN)
7478 message (FATAL_ERROR "No C++ compiler found. Please ensure that TOOLCHAIN_BIN_DIR directory contains a set of C++ compiling tools compatible with the target" )
7579 endif ()
7680 set (CMAKE_CXX_COMPILER ${CXX_COMPILER_BIN} )
77- message ("CXX compiler found: ${CMAKE_CXX_COMPILER} " )
81+ message (STATUS "CXX compiler found: ${CMAKE_CXX_COMPILER} " )
7882 else ()
7983 # Set toolchain file that expect the same toolchain as IDF sets on PATH
8084 set (CMAKE_TOOLCHAIN_FILE ${ESPRESSIF_PORT_DIR} /tools/toolchain-${MCUBOOT_TARGET} .cmake)
81- message ("No user-defined toolchain, setting default toolchain file: ${CMAKE_TOOLCHAIN_FILE} " )
85+ message (STATUS "No user-defined toolchain, setting default toolchain file: ${CMAKE_TOOLCHAIN_FILE} " )
8286 endif ()
8387
8488 # This flag is needed when redefining a different compiler toolchain at this point
8589 # on CMakeLists, the reason is that CMake does a compiler testing prior to building
8690 # that may fail due to cross-compilation
8791 set (CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY" )
8892else ()
89- message ("CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE} " )
93+ message (STATUS "CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE} " )
9094endif ()
9195
9296# Set the minimum revision for each supported chip
@@ -279,6 +283,8 @@ list(APPEND inc_directories
279283 )
280284
281285set(CFLAGS
286+ " -specs=picolibc.specs "
287+ " -nostdlib "
282288 " -Wno-frame-address "
283289 " -Wall "
284290 " -Wextra "
@@ -300,14 +306,14 @@ set(CFLAGS
300306 " -Wno-sign-compare "
301307 " -ggdb "
302308 " -Os "
303- " -D_GNU_SOURCE "
304- " -std=gnu17 "
309+ " -std=gnu23 "
305310 " -Wno-old-style-declaration "
306311 " -Wno-implicit-int "
307312 " -Wno-declaration-after-statement "
308313 )
309314
310315set(LDFLAGS
316+ " -specs=picolibc.specs "
311317 " -nostdlib "
312318 " -Wno-frame-address "
313319 " -Wl,--cref "
@@ -325,12 +331,24 @@ set(LDFLAGS
325331if(" ${MCUBOOT_ARCH} " STREQUAL " xtensa ")
326332 list(APPEND CFLAGS
327333 " -mlongcalls "
334+ " -fno-builtin-memcpy "
335+ " -fno-builtin-memset "
336+ " -fno-builtin-bzero "
328337 )
329338 list(APPEND LDFLAGS
330339 " -mlongcalls "
340+ " -fno-builtin-memcpy "
341+ " -fno-builtin-memset "
342+ " -fno-builtin-bzero "
331343 )
332344endif()
333345
346+ set_source_files_properties(
347+ ${ESPRESSIF_PORT_DIR} /port/serial_adapter.c
348+ PROPERTIES COMPILE_FLAGS
349+ " -Wno-logical-op "
350+ )
351+
334352set(LINKER_SCRIPT_INCLUDES ${ESPRESSIF_PORT_DIR} /port/include/${MCUBOOT_TARGET} )
335353
336354# Set linker script
@@ -438,7 +456,7 @@ add_custom_command(
438456 COMMAND
439457 ${esptool_path}
440458 --chip ${MCUBOOT_TARGET} elf2image --min-rev ${ESP_MIN_REVISION}
441- --flash_mode ${ESP_FLASH_MODE} --flash_freq ${ESP_FLASH_FREQ} --flash_size ${CONFIG_ESP_FLASH_SIZE}
459+ --flash-mode ${ESP_FLASH_MODE} --flash-freq ${ESP_FLASH_FREQ} --flash-size ${CONFIG_ESP_FLASH_SIZE}
442460 -o ${APP_NAME} .bin ${APP_NAME} .elf
443461 )
444462
@@ -462,7 +480,7 @@ add_custom_command(
462480 ${esptool_path}
463481 -p ${FLASH_PORT} -b ${ESP_BAUD_RATE} --before default_reset --after no_reset
464482 --chip ${MCUBOOT_TARGET} write_flash
465- --flash_mode ${ESP_FLASH_MODE} --flash_size ${CONFIG_ESP_FLASH_SIZE}
466- --flash_freq ${ESP_FLASH_FREQ} ${CONFIG_ESP_BOOTLOADER_OFFSET}
483+ --flash-mode ${ESP_FLASH_MODE} --flash-size ${CONFIG_ESP_FLASH_SIZE}
484+ --flash-freq ${ESP_FLASH_FREQ} ${CONFIG_ESP_BOOTLOADER_OFFSET}
467485 ${APP_NAME} .bin
468486 )
0 commit comments