diff --git a/components/bootloader/subproject/CMakeLists.txt b/components/bootloader/subproject/CMakeLists.txt index e4881b4bc5..f630bcc46c 100644 --- a/components/bootloader/subproject/CMakeLists.txt +++ b/components/bootloader/subproject/CMakeLists.txt @@ -58,6 +58,7 @@ foreach(component ${proj_components}) endforeach() set(BOOTLOADER_BUILD 1) +set(NON_OS_BUILD 1) include("${IDF_PATH}/tools/cmake/project.cmake") set(common_req log esp_rom esp_common esp_hw_support newlib) idf_build_set_property(EXTRA_COMPONENT_EXCLUDE_DIRS "${EXTRA_COMPONENT_EXCLUDE_DIRS}") @@ -66,6 +67,7 @@ idf_build_set_property(__OUTPUT_SDKCONFIG 0) project(bootloader) idf_build_set_property(COMPILE_DEFINITIONS "BOOTLOADER_BUILD=1" APPEND) +idf_build_set_property(COMPILE_DEFINITIONS "NON_OS_BUILD=1" APPEND) idf_build_set_property(COMPILE_OPTIONS "-fno-stack-protector" APPEND) idf_component_get_property(main_args esptool_py FLASH_ARGS) @@ -207,7 +209,7 @@ elseif(CONFIG_SECURE_BOOTLOADER_REFLASHABLE) COMMAND ${CMAKE_COMMAND} -E echo "* After first boot, only re-flashes of this kind (with same key) will be accepted." COMMAND ${CMAKE_COMMAND} -E echo - "* Not recommended to re-use the same secure boot keyfile on multiple production devices." + "* Not recommended to reuse the same secure boot keyfile on multiple production devices." DEPENDS gen_secure_bootloader_key gen_bootloader_digest_bin VERBATIM) elseif( diff --git a/components/efuse/CMakeLists.txt b/components/efuse/CMakeLists.txt index e0f57b1d34..8b5d587213 100644 --- a/components/efuse/CMakeLists.txt +++ b/components/efuse/CMakeLists.txt @@ -1,4 +1,5 @@ idf_build_get_property(target IDF_TARGET) +idf_build_get_property(non_os_build NON_OS_BUILD) if(CONFIG_EFUSE_VIRTUAL) message(STATUS "Efuse virtual mode is enabled. If Secure boot or Flash encryption is on" @@ -28,7 +29,7 @@ list(APPEND srcs "src/esp_efuse_api.c" "src/esp_efuse_utility.c" "src/efuse_controller/keys/${type}/esp_efuse_api_key.c") -if(BOOTLOADER_BUILD) +if(non_os_build) idf_component_register(SRCS "${srcs}" PRIV_REQUIRES bootloader_support soc spi_flash INCLUDE_DIRS "${include_dirs}" diff --git a/components/efuse/src/esp_efuse_api.c b/components/efuse/src/esp_efuse_api.c index 64059f72a1..36c555435c 100644 --- a/components/efuse/src/esp_efuse_api.c +++ b/components/efuse/src/esp_efuse_api.c @@ -13,7 +13,7 @@ const static char *TAG = "efuse"; -#if defined(BOOTLOADER_BUILD) +#ifdef NON_OS_BUILD #define EFUSE_LOCK_ACQUIRE_RECURSIVE() #define EFUSE_LOCK_RELEASE_RECURSIVE() #else @@ -39,11 +39,11 @@ esp_err_t esp_efuse_read_field_blob(const esp_efuse_desc_t* field[], void* dst, do { memset((uint8_t *)dst, 0, esp_efuse_utility_get_number_of_items(dst_size_bits, 8)); err = esp_efuse_utility_process(field, dst, dst_size_bits, esp_efuse_utility_fill_buff); -#ifndef BOOTLOADER_BUILD +#ifndef NON_OS_BUILD if (err == ESP_ERR_DAMAGED_READING) { vTaskDelay(1); } -#endif // BOOTLOADER_BUILD +#endif // NON_OS_BUILD } while (err == ESP_ERR_DAMAGED_READING); } return err; @@ -67,11 +67,11 @@ esp_err_t esp_efuse_read_field_cnt(const esp_efuse_desc_t* field[], size_t* out_ do { *out_cnt = 0; err = esp_efuse_utility_process(field, out_cnt, 0, esp_efuse_utility_count_once); -#ifndef BOOTLOADER_BUILD +#ifndef NON_OS_BUILD if (err == ESP_ERR_DAMAGED_READING) { vTaskDelay(1); } -#endif // BOOTLOADER_BUILD +#endif // NON_OS_BUILD } while (err == ESP_ERR_DAMAGED_READING); } return err; diff --git a/components/esp_hw_support/CMakeLists.txt b/components/esp_hw_support/CMakeLists.txt index 52f0aa03a8..1d3585ac91 100644 --- a/components/esp_hw_support/CMakeLists.txt +++ b/components/esp_hw_support/CMakeLists.txt @@ -1,4 +1,5 @@ idf_build_get_property(target IDF_TARGET) +idf_build_get_property(non_os_build NON_OS_BUILD) # On Linux, we only support a few features, hence this simple component registration if(${target} STREQUAL "linux") @@ -22,7 +23,7 @@ if(CONFIG_RTC_CLK_SRC_INT_RC32K) endif() set(srcs "cpu.c" "port/${IDF_TARGET}/esp_cpu_intr.c" "esp_memory_utils.c" "port/${IDF_TARGET}/cpu_region_protect.c") -if(NOT BOOTLOADER_BUILD) +if(NOT non_os_build) list(APPEND srcs "esp_clk.c" "clk_ctrl_os.c" "hw_random.c" @@ -167,7 +168,7 @@ if(CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND OR CONFIG_PM_SLP_DISABLE_GPIO) target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_sleep_gpio_include") endif() -if(NOT BOOTLOADER_BUILD) +if(NOT non_os_build) if(CONFIG_SPIRAM) idf_component_optional_requires(PRIVATE esp_psram) endif() diff --git a/components/esp_security/CMakeLists.txt b/components/esp_security/CMakeLists.txt index d9c054b15e..da2fb0125b 100644 --- a/components/esp_security/CMakeLists.txt +++ b/components/esp_security/CMakeLists.txt @@ -1,4 +1,5 @@ idf_build_get_property(target IDF_TARGET) +idf_build_get_property(non_os_build NON_OS_BUILD) if(${target} STREQUAL "linux") return() # This component is not supported by the POSIX/Linux simulator @@ -8,7 +9,7 @@ set(srcs "") set(priv_requires "") set(priv_includes "") -if(NOT BOOTLOADER_BUILD) +if(NOT non_os_build) list(APPEND srcs "src/init.c") list(APPEND priv_includes "src/${IDF_TARGET}") @@ -37,6 +38,6 @@ idf_component_register(SRCS ${srcs} PRIV_INCLUDE_DIRS ${priv_includes} PRIV_REQUIRES ${priv_requires}) -if(NOT BOOTLOADER_BUILD) +if(NOT non_os_build) target_link_libraries(${COMPONENT_LIB} PRIVATE "-u esp_security_init_include_impl") endif() diff --git a/components/esptool_py/project_include.cmake b/components/esptool_py/project_include.cmake index 9f051b2359..de0efe407c 100644 --- a/components/esptool_py/project_include.cmake +++ b/components/esptool_py/project_include.cmake @@ -5,6 +5,7 @@ idf_build_get_property(target IDF_TARGET) idf_build_get_property(python PYTHON) idf_build_get_property(idf_path IDF_PATH) +idf_build_get_property(non_os_build NON_OS_BUILD) set(chip_model ${target}) @@ -151,7 +152,7 @@ elseif(CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME OR CONFIG_SECURE_SIGNED_APPS_ECDSA_V set(secure_boot_version "2") endif() -if(NOT BOOTLOADER_BUILD AND CONFIG_SECURE_SIGNED_APPS) +if(NOT non_os_build AND CONFIG_SECURE_SIGNED_APPS) if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES) # for locally signed secure boot image, add a signing step to get from unsigned app to signed app get_filename_component(secure_boot_signing_key "${CONFIG_SECURE_BOOT_SIGNING_KEY}" @@ -526,7 +527,7 @@ function(esptool_py_custom_target target_name flasher_filename dependencies) endif() endfunction() -if(NOT BOOTLOADER_BUILD) +if(NOT non_os_build) set(flash_deps "") if(CONFIG_APP_BUILD_TYPE_APP_2NDBOOT) diff --git a/components/freertos/CMakeLists.txt b/components/freertos/CMakeLists.txt index 5776b7f378..87798ab788 100644 --- a/components/freertos/CMakeLists.txt +++ b/components/freertos/CMakeLists.txt @@ -20,7 +20,9 @@ # - Files common across all kernel implementations and all ports # Bootloader builds only needs FreeRTOS for config, not for anything else -if(BOOTLOADER_BUILD) +idf_build_get_property(non_os_build NON_OS_BUILD) + +if(non_os_build) idf_component_register() return() endif() diff --git a/components/log/CMakeLists.txt b/components/log/CMakeLists.txt index e162bfb853..0743b16e72 100644 --- a/components/log/CMakeLists.txt +++ b/components/log/CMakeLists.txt @@ -1,6 +1,7 @@ idf_build_get_property(target IDF_TARGET) +idf_build_get_property(non_os_build NON_OS_BUILD) -if(BOOTLOADER_BUILD) +if(non_os_build) set(system_target "noos") else() if(${target} STREQUAL "linux") @@ -15,7 +16,7 @@ set(srcs "src/${system_target}/log_timestamp.c" "src/${system_target}/log_lock.c") set(priv_requires "") -if(NOT BOOTLOADER_BUILD) +if(NOT non_os_build) list(APPEND priv_requires soc hal esp_hw_support) list(APPEND srcs "src/os/log_write.c") diff --git a/components/log/include/esp_log.h b/components/log/include/esp_log.h index 8d11d9ca94..e2cb068f43 100644 --- a/components/log/include/esp_log.h +++ b/components/log/include/esp_log.h @@ -101,7 +101,7 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format, esp_rom_printf(LOG_FORMAT(log_tag_letter, format), esp_log_timestamp(), tag, ##__VA_ARGS__); \ }} while(0) -#ifndef BOOTLOADER_BUILD +#ifndef NON_OS_BUILD #if defined(__cplusplus) && (__cplusplus > 201703L) #define ESP_LOGE( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_ERROR, tag, format __VA_OPT__(,) __VA_ARGS__) #define ESP_LOGW( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_WARN, tag, format __VA_OPT__(,) __VA_ARGS__) @@ -147,7 +147,7 @@ void esp_log_writev(esp_log_level_t level, const char* tag, const char* format, /// macro to output logs at ``ESP_LOG_VERBOSE`` level. @see ``ESP_LOGE`` #define ESP_LOGV( tag, format, ... ) ESP_EARLY_LOGV(tag, format, ##__VA_ARGS__) #endif // !(defined(__cplusplus) && (__cplusplus > 201703L)) -#endif // BOOTLOADER_BUILD +#endif // !NON_OS_BUILD /** runtime macro to output logs at a specified level. * diff --git a/components/log/include/esp_log_buffer.h b/components/log/include/esp_log_buffer.h index d5726f5e2b..5453061403 100644 --- a/components/log/include/esp_log_buffer.h +++ b/components/log/include/esp_log_buffer.h @@ -13,7 +13,7 @@ extern "C" { #endif -#if !BOOTLOADER_BUILD || __DOXYGEN__ +#if !NON_OS_BUILD || __DOXYGEN__ /** * @brief Logs a buffer of hexadecimal bytes at the specified log level. @@ -173,7 +173,7 @@ static inline void esp_log_buffer_char(const char *tag, const void *buffer, uint } /** @endcond */ -#endif // !BOOTLOADER_BUILD || __DOXYGEN__ +#endif // !NON_OS_BUILD || __DOXYGEN__ #ifdef __cplusplus } diff --git a/components/log/include/esp_log_level.h b/components/log/include/esp_log_level.h index 80aeaa5ac1..1f10660b99 100644 --- a/components/log/include/esp_log_level.h +++ b/components/log/include/esp_log_level.h @@ -37,12 +37,12 @@ typedef enum { #endif // !BOOTLOADER_BUILD #endif // LOG_LOCAL_LEVEL -#if BOOTLOADER_BUILD +#ifdef NON_OS_BUILD #define _ESP_LOG_ENABLED(log_level) (LOG_LOCAL_LEVEL >= (log_level)) #define _ESP_LOG_EARLY_ENABLED(log_level) _ESP_LOG_ENABLED(log_level) -#else // !BOOTLOADER_BUILD +#else // !NON_OS_BUILD #if CONFIG_LOG_MASTER_LEVEL #define _ESP_LOG_ENABLED(log_level) (esp_log_get_level_master() >= (log_level) && LOG_LOCAL_LEVEL >= (log_level)) @@ -54,7 +54,7 @@ typedef enum { currently configured min log level are higher than the log level */ #define _ESP_LOG_EARLY_ENABLED(log_level) (LOG_LOCAL_LEVEL >= (log_level) && esp_log_get_default_level() >= (log_level)) -#endif // !BOOTLOADER_BUILD +#endif // !NON_OS_BUILD /** @endcond */ diff --git a/components/log/src/log_timestamp_common.c b/components/log/src/log_timestamp_common.c index ba9521908f..7905899da5 100644 --- a/components/log/src/log_timestamp_common.c +++ b/components/log/src/log_timestamp_common.c @@ -12,7 +12,7 @@ #include "esp_private/log_timestamp.h" #include "sdkconfig.h" -#if !BOOTLOADER_BUILD +#ifndef NON_OS_BUILD #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -60,7 +60,7 @@ char *esp_log_system_timestamp(void) } return buffer; } -#endif // !BOOTLOADER_BUILD +#endif // !NON_OS_BUILD uint64_t esp_log_timestamp64(bool critical) { diff --git a/components/newlib/CMakeLists.txt b/components/newlib/CMakeLists.txt index 0d05270881..c0af7ac692 100644 --- a/components/newlib/CMakeLists.txt +++ b/components/newlib/CMakeLists.txt @@ -1,4 +1,5 @@ idf_build_get_property(target IDF_TARGET) +idf_build_get_property(non_os_build NON_OS_BUILD) if(${target} STREQUAL "linux") return() # This component is not supported by the POSIX/Linux simulator @@ -6,7 +7,7 @@ endif() set(include_dirs "platform_include") -if(BOOTLOADER_BUILD) +if(non_os_build) # Bootloader builds need the platform_include directory (for assert.h), but nothing else idf_component_register(INCLUDE_DIRS platform_include) return() diff --git a/components/partition_table/CMakeLists.txt b/components/partition_table/CMakeLists.txt index d5844374b0..26b8229bc7 100644 --- a/components/partition_table/CMakeLists.txt +++ b/components/partition_table/CMakeLists.txt @@ -1,4 +1,6 @@ idf_build_get_property(target IDF_TARGET) +idf_build_get_property(non_os_build NON_OS_BUILD) + set(priv_req) if(NOT ${target} STREQUAL "linux") list(APPEND priv_req esptool_py) @@ -6,7 +8,7 @@ endif() idf_component_register(PRIV_REQUIRES ${priv_req}) -if(BOOTLOADER_BUILD) +if(non_os_build) return() endif() diff --git a/components/partition_table/project_include.cmake b/components/partition_table/project_include.cmake index 7778af1155..ddd6230db3 100644 --- a/components/partition_table/project_include.cmake +++ b/components/partition_table/project_include.cmake @@ -4,8 +4,9 @@ set(PARTITION_TABLE_CHECK_SIZES_TOOL_PATH "${CMAKE_CURRENT_LIST_DIR}/check_sizes idf_build_get_property(build_dir BUILD_DIR) idf_build_set_property(PARTITION_TABLE_BIN_PATH "${build_dir}/partition_table/partition-table.bin") +idf_build_get_property(non_os_build NON_OS_BUILD) -if(NOT BOOTLOADER_BUILD) +if(NOT non_os_build) # Set PARTITION_CSV_PATH to the configured partition CSV file # absolute path if(CONFIG_PARTITION_TABLE_CUSTOM) diff --git a/components/spi_flash/CMakeLists.txt b/components/spi_flash/CMakeLists.txt index b71f6e71cf..5e85a5c94f 100644 --- a/components/spi_flash/CMakeLists.txt +++ b/components/spi_flash/CMakeLists.txt @@ -1,4 +1,6 @@ idf_build_get_property(target IDF_TARGET) +idf_build_get_property(non_os_build NON_OS_BUILD) + if(${target} STREQUAL "linux") idf_component_register(SRCS "linux/spi_flash_linux.c" "linux/cache_utils.c" @@ -8,7 +10,7 @@ if(${target} STREQUAL "linux") return() endif() -if(BOOTLOADER_BUILD OR CONFIG_APP_BUILD_TYPE_PURE_RAM_APP) +if(non_os_build OR CONFIG_APP_BUILD_TYPE_PURE_RAM_APP) set(srcs "spi_flash_wrap.c") set(priv_requires bootloader_support soc) else() @@ -70,7 +72,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU") " -fno-inline-small-functions -fno-inline-functions-called-once") endif() -if(NOT BOOTLOADER_BUILD AND NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP) +if(NOT non_os_build AND NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP) if(CONFIG_SPIRAM) # [refactor-todo]: requires "esp_psram" for few MMU usages in `flash_mmap.c` # will be replaced with MMU requirements diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index c9414c437d..b3d72516e5 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -524,6 +524,7 @@ macro(idf_build_process target) cmake_parse_arguments(_ "${options}" "${single_value}" "${multi_value}" ${ARGN}) idf_build_set_property(BOOTLOADER_BUILD "${BOOTLOADER_BUILD}") + idf_build_set_property(NON_OS_BUILD "${NON_OS_BUILD}") idf_build_set_property(IDF_TOOLCHAIN "${IDF_TOOLCHAIN}")