diff --git a/CMakeLists.txt b/CMakeLists.txt index 190d4c5ffb..1cd2e791ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,6 +169,10 @@ if(CONFIG_COMPILER_DUMP_RTL_FILES) list(APPEND compile_options "-fdump-rtl-expand") endif() +if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 15.0) + list(APPEND c_compile_options "-fzero-init-padding-bits=all" "-fno-malloc-dce") +endif() + __generate_prefix_map(prefix_map_compile_options) list(APPEND compile_options ${prefix_map_compile_options}) @@ -188,6 +192,15 @@ if(CONFIG_COMPILER_DISABLE_GCC14_WARNINGS) list(APPEND compile_options "-Wno-calloc-transposed-args") endif() +if(CONFIG_COMPILER_DISABLE_GCC15_WARNINGS) + list(APPEND c_compile_options "-Wno-unterminated-string-initialization") + list(APPEND c_compile_options "-Wno-header-guard") + list(APPEND cxx_compile_options "-Wno-self-move") + list(APPEND cxx_compile_options "-Wno-template-body") + list(APPEND cxx_compile_options "-Wno-dangling-reference") + list(APPEND cxx_compile_options "-Wno-defaulted-function-deleted") +endif() + if(CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS) if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang") idf_build_replace_option_from_property(COMPILE_OPTIONS "-Werror" "-Werror=all") diff --git a/Kconfig b/Kconfig index 329d7d8e99..dd690c14b3 100644 --- a/Kconfig +++ b/Kconfig @@ -610,6 +610,13 @@ mainmenu "Espressif IoT Development Framework Configuration" Enable this option if use GCC 14 or newer, and want to disable warnings which don't appear with GCC 13. + config COMPILER_DISABLE_GCC15_WARNINGS + bool "Disable new warnings introduced in GCC 15" + default "n" + help + Enable this option if use GCC 15 or newer, and want to disable warnings which don't appear with + GCC 14. + config COMPILER_DUMP_RTL_FILES bool "Dump RTL files during compilation" help diff --git a/components/bootloader_support/src/bootloader_init.c b/components/bootloader_support/src/bootloader_init.c index 0e8dcd7621..9488bb60e1 100644 --- a/components/bootloader_support/src/bootloader_init.c +++ b/components/bootloader_support/src/bootloader_init.c @@ -29,7 +29,7 @@ esp_image_header_t WORD_ALIGNED_ATTR bootloader_image_hdr; void bootloader_clear_bss_section(void) { - memset(&_bss_start, 0, (&_bss_end - &_bss_start) * sizeof(_bss_start)); + memset(&_bss_start, 0, (uintptr_t)&_bss_end - (uintptr_t)&_bss_start); } esp_err_t bootloader_read_bootloader_header(void) diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index 9b3a577afa..806c0dbdf2 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -1022,3 +1022,14 @@ if(NOT CMAKE_BUILD_EARLY_EXPANSION) "${CMAKE_CURRENT_LIST_DIR}/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c" PROPERTIES COMPILE_FLAGS "${jump_table_opts}") endif() + +if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 15.0) + if(CONFIG_BT_BLUEDROID_ENABLED) + set_source_files_properties("host/bluedroid/device/controller.c" + PROPERTIES COMPILE_FLAGS "-Wno-unterminated-string-initialization") + endif() + if(CONFIG_BT_NIMBLE_ENABLED AND CONFIG_BT_NIMBLE_MESH) + set_source_files_properties("host/nimble/nimble/nimble/host/mesh/src/prov.c" + PROPERTIES COMPILE_FLAGS "-Wno-unterminated-string-initialization") + endif() +endif() diff --git a/components/bt/host/bluedroid/btc/profile/std/a2dp/bta_av_co.c b/components/bt/host/bluedroid/btc/profile/std/a2dp/bta_av_co.c index f2668e2e04..e237c8363c 100644 --- a/components/bt/host/bluedroid/btc/profile/std/a2dp/bta_av_co.c +++ b/components/bt/host/bluedroid/btc/profile/std/a2dp/bta_av_co.c @@ -22,6 +22,7 @@ * BTC. * ******************************************************************************/ +#include "esp_attr.h" #include "string.h" #include "common/bt_target.h" #include "stack/a2d_api.h" @@ -66,7 +67,7 @@ #define BTA_AV_CO_SBC_MAX_BITPOOL 53 /* SCMS-T protect info */ -const UINT8 bta_av_co_cp_scmst[BTA_AV_CP_INFO_LEN] = "\x02\x02\x00"; +const UINT8 bta_av_co_cp_scmst[BTA_AV_CP_INFO_LEN] = { 2, 2, 0 }; /* SBC SRC codec capabilities */ const tA2D_SBC_CIE bta_av_co_sbc_caps = { diff --git a/components/cxx/test_apps/.build-test-rules.yml b/components/cxx/test_apps/.build-test-rules.yml index 3b8ff55552..787715d396 100644 --- a/components/cxx/test_apps/.build-test-rules.yml +++ b/components/cxx/test_apps/.build-test-rules.yml @@ -2,6 +2,6 @@ components/cxx/test_apps: enable: - - if: IDF_TARGET in ["esp32", "esp32c3"] + - if: IDF_TARGET in ["esp32", "esp32c3", "esp32c61", "esp32p4"] temporary: true reason: the other targets are not tested yet diff --git a/components/cxx/test_apps/exception/README.md b/components/cxx/test_apps/exception/README.md index 1fb88efd15..c68d6f39e8 100644 --- a/components/cxx/test_apps/exception/README.md +++ b/components/cxx/test_apps/exception/README.md @@ -1,2 +1,2 @@ -| Supported Targets | ESP32 | ESP32-C3 | -| ----------------- | ----- | -------- | +| Supported Targets | ESP32 | ESP32-C3 | ESP32-C61 | ESP32-P4 | +| ----------------- | ----- | -------- | --------- | -------- | diff --git a/components/cxx/test_apps/exception/main/test_exception.cpp b/components/cxx/test_apps/exception/main/test_exception.cpp index d0ef7166c7..d33a4fcca8 100644 --- a/components/cxx/test_apps/exception/main/test_exception.cpp +++ b/components/cxx/test_apps/exception/main/test_exception.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,12 +13,10 @@ - 88 bytes are allocated by pthread_setspecific() to init internal lock - some more memory... */ -#if CONFIG_IDF_TARGET_ESP32 -#define LEAKS (300) -#elif CONFIG_IDF_TARGET_ESP32S2 -#define LEAKS (800) -#elif CONFIG_IDF_TARGET_ESP32C3 -#define LEAKS (700) +#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C61 || CONFIG_IDF_TARGET_ESP32P4 +#define LEAKS (128) /* real: 72 */ +#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3 +#define LEAKS (448) /* real: 396 */ #else #error "unknown target in CXX tests, can't set leaks threshold" #endif diff --git a/components/cxx/test_apps/exception/pytest_cxx_exception.py b/components/cxx/test_apps/exception/pytest_cxx_exception.py index e89f3c561a..209db3f3d0 100644 --- a/components/cxx/test_apps/exception/pytest_cxx_exception.py +++ b/components/cxx/test_apps/exception/pytest_cxx_exception.py @@ -6,6 +6,6 @@ from pytest_embedded_idf.utils import idf_parametrize @pytest.mark.generic -@idf_parametrize('target', ['esp32', 'esp32c3'], indirect=['target']) +@idf_parametrize('target', ['esp32', 'esp32c3', 'esp32c61', 'esp32p4'], indirect=['target']) def test_cxx_exception(dut: Dut) -> None: dut.run_all_single_board_cases() diff --git a/components/cxx/test_apps/exception_no_except/README.md b/components/cxx/test_apps/exception_no_except/README.md index 1fb88efd15..c68d6f39e8 100644 --- a/components/cxx/test_apps/exception_no_except/README.md +++ b/components/cxx/test_apps/exception_no_except/README.md @@ -1,2 +1,2 @@ -| Supported Targets | ESP32 | ESP32-C3 | -| ----------------- | ----- | -------- | +| Supported Targets | ESP32 | ESP32-C3 | ESP32-C61 | ESP32-P4 | +| ----------------- | ----- | -------- | --------- | -------- | diff --git a/components/cxx/test_apps/exception_no_except/pytest_cxx_exception_no_except.py b/components/cxx/test_apps/exception_no_except/pytest_cxx_exception_no_except.py index ba8849827b..f80b4ab766 100644 --- a/components/cxx/test_apps/exception_no_except/pytest_cxx_exception_no_except.py +++ b/components/cxx/test_apps/exception_no_except/pytest_cxx_exception_no_except.py @@ -6,7 +6,7 @@ from pytest_embedded_idf.utils import idf_parametrize @pytest.mark.generic -@idf_parametrize('target', ['esp32', 'esp32c3'], indirect=['target']) +@idf_parametrize('target', ['esp32', 'esp32c3', 'esp32c61', 'esp32p4'], indirect=['target']) def test_cxx_noexcept_out_of_range(dut: Dut) -> None: dut.expect_exact('Press ENTER to see the list of tests') dut.write('1') @@ -15,7 +15,7 @@ def test_cxx_noexcept_out_of_range(dut: Dut) -> None: @pytest.mark.generic -@idf_parametrize('target', ['esp32', 'esp32c3'], indirect=['target']) +@idf_parametrize('target', ['esp32', 'esp32c3', 'esp32c61', 'esp32p4'], indirect=['target']) def test_cxx_noexcept_bad_alloc(dut: Dut) -> None: dut.expect_exact('Press ENTER to see the list of tests') dut.write('2') diff --git a/components/cxx/test_apps/general/README.md b/components/cxx/test_apps/general/README.md index 1fb88efd15..c68d6f39e8 100644 --- a/components/cxx/test_apps/general/README.md +++ b/components/cxx/test_apps/general/README.md @@ -1,2 +1,2 @@ -| Supported Targets | ESP32 | ESP32-C3 | -| ----------------- | ----- | -------- | +| Supported Targets | ESP32 | ESP32-C3 | ESP32-C61 | ESP32-P4 | +| ----------------- | ----- | -------- | --------- | -------- | diff --git a/components/cxx/test_apps/general/main/test_cxx_general.cpp b/components/cxx/test_apps/general/main/test_cxx_general.cpp index 9d906bfe40..84ffc8447e 100644 --- a/components/cxx/test_apps/general/main/test_cxx_general.cpp +++ b/components/cxx/test_apps/general/main/test_cxx_general.cpp @@ -108,18 +108,16 @@ TEST_CASE("static initialization guards work as expected", "[misc]") TEST_ASSERT_NOT_NULL(s_slow_init_sem); int task_count = 0; // four tasks competing for static initialization of one object - task_count += start_slow_init_task<1>(0, PRO_CPU_NUM); -#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2 - task_count += start_slow_init_task<1>(1, APP_CPU_NUM); -#endif + for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) { + task_count += start_slow_init_task<1>(i, i); + } task_count += start_slow_init_task<1>(2, PRO_CPU_NUM); task_count += start_slow_init_task<1>(3, tskNO_AFFINITY); // four tasks competing for static initialization of another object - task_count += start_slow_init_task<2>(0, PRO_CPU_NUM); -#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2 - task_count += start_slow_init_task<2>(1, APP_CPU_NUM); -#endif + for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) { + task_count += start_slow_init_task<2>(i, i); + } task_count += start_slow_init_task<2>(2, PRO_CPU_NUM); task_count += start_slow_init_task<2>(3, tskNO_AFFINITY); diff --git a/components/cxx/test_apps/general/pytest_cxx_general.py b/components/cxx/test_apps/general/pytest_cxx_general.py index f480ed673c..e49b4ea7f9 100644 --- a/components/cxx/test_apps/general/pytest_cxx_general.py +++ b/components/cxx/test_apps/general/pytest_cxx_general.py @@ -9,21 +9,21 @@ configurations = ['noexcept', 'exceptions_rtti'] @pytest.mark.generic @pytest.mark.parametrize('config', configurations, indirect=True) -@idf_parametrize('target', ['esp32', 'esp32c3'], indirect=['target']) +@idf_parametrize('target', ['esp32', 'esp32c3', 'esp32c61', 'esp32p4'], indirect=['target']) def test_cxx_static_init_non_pod(dut: Dut) -> None: dut.run_all_single_board_cases(name=['can use static initializers for non-POD types']) @pytest.mark.generic @pytest.mark.parametrize('config', configurations, indirect=True) -@idf_parametrize('target', ['esp32', 'esp32c3'], indirect=['target']) +@idf_parametrize('target', ['esp32', 'esp32c3', 'esp32c61', 'esp32p4'], indirect=['target']) def test_cxx_misc(dut: Dut) -> None: dut.run_all_single_board_cases(group='misc') @pytest.mark.generic @pytest.mark.parametrize('config', configurations, indirect=True) -@idf_parametrize('target', ['esp32', 'esp32c3'], indirect=['target']) +@idf_parametrize('target', ['esp32', 'esp32c3', 'esp32c61', 'esp32p4'], indirect=['target']) def test_cxx_stack_smash(dut: Dut) -> None: dut.expect_exact('Press ENTER to see the list of tests') dut.write('"stack smashing protection CXX"') diff --git a/components/cxx/test_apps/rtti/README.md b/components/cxx/test_apps/rtti/README.md index 1fb88efd15..c68d6f39e8 100644 --- a/components/cxx/test_apps/rtti/README.md +++ b/components/cxx/test_apps/rtti/README.md @@ -1,2 +1,2 @@ -| Supported Targets | ESP32 | ESP32-C3 | -| ----------------- | ----- | -------- | +| Supported Targets | ESP32 | ESP32-C3 | ESP32-C61 | ESP32-P4 | +| ----------------- | ----- | -------- | --------- | -------- | diff --git a/components/cxx/test_apps/rtti/main/test_rtti.cpp b/components/cxx/test_apps/rtti/main/test_rtti.cpp index 71d0c3b949..8428049e1e 100644 --- a/components/cxx/test_apps/rtti/main/test_rtti.cpp +++ b/components/cxx/test_apps/rtti/main/test_rtti.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -14,12 +14,10 @@ - 88 bytes are allocated by pthread_setspecific() to init internal lock - some more memory... */ -#if CONFIG_IDF_TARGET_ESP32 -#define LEAKS (300) -#elif CONFIG_IDF_TARGET_ESP32S2 -#define LEAKS (800) -#elif CONFIG_IDF_TARGET_ESP32C3 -#define LEAKS (700) +#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C61 || CONFIG_IDF_TARGET_ESP32P4 +#define LEAKS (128) /* real: 72 */ +#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3 +#define LEAKS (448) /* real: 396 */ #else #error "unknown target in CXX tests, can't set leaks threshold" #endif diff --git a/components/cxx/test_apps/rtti/pytest_cxx_rtti.py b/components/cxx/test_apps/rtti/pytest_cxx_rtti.py index 40ec38cbd0..c1328f8759 100644 --- a/components/cxx/test_apps/rtti/pytest_cxx_rtti.py +++ b/components/cxx/test_apps/rtti/pytest_cxx_rtti.py @@ -6,6 +6,6 @@ from pytest_embedded_idf.utils import idf_parametrize @pytest.mark.generic -@idf_parametrize('target', ['esp32', 'esp32c3'], indirect=['target']) +@idf_parametrize('target', ['esp32', 'esp32c3', 'esp32c61', 'esp32p4'], indirect=['target']) def test_cxx_rtti(dut: Dut) -> None: dut.run_all_single_board_cases() diff --git a/components/esp_common/include/esp_attr.h b/components/esp_common/include/esp_attr.h index 3ada7d5a8b..bd122e39c9 100644 --- a/components/esp_common/include/esp_attr.h +++ b/components/esp_common/include/esp_attr.h @@ -161,6 +161,13 @@ extern "C" { // Forces to not inline function #define NOINLINE_ATTR __attribute__((noinline)) +#if !defined(__clang__) && __GNUC__ >= 15 +// Marks a character array as not null-terminated to avoid string-related optimizations or warnings +#define NONSTRING_ATTR __attribute__ ((nonstring)) +#else +#define NONSTRING_ATTR +#endif + // This allows using enum as flags in C++ // Format: FLAG_ATTR(flag_enum_t) #ifdef __cplusplus diff --git a/components/esp_driver_uart/include/driver/uart_wakeup.h b/components/esp_driver_uart/include/driver/uart_wakeup.h index 4ac3665da0..2fab94f0af 100644 --- a/components/esp_driver_uart/include/driver/uart_wakeup.h +++ b/components/esp_driver_uart/include/driver/uart_wakeup.h @@ -7,6 +7,7 @@ #pragma once #include "esp_err.h" +#include "esp_attr.h" #include "soc/soc_caps.h" #include "hal/uart_types.h" @@ -45,7 +46,7 @@ typedef struct { '*' represents any symbol. The end character cannot be '*'. Example: "he**o" matches hello, heyyo. */ - char wake_chars_seq[SOC_UART_WAKEUP_CHARS_SEQ_MAX_LEN]; + NONSTRING_ATTR char wake_chars_seq[SOC_UART_WAKEUP_CHARS_SEQ_MAX_LEN]; #endif } uart_wakeup_cfg_t; diff --git a/components/esp_hw_support/lowpower/port/esp32s3/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32s3/sleep_cpu.c index b070648730..14edd6563c 100644 --- a/components/esp_hw_support/lowpower/port/esp32s3/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32s3/sleep_cpu.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -119,11 +119,11 @@ static esp_err_t esp_sleep_tagmem_pd_low_init(void) if (s_tag_mem->link_addr == NULL) { extern char _stext[], _etext[]; uint32_t code_start = (uint32_t)_stext; - uint32_t code_size = (uint32_t)(_etext - _stext); + uint32_t code_size = (uint32_t)((uintptr_t)_etext - (uintptr_t)_stext); #if !(CONFIG_SPIRAM && CONFIG_SOC_PM_SUPPORT_TAGMEM_PD) extern char _rodata_start[], _rodata_reserved_end[]; uint32_t data_start = (uint32_t)_rodata_start; - uint32_t data_size = (uint32_t)(_rodata_reserved_end - _rodata_start); + uint32_t data_size = (uint32_t)((uintptr_t)_rodata_reserved_end - (uintptr_t)_rodata_start); #else uint32_t data_start = SOC_DROM_LOW; uint32_t data_size = SOC_EXTRAM_DATA_SIZE; diff --git a/components/esp_phy/esp32/include/phy_init_data.h b/components/esp_phy/esp32/include/phy_init_data.h index 146a08af16..655eaac249 100644 --- a/components/esp_phy/esp32/include/phy_init_data.h +++ b/components/esp_phy/esp32/include/phy_init_data.h @@ -7,6 +7,7 @@ #ifndef PHY_INIT_DATA_H #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ #include "esp_phy_init.h" +#include "esp_attr.h" #include "sdkconfig.h" #ifdef __cplusplus @@ -50,7 +51,7 @@ typedef struct { * @brief Country corresponds to PHY init data type structure */ typedef struct { - char cc[PHY_COUNTRY_CODE_LEN]; + NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN]; uint8_t type; } phy_country_to_bin_type_t; #endif diff --git a/components/esp_phy/esp32c2/include/phy_init_data.h b/components/esp_phy/esp32c2/include/phy_init_data.h index 322b9bec8e..ea404dbd88 100644 --- a/components/esp_phy/esp32c2/include/phy_init_data.h +++ b/components/esp_phy/esp32c2/include/phy_init_data.h @@ -7,6 +7,7 @@ #ifndef PHY_INIT_DATA_H #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ #include "esp_phy_init.h" +#include "esp_attr.h" #include "sdkconfig.h" #ifdef __cplusplus @@ -51,7 +52,7 @@ typedef struct { * @brief Country corresponds to PHY init data type structure */ typedef struct { - char cc[PHY_COUNTRY_CODE_LEN]; + NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN]; uint8_t type; } phy_country_to_bin_type_t; #endif diff --git a/components/esp_phy/esp32c3/include/phy_init_data.h b/components/esp_phy/esp32c3/include/phy_init_data.h index 322b9bec8e..ea404dbd88 100644 --- a/components/esp_phy/esp32c3/include/phy_init_data.h +++ b/components/esp_phy/esp32c3/include/phy_init_data.h @@ -7,6 +7,7 @@ #ifndef PHY_INIT_DATA_H #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ #include "esp_phy_init.h" +#include "esp_attr.h" #include "sdkconfig.h" #ifdef __cplusplus @@ -51,7 +52,7 @@ typedef struct { * @brief Country corresponds to PHY init data type structure */ typedef struct { - char cc[PHY_COUNTRY_CODE_LEN]; + NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN]; uint8_t type; } phy_country_to_bin_type_t; #endif diff --git a/components/esp_phy/esp32c5/include/phy_init_data.h b/components/esp_phy/esp32c5/include/phy_init_data.h index 8a0eb24016..c3c126ac66 100644 --- a/components/esp_phy/esp32c5/include/phy_init_data.h +++ b/components/esp_phy/esp32c5/include/phy_init_data.h @@ -7,6 +7,7 @@ #ifndef PHY_INIT_DATA_H #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ #include +#include "esp_attr.h" #include "esp_phy_init.h" #include "sdkconfig.h" @@ -52,7 +53,7 @@ typedef struct { * @brief Country corresponds to PHY init data type structure */ typedef struct { - char cc[PHY_COUNTRY_CODE_LEN]; + NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN]; uint8_t type; } phy_country_to_bin_type_t; #endif diff --git a/components/esp_phy/esp32c6/include/phy_init_data.h b/components/esp_phy/esp32c6/include/phy_init_data.h index 322b9bec8e..ea404dbd88 100644 --- a/components/esp_phy/esp32c6/include/phy_init_data.h +++ b/components/esp_phy/esp32c6/include/phy_init_data.h @@ -7,6 +7,7 @@ #ifndef PHY_INIT_DATA_H #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ #include "esp_phy_init.h" +#include "esp_attr.h" #include "sdkconfig.h" #ifdef __cplusplus @@ -51,7 +52,7 @@ typedef struct { * @brief Country corresponds to PHY init data type structure */ typedef struct { - char cc[PHY_COUNTRY_CODE_LEN]; + NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN]; uint8_t type; } phy_country_to_bin_type_t; #endif diff --git a/components/esp_phy/esp32c61/include/phy_init_data.h b/components/esp_phy/esp32c61/include/phy_init_data.h index 8a0eb24016..5eba276504 100644 --- a/components/esp_phy/esp32c61/include/phy_init_data.h +++ b/components/esp_phy/esp32c61/include/phy_init_data.h @@ -8,6 +8,7 @@ #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ #include #include "esp_phy_init.h" +#include "esp_attr.h" #include "sdkconfig.h" #ifdef __cplusplus @@ -52,7 +53,7 @@ typedef struct { * @brief Country corresponds to PHY init data type structure */ typedef struct { - char cc[PHY_COUNTRY_CODE_LEN]; + NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN]; uint8_t type; } phy_country_to_bin_type_t; #endif diff --git a/components/esp_phy/esp32s2/include/phy_init_data.h b/components/esp_phy/esp32s2/include/phy_init_data.h index 322b9bec8e..ea404dbd88 100644 --- a/components/esp_phy/esp32s2/include/phy_init_data.h +++ b/components/esp_phy/esp32s2/include/phy_init_data.h @@ -7,6 +7,7 @@ #ifndef PHY_INIT_DATA_H #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ #include "esp_phy_init.h" +#include "esp_attr.h" #include "sdkconfig.h" #ifdef __cplusplus @@ -51,7 +52,7 @@ typedef struct { * @brief Country corresponds to PHY init data type structure */ typedef struct { - char cc[PHY_COUNTRY_CODE_LEN]; + NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN]; uint8_t type; } phy_country_to_bin_type_t; #endif diff --git a/components/esp_phy/esp32s3/include/phy_init_data.h b/components/esp_phy/esp32s3/include/phy_init_data.h index 322b9bec8e..ea404dbd88 100644 --- a/components/esp_phy/esp32s3/include/phy_init_data.h +++ b/components/esp_phy/esp32s3/include/phy_init_data.h @@ -7,6 +7,7 @@ #ifndef PHY_INIT_DATA_H #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ #include "esp_phy_init.h" +#include "esp_attr.h" #include "sdkconfig.h" #ifdef __cplusplus @@ -51,7 +52,7 @@ typedef struct { * @brief Country corresponds to PHY init data type structure */ typedef struct { - char cc[PHY_COUNTRY_CODE_LEN]; + NONSTRING_ATTR char cc[PHY_COUNTRY_CODE_LEN]; uint8_t type; } phy_country_to_bin_type_t; #endif diff --git a/components/esp_rom/esp32h21/include/esp32h21/rom/libc_stubs.h b/components/esp_rom/esp32h21/include/esp32h21/rom/libc_stubs.h index 8b2b9ebd63..3b6db54495 100644 --- a/components/esp_rom/esp32h21/include/esp32h21/rom/libc_stubs.h +++ b/components/esp_rom/esp32h21/include/esp32h21/rom/libc_stubs.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -57,7 +57,6 @@ struct syscall_stub_table int (*_write_r)(struct _reent *r, int, const void *, int); int (*_lseek_r)(struct _reent *r, int, int, int); int (*_read_r)(struct _reent *r, int, void *, int); -#ifdef _RETARGETABLE_LOCKING void (*_retarget_lock_init)(_LOCK_T *lock); void (*_retarget_lock_init_recursive)(_LOCK_T *lock); void (*_retarget_lock_close)(_LOCK_T lock); @@ -68,18 +67,6 @@ struct syscall_stub_table int (*_retarget_lock_try_acquire_recursive)(_LOCK_T lock); void (*_retarget_lock_release)(_LOCK_T lock); void (*_retarget_lock_release_recursive)(_LOCK_T lock); -#else - void (*_lock_init)(_lock_t *lock); - void (*_lock_init_recursive)(_lock_t *lock); - void (*_lock_close)(_lock_t *lock); - void (*_lock_close_recursive)(_lock_t *lock); - void (*_lock_acquire)(_lock_t *lock); - void (*_lock_acquire_recursive)(_lock_t *lock); - int (*_lock_try_acquire)(_lock_t *lock); - int (*_lock_try_acquire_recursive)(_lock_t *lock); - void (*_lock_release)(_lock_t *lock); - void (*_lock_release_recursive)(_lock_t *lock); -#endif int (*_printf_float)(struct _reent *data, void *pdata, FILE * fp, int (*pfunc) (struct _reent *, FILE *, const char *, size_t len), va_list * ap); int (*_scanf_float) (struct _reent *rptr, void *pdata, FILE *fp, va_list *ap); void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((noreturn)); diff --git a/components/esp_rom/esp32s2/usb_patches.c b/components/esp_rom/esp32s2/usb_patches.c index 978c9b1f78..6acd2dbeb0 100644 --- a/components/esp_rom/esp32s2/usb_patches.c +++ b/components/esp_rom/esp32s2/usb_patches.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -73,11 +73,11 @@ void rom_usb_cdc_set_descriptor_patch(void) void usb_dev_deinit(void) { extern char rom_usb_dev, rom_usb_dev_end; - memset((void *) &rom_usb_dev, 0, &rom_usb_dev_end - &rom_usb_dev); + memset((void *) &rom_usb_dev, 0, (uintptr_t)&rom_usb_dev_end - (uintptr_t)&rom_usb_dev); } void usb_dw_ctrl_deinit(void) { extern char rom_usb_dw_ctrl, rom_usb_dw_ctrl_end; - memset((void *) &rom_usb_dw_ctrl, 0, &rom_usb_dw_ctrl_end - &rom_usb_dw_ctrl); + memset((void *) &rom_usb_dw_ctrl, 0, (uintptr_t)&rom_usb_dw_ctrl_end - (uintptr_t)&rom_usb_dw_ctrl); } diff --git a/components/esp_system/port/cpu_start.c b/components/esp_system/port/cpu_start.c index 978aa1fb81..0afbd83254 100644 --- a/components/esp_system/port/cpu_start.c +++ b/components/esp_system/port/cpu_start.c @@ -417,26 +417,26 @@ FORCE_INLINE_ATTR IRAM_ATTR void get_reset_reason(soc_reset_reason_t *rst_reas) FORCE_INLINE_ATTR IRAM_ATTR void init_bss(const soc_reset_reason_t *rst_reas) { #if SOC_MEM_NON_CONTIGUOUS_SRAM - memset(&_bss_start_low, 0, (&_bss_end_low - &_bss_start_low) * sizeof(_bss_start_low)); - memset(&_bss_start_high, 0, (&_bss_end_high - &_bss_start_high) * sizeof(_bss_start_high)); + memset(&_bss_start_low, 0, (uintptr_t)&_bss_end_low - (uintptr_t)&_bss_start_low); + memset(&_bss_start_high, 0, (uintptr_t)&_bss_end_high - (uintptr_t)&_bss_start_high); #else - memset(&_bss_start, 0, (&_bss_end - &_bss_start) * sizeof(_bss_start)); + memset(&_bss_start, 0, (uintptr_t)&_bss_end - (uintptr_t)&_bss_start); #endif // SOC_MEM_NON_CONTIGUOUS_SRAM #if CONFIG_BT_LE_RELEASE_IRAM_SUPPORTED // Clear Bluetooth bss - memset(&_bss_bt_start, 0, (&_bss_bt_end - &_bss_bt_start) * sizeof(_bss_bt_start)); + memset(&_bss_bt_start, 0, (uintptr_t)&_bss_bt_end - (uintptr_t)&_bss_bt_start); #endif // CONFIG_BT_LE_RELEASE_IRAM_SUPPORTED #if defined(CONFIG_IDF_TARGET_ESP32) && defined(CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY) // Clear IRAM BSS - memset(&_iram_bss_start, 0, (&_iram_bss_end - &_iram_bss_start) * sizeof(_iram_bss_start)); + memset(&_iram_bss_start, 0, (uintptr_t)&_iram_bss_end - (uintptr_t)&_iram_bss_start); #endif #if SOC_RTC_FAST_MEM_SUPPORTED || SOC_RTC_SLOW_MEM_SUPPORTED /* Unless waking from deep sleep (implying RTC memory is intact), clear RTC bss */ if (rst_reas[0] != RESET_REASON_CORE_DEEP_SLEEP) { - memset(&_rtc_bss_start, 0, (&_rtc_bss_end - &_rtc_bss_start) * sizeof(_rtc_bss_start)); + memset(&_rtc_bss_start, 0, (uintptr_t)&_rtc_bss_end - (uintptr_t)&_rtc_bss_start); } #endif } diff --git a/components/esp_system/port/soc/esp32h4/system_internal.c b/components/esp_system/port/soc/esp32h4/system_internal.c index b4d2ca2498..f421bbd90f 100644 --- a/components/esp_system/port/soc/esp32h4/system_internal.c +++ b/components/esp_system/port/soc/esp32h4/system_internal.c @@ -10,6 +10,7 @@ #include "esp_private/system_internal.h" #include "esp_attr.h" #include "esp_log.h" +#include "esp_macros.h" #include "esp_rom_sys.h" #include "riscv/rv_utils.h" #include "esp_rom_uart.h" @@ -135,7 +136,5 @@ void esp_restart_noos(void) esp_cpu_reset(1); } #endif - while (true) { - ; - } + ESP_INFINITE_LOOP(); } diff --git a/components/esp_wifi/CMakeLists.txt b/components/esp_wifi/CMakeLists.txt index 2cd6ec22e2..99984c96e2 100644 --- a/components/esp_wifi/CMakeLists.txt +++ b/components/esp_wifi/CMakeLists.txt @@ -97,6 +97,12 @@ if(CONFIG_ESP_WIFI_ENABLED OR CONFIG_ESP_HOST_WIFI_ENABLED) target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob}) endforeach() endif() + # TODO IDF-13365: remove the following lines + if(CMAKE_C_COMPILER_ID MATCHES "GNU") + set_source_files_properties(regulatory/esp_wifi_regulatory.c + PROPERTIES COMPILE_FLAGS + -Wno-unterminated-string-initialization) + endif() endif() if(CONFIG_SPIRAM) diff --git a/components/esp_wifi/test_apps/bin_size_apsta/pytest_bin_size_apsta.py b/components/esp_wifi/test_apps/bin_size_apsta/pytest_bin_size_apsta.py index f3ecffb532..51e16ecac6 100644 --- a/components/esp_wifi/test_apps/bin_size_apsta/pytest_bin_size_apsta.py +++ b/components/esp_wifi/test_apps/bin_size_apsta/pytest_bin_size_apsta.py @@ -11,7 +11,7 @@ from pytest_embedded_idf.utils import idf_parametrize # The standard value has 30~100 bytes fault tolerance SAVE_BIN_SIZE_TH = { 'disable_sae_h2e': { - 'esp32': 16800, + 'esp32': 16600, 'esp32c2': 19700, 'esp32c3': 19600, 'esp32c5': 19650, diff --git a/components/fatfs/vfs/vfs_fat.c b/components/fatfs/vfs/vfs_fat.c index b0b32fa9dc..a2c865b4c5 100644 --- a/components/fatfs/vfs/vfs_fat.c +++ b/components/fatfs/vfs/vfs_fat.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/components/heap/port/memory_layout_utils.c b/components/heap/port/memory_layout_utils.c index f24fdebf00..6410252a90 100644 --- a/components/heap/port/memory_layout_utils.c +++ b/components/heap/port/memory_layout_utils.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -25,8 +25,9 @@ extern soc_reserved_region_t soc_reserved_memory_region_end; static size_t s_get_num_reserved_regions(void) { - size_t result = ( &soc_reserved_memory_region_end - - &soc_reserved_memory_region_start ); + size_t result = (uintptr_t)&soc_reserved_memory_region_end - (uintptr_t)&soc_reserved_memory_region_start; + result /= sizeof(soc_reserved_region_t); + #if ESP_ROM_HAS_LAYOUT_TABLE return result + 1; // ROM table means one entry needs to be added at runtime #else diff --git a/components/log/src/log_format_text.c b/components/log/src/log_format_text.c index b1f7819970..21172f1f9f 100644 --- a/components/log/src/log_format_text.c +++ b/components/log/src/log_format_text.c @@ -28,7 +28,7 @@ static __attribute__((unused)) const char s_lvl_name[ESP_LOG_MAX] = { 'V', // VERBOSE }; -static __attribute__((unused)) const char s_lvl_color[ESP_LOG_MAX][8] = { +static __attribute__((unused)) const char s_lvl_color[ESP_LOG_MAX][9] = { "\0", // NONE LOG_ANSI_COLOR_REGULAR(LOG_ANSI_COLOR_RED)"\0", // ERROR LOG_ANSI_COLOR_REGULAR(LOG_ANSI_COLOR_YELLOW)"\0", // WARNING diff --git a/components/lwip/port/hooks/lwip_default_hooks.c b/components/lwip/port/hooks/lwip_default_hooks.c index 180c15a632..1ec6e75814 100644 --- a/components/lwip/port/hooks/lwip_default_hooks.c +++ b/components/lwip/port/hooks/lwip_default_hooks.c @@ -11,7 +11,9 @@ #include "esp_log.h" #include +#ifndef __weak #define __weak __attribute__((weak)) +#endif /** * Default lwip behavior is to silence LWIP_ERROR() if LWIP_DEBUG is not set. diff --git a/components/mbedtls/CMakeLists.txt b/components/mbedtls/CMakeLists.txt index 4308a0a7c9..eb4d5a7f06 100644 --- a/components/mbedtls/CMakeLists.txt +++ b/components/mbedtls/CMakeLists.txt @@ -347,6 +347,11 @@ foreach(target ${mbedtls_targets}) endif() endforeach() +if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 15.0) + target_compile_options(mbedtls PRIVATE "-Wno-unterminated-string-initialization") +endif() + + if(CONFIG_MBEDTLS_DYNAMIC_BUFFER) set(WRAP_FUNCTIONS mbedtls_ssl_write_client_hello diff --git a/components/mbedtls/esp_crt_bundle/esp_crt_bundle.c b/components/mbedtls/esp_crt_bundle/esp_crt_bundle.c index 65f817f7bd..9714f5366c 100644 --- a/components/mbedtls/esp_crt_bundle/esp_crt_bundle.c +++ b/components/mbedtls/esp_crt_bundle/esp_crt_bundle.c @@ -335,7 +335,7 @@ esp_err_t esp_crt_bundle_attach(void *conf) esp_err_t ret = ESP_OK; // If no bundle has been set by the user then use the bundle embedded in the binary if (s_crt_bundle == NULL) { - ret = esp_crt_bundle_init(x509_crt_imported_bundle_bin_start, x509_crt_imported_bundle_bin_end - x509_crt_imported_bundle_bin_start); + ret = esp_crt_bundle_init(x509_crt_imported_bundle_bin_start, (uintptr_t)x509_crt_imported_bundle_bin_end - (uintptr_t)x509_crt_imported_bundle_bin_start); } if (unlikely(ret != ESP_OK)) { diff --git a/components/newlib/CMakeLists.txt b/components/newlib/CMakeLists.txt index 99a11e810f..3d4769ca67 100644 --- a/components/newlib/CMakeLists.txt +++ b/components/newlib/CMakeLists.txt @@ -38,20 +38,23 @@ if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND) endif() if(CONFIG_LIBC_OPTIMIZED_MISALIGNED_ACCESS) - list(APPEND srcs - "src/string/memcmp.c" - "src/string/memmove.c" - "src/string/strncmp.c" - "src/string/strncpy.c" - "src/port/riscv/memcpy.c" - "src/port/riscv/strcpy.c" - "src/port/riscv/strcmp.S") - list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_memcmp_impl") - list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_memmove_impl") - list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_strncmp_impl") - list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_strncpy_impl") - list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_strcpy_impl") - list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_strcmp_impl") + if(CMAKE_C_COMPILER_ID MATCHES "Clang") + # TODO IDF-13089: remove this block and modify src/newlib.lf when clang was upgraded + list(APPEND srcs + "src/string/memcmp.c" + "src/string/memmove.c" + "src/string/strncmp.c" + "src/string/strncpy.c" + "src/port/riscv/memcpy.c" + "src/port/riscv/strcpy.c" + "src/port/riscv/strcmp.S") + list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_memcmp_impl") + list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_memmove_impl") + list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_strncmp_impl") + list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_strncpy_impl") + list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_strcpy_impl") + list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_strcmp_impl") + endif() endif() if(CONFIG_LIBC_NEWLIB) @@ -69,12 +72,10 @@ endif() set(ldfragments "") list(APPEND ldfragments "src/newlib.lf" "src/system_libs.lf") -if(CONFIG_SPIRAM_CACHE_WORKAROUND) - if(CONFIG_LIBC_NEWLIB) - list(APPEND ldfragments src/esp32-spiram-rom-functions-c.lf) - else() - list(APPEND ldfragments src/picolibc/esp32-spiram-rom-functions-c.lf) - endif() +if(CONFIG_LIBC_NEWLIB) + list(APPEND ldfragments src/libc.lf) +else() + list(APPEND ldfragments src/picolibc/libc.lf) endif() idf_component_register(SRCS "${srcs}" diff --git a/components/newlib/platform_include/sys/lock.h b/components/newlib/platform_include/sys/lock.h index aed4d2c183..9674232136 100644 --- a/components/newlib/platform_include/sys/lock.h +++ b/components/newlib/platform_include/sys/lock.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,7 +12,7 @@ extern "C" { #endif -#ifdef _RETARGETABLE_LOCKING +#if defined(_RETARGETABLE_LOCKING) || defined(CONFIG_LIBC_PICOLIBC) /* Actual platfrom-specific definition of struct __lock. * The size here should be sufficient for a FreeRTOS mutex. @@ -52,10 +52,6 @@ int _lock_try_acquire_recursive(_lock_t *plock); void _lock_release(_lock_t *plock); void _lock_release_recursive(_lock_t *plock); -#if CONFIG_LIBC_PICOLIBC -#define __lock_try_acquire(lock) _lock_try_acquire(&(lock)) -#define __lock_try_acquire_recursive(lock) _lock_try_acquire_recursive(&(lock)) -#endif // CONFIG_LIBC_PICOLIBC #endif // _RETARGETABLE_LOCKING #ifdef __cplusplus diff --git a/components/newlib/platform_include/sys/select.h b/components/newlib/platform_include/sys/select.h index e4d828b711..2eeab9092f 100644 --- a/components/newlib/platform_include/sys/select.h +++ b/components/newlib/platform_include/sys/select.h @@ -26,6 +26,10 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct #endif // fd_set +#if __BSD_VISIBLE && !defined(fds_bits) +#define fds_bits __fds_bits +#endif + #if defined(FD_ISSET) || defined(FD_SET) || defined(FD_CLR) #undef FD_SET #undef FD_CLR diff --git a/components/newlib/src/getentropy.c b/components/newlib/src/getentropy.c index 530a5964cc..850ae4e1cf 100644 --- a/components/newlib/src/getentropy.c +++ b/components/newlib/src/getentropy.c @@ -6,6 +6,7 @@ #include #include +#include int getentropy(void *buffer, size_t length) { diff --git a/components/newlib/src/esp32-spiram-rom-functions-c.lf b/components/newlib/src/libc.lf similarity index 97% rename from components/newlib/src/esp32-spiram-rom-functions-c.lf rename to components/newlib/src/libc.lf index 1e066d61b1..1f31f191c1 100644 --- a/components/newlib/src/esp32-spiram-rom-functions-c.lf +++ b/components/newlib/src/libc.lf @@ -3,10 +3,6 @@ # and/or applications may assume that because these functions normally are in ROM, they are accessible even when flash is # inaccessible. To work around this, this ld fragment places these functions in RAM instead. If the ROM functions are used, # these defines do nothing, so they can still be included in that situation. -# -# -# Note: the only difference between esp32-spiram-rom-functions-c.lf -# and esp32-spiram-rom-functions-psram-workaround.lf is the archive name. [mapping:libc] archive: @@ -15,6 +11,8 @@ archive: else: libc.a entries: + if LIBC_OPTIMIZED_MISALIGNED_ACCESS = y: + libc_a-memcpy (noflash) if SPIRAM_CACHE_WORKAROUND = y: # The following libs are either used in a lot of places or in critical # code. (such as panic or abort) diff --git a/components/newlib/src/newlib.lf b/components/newlib/src/newlib.lf index 7ca47a0b9b..359acd6345 100644 --- a/components/newlib/src/newlib.lf +++ b/components/newlib/src/newlib.lf @@ -9,3 +9,18 @@ entries: stdatomic (noflash) if STDATOMIC_S32C1I_SPIRAM_WORKAROUND = y: stdatomic_s32c1i (noflash) + if STDATOMIC_S32C1I_SPIRAM_WORKAROUND = y: + stdatomic_s32c1i (noflash) + if CONFIG_LIBC_OPTIMIZED_MISALIGNED_ACCESS = y && IDF_TOOLCHAIN_GCC = y: + # memcpy() should be in IRAM due to early system use + # Others can stay in flash (performance difference is minimal) + # + # Performance Comparison: + # | func | flash | iram | + # |---------|-------|-------| + # | memcmp | 15986 | 15170 | + # | strcpy | 17499 | 16660 | + # | strcmp | 13125 | 11147 | + # | strncpy | 17386 | 16668 | + # | strncmp | 22161 | 21782 | + libc_a-memcpy (noflash) diff --git a/components/newlib/src/picolibc/esp32-spiram-rom-functions-c.lf b/components/newlib/src/picolibc/libc.lf similarity index 96% rename from components/newlib/src/picolibc/esp32-spiram-rom-functions-c.lf rename to components/newlib/src/picolibc/libc.lf index f2a97b4cc9..0892557473 100644 --- a/components/newlib/src/picolibc/esp32-spiram-rom-functions-c.lf +++ b/components/newlib/src/picolibc/libc.lf @@ -8,6 +8,10 @@ archive: libc.a entries: + if LIBC_OPTIMIZED_MISALIGNED_ACCESS = y && IDF_TARGET_ARCH_RISCV = y: + memcpy-asm (noflash) + if LIBC_OPTIMIZED_MISALIGNED_ACCESS = y && IDF_TARGET_ARCH_XTENSA = y: + libc_machine_xtensa_memcpy (noflash) if SPIRAM_CACHE_WORKAROUND = y: # The following libs are either used in a lot of places or in critical code. (such as panic or abort) # Thus, they shall always be placed in IRAM. diff --git a/components/newlib/src/picolibc/picolibc_init.c b/components/newlib/src/picolibc/picolibc_init.c index 2e0fc30f14..efe982e897 100644 --- a/components/newlib/src/picolibc/picolibc_init.c +++ b/components/newlib/src/picolibc/picolibc_init.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/components/newlib/src/pthread.c b/components/newlib/src/pthread.c index 13da80d7d5..d899dabad3 100644 --- a/components/newlib/src/pthread.c +++ b/components/newlib/src/pthread.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ #include +#include #include "esp_log.h" const static char *TAG = "esp32_asio_pthread"; @@ -22,6 +23,8 @@ int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict os return 0; } +// picolibc has sigfillset macro in signal.h +#if !CONFIG_LIBC_PICOLIBC int sigfillset(sigset_t *what) { ESP_LOGD(TAG, "%s: Signals not supported in ESP pthread", __func__); @@ -30,6 +33,7 @@ int sigfillset(sigset_t *what) } return 0; } +#endif /* !CONFIG_LIBC_PICOLIBC */ void esp_libc_include_pthread_impl(void) { diff --git a/components/newlib/src/reent_syscalls.c b/components/newlib/src/reent_syscalls.c index 72f3a4ec18..a036222990 100644 --- a/components/newlib/src/reent_syscalls.c +++ b/components/newlib/src/reent_syscalls.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "sdkconfig.h" #include "esp_rom_uart.h" #include "esp_system_console.h" diff --git a/components/newlib/src/syscalls.c b/components/newlib/src/syscalls.c index 4ead5eb1a3..ed5ee9f03a 100644 --- a/components/newlib/src/syscalls.c +++ b/components/newlib/src/syscalls.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -10,6 +10,11 @@ #include #include #include +#include + +#if CONFIG_IDF_TOOLCHAIN_GCC +#include +#endif #if CONFIG_LIBC_PICOLIBC int open(const char *pathname, int flags, ...) @@ -126,6 +131,22 @@ int system(const char* str) return _system_r(__getreent(), str); } +#if CONFIG_IDF_TOOLCHAIN_GCC +int statvfs(const char *restrict path, struct statvfs *restrict buf) +{ + /* TODO IDF-9879 */ + errno = ENOSYS; + return -1; +} + +int fstatvfs(int fd, struct statvfs *buf) +{ + /* TODO IDF-9879 */ + errno = ENOSYS; + return -1; +} +#endif + void esp_libc_include_syscalls_impl(void) { } diff --git a/components/newlib/test_apps/newlib/main/test_newlib.c b/components/newlib/test_apps/newlib/main/test_newlib.c index bd6a91627a..65137cebe8 100644 --- a/components/newlib/test_apps/newlib/main/test_newlib.c +++ b/components/newlib/test_apps/newlib/main/test_newlib.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "unity.h" #include "sdkconfig.h" diff --git a/components/soc/esp32h2/register/soc/pmu_struct.h b/components/soc/esp32h2/register/soc/pmu_struct.h index a38ff690ec..74753c6981 100644 --- a/components/soc/esp32h2/register/soc/pmu_struct.h +++ b/components/soc/esp32h2/register/soc/pmu_struct.h @@ -6,6 +6,7 @@ #pragma once #include +#include #include "soc/pmu_reg.h" #ifdef __cplusplus extern "C" { diff --git a/components/soc/esp32h21/register/soc/pmu_struct.h b/components/soc/esp32h21/register/soc/pmu_struct.h index cb01406439..5f77c3317b 100644 --- a/components/soc/esp32h21/register/soc/pmu_struct.h +++ b/components/soc/esp32h21/register/soc/pmu_struct.h @@ -6,6 +6,7 @@ #pragma once #include +#include #include "soc/pmu_reg.h" #ifdef __cplusplus extern "C" diff --git a/components/soc/esp32h4/register/soc/pmu_struct.h b/components/soc/esp32h4/register/soc/pmu_struct.h index be8eafa6e1..f0caccff4a 100644 --- a/components/soc/esp32h4/register/soc/pmu_struct.h +++ b/components/soc/esp32h4/register/soc/pmu_struct.h @@ -6,6 +6,7 @@ #pragma once #include +#include #ifdef __cplusplus extern "C" { #endif diff --git a/components/soc/esp32p4/register/soc/pmu_struct.h b/components/soc/esp32p4/register/soc/pmu_struct.h index b62a05199b..6d3cf7298c 100644 --- a/components/soc/esp32p4/register/soc/pmu_struct.h +++ b/components/soc/esp32p4/register/soc/pmu_struct.h @@ -5,6 +5,7 @@ */ #pragma once +#include #include #include "soc/pmu_reg.h" #ifdef __cplusplus diff --git a/components/soc/lldesc.c b/components/soc/lldesc.c index 7850d78799..3cc947b62b 100644 --- a/components/soc/lldesc.c +++ b/components/soc/lldesc.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include "soc/lldesc.h" void lldesc_setup_link_constrained(lldesc_t *dmadesc, const void *data, int len, int max_desc_size, bool isrx) diff --git a/components/spiffs/esp_spiffs.c b/components/spiffs/esp_spiffs.c index b4820f5098..68e253db14 100644 --- a/components/spiffs/esp_spiffs.c +++ b/components/spiffs/esp_spiffs.c @@ -15,6 +15,7 @@ #include "freertos/semphr.h" #include #include +#include #include #include #include diff --git a/components/ulp/cmake/toolchain-lp-core-riscv.cmake b/components/ulp/cmake/toolchain-lp-core-riscv.cmake index eb3a0623be..900ad5923d 100644 --- a/components/ulp/cmake/toolchain-lp-core-riscv.cmake +++ b/components/ulp/cmake/toolchain-lp-core-riscv.cmake @@ -5,11 +5,11 @@ set(CMAKE_C_COMPILER "riscv32-esp-elf-gcc") set(CMAKE_CXX_COMPILER "riscv32-esp-elf-g++") set(CMAKE_ASM_COMPILER "riscv32-esp-elf-gcc") -set(CMAKE_C_FLAGS "-Os -ggdb -march=rv32imac_zicsr_zifencei -mdiv -fdata-sections -ffunction-sections" +set(CMAKE_C_FLAGS "-Os -ggdb -march=rv32imac_zicsr_zifencei_zaamo_zalrsc -mdiv -fdata-sections -ffunction-sections" CACHE STRING "C Compiler Base Flags") -set(CMAKE_CXX_FLAGS "-Os -ggdb -march=rv32imac_zicsr_zifencei -mdiv -fdata-sections -ffunction-sections" +set(CMAKE_CXX_FLAGS "-Os -ggdb -march=rv32imac_zicsr_zifencei_zaamo_zalrsc -mdiv -fdata-sections -ffunction-sections" CACHE STRING "C++ Compiler Base Flags") -set(CMAKE_ASM_FLAGS "-Os -ggdb -march=rv32imac_zicsr_zifencei -x assembler-with-cpp" +set(CMAKE_ASM_FLAGS "-Os -ggdb -march=rv32imac_zicsr_zifencei_zaamo_zalrsc -x assembler-with-cpp" CACHE STRING "Assembler Base Flags") -set(CMAKE_EXE_LINKER_FLAGS "-march=rv32imac_zicsr_zifencei --specs=nano.specs --specs=nosys.specs" +set(CMAKE_EXE_LINKER_FLAGS "-march=rv32imac_zicsr_zifencei_zaamo_zalrsc --specs=nano.specs --specs=nosys.specs" CACHE STRING "Linker Base Flags") diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index d293735204..3a45a310a0 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -362,6 +362,7 @@ PREDEFINED = \ IDF_DEPRECATED(X)= \ IRAM_ATTR= \ FORCE_INLINE_ATTR= \ + NONSTRING_ATTR= \ configSUPPORT_DYNAMIC_ALLOCATION=1 \ configSUPPORT_STATIC_ALLOCATION=1 \ configQUEUE_REGISTRY_SIZE=1 \ diff --git a/docs/en/migration-guides/release-6.x/6.0/index.rst b/docs/en/migration-guides/release-6.x/6.0/index.rst index cb0cbec001..19ce2244e8 100644 --- a/docs/en/migration-guides/release-6.x/6.0/index.rst +++ b/docs/en/migration-guides/release-6.x/6.0/index.rst @@ -11,3 +11,4 @@ Migration from 5.5 to 6.0 security tools system + toolchain diff --git a/docs/en/migration-guides/release-6.x/6.0/toolchain.rst b/docs/en/migration-guides/release-6.x/6.0/toolchain.rst new file mode 100644 index 0000000000..41713e4f36 --- /dev/null +++ b/docs/en/migration-guides/release-6.x/6.0/toolchain.rst @@ -0,0 +1,110 @@ +Toolchain +********* + +:link_to_translation:`zh_CN:[中文]` + +GCC Version +=========== + +The previous GCC version 14.2.0 has been upgraded to 15.1.0 across all chip targets. Upgrading to ESP-IDF v6.0 requires porting code to GCC 15.1.0. Refer to the official `GCC 15 porting guide `_ + +Warnings +======== + +The upgrade to GCC 15.1.0 has resulted in the addition of new warnings, or enhancements to existing warnings. The full details of all GCC warnings can be found in `GCC Warning Options `_. Users are advised to double-check their code, then fix the warnings if possible. Unfortunately, depending on the warning and the complexity of the user's code, some warnings will be false positives that require non-trivial fixes. In such cases, users can choose to suppress the warning in multiple ways. This section outlines some common warnings that users are likely to encounter and ways to fix them. + +To suprress all new warnings enable :ref:`CONFIG_COMPILER_DISABLE_GCC15_WARNINGS` config option. + +``-Wno-unterminated-string-initialization`` +------------------------------------------- + +Warn about character arrays initialized as unterminated character sequences with a string literal, unless the declaration being initialized has the nonstring attribute. + +.. code-block:: c + + #include "esp_attr.h" + + char arr[3] = "foo"; /* Warning. */ + NONSTRING_ATTR char arr2[3] = "bar"; /* No warning. */ + +``-Wno-header-guard`` +--------------------- + +Warn if a header file has a typo in its include guard. When #ifndef and #define use different names. + +.. code-block:: c + + #ifndef WHEADER_GUARD_2 + #define WHEADERGUARD2 /* Warning. Must be changed to WHEADER_GUARD_2. */ + /* ... */ + #endif + +``-Wno-self-move (C++ only)`` +----------------------------- + +Warns when a value is moved to itself with std::move. Such a std::move typically has no effect. + +.. code-block:: cpp + + struct T { + /* ... */ + }; + void fn() + { + T t; + /* ... */ + t = std::move (t); /* Warning. The line can be removed. */ + } + + +``-Wno-template-body (C++ only)`` +--------------------------------- + +Disable diagnosing errors when parsing a template, and instead issue an error only upon instantiation of the template. + +.. code-block:: cpp + + template + void f() { + const int n = 42; + ++n; /* read-only variable 'n' */ + } + +``-Wno-dangling-reference (C++ only)`` +-------------------------------------- + +Warn when a reference is bound to a temporary whose lifetime has ended. + +.. code-block:: cpp + + int n = 1; + const int& r = std::max(n - 1, n + 1); /* r is dangling. */ + +``-Wno-defaulted-function-deleted (C++ only)`` +---------------------------------------------- + +Warn when an explicitly defaulted function is deleted by the compiler. That can occur when the function’s declared type does not match the type of the function that would have been implicitly declared. + +.. code-block:: cpp + + template + struct C { + C(); + C(const C&&) = default; /* Implicitly deleted. */ + }; + +Picolibc +======== + +When building with :ref:`CONFIG_LIBC_PICOLIBC` enabled, the following adaptation is required. + +``sys/signal.h header removed`` +------------------------------- + +The header ```` is no longer available in Picolibc. +To ensure compatibility and improve portability across libc implementations, replace it with the standard C header ````. + +.. code-block:: c + + #include /* fatal error: sys/signal.h: No such file or directory */ + #include /* Ok: standard and portable */ diff --git a/docs/zh_CN/migration-guides/release-6.x/6.0/index.rst b/docs/zh_CN/migration-guides/release-6.x/6.0/index.rst index 5e5c9e2ae0..b47defe315 100644 --- a/docs/zh_CN/migration-guides/release-6.x/6.0/index.rst +++ b/docs/zh_CN/migration-guides/release-6.x/6.0/index.rst @@ -11,3 +11,4 @@ security tools system + toolchain diff --git a/docs/zh_CN/migration-guides/release-6.x/6.0/toolchain.rst b/docs/zh_CN/migration-guides/release-6.x/6.0/toolchain.rst new file mode 100644 index 0000000000..e04a9f42b6 --- /dev/null +++ b/docs/zh_CN/migration-guides/release-6.x/6.0/toolchain.rst @@ -0,0 +1 @@ +.. include:: ../../../../en/migration-guides/release-6.x/6.0/toolchain.rst diff --git a/tools/ci/python_packages/idf_iperf_test_util/IperfUtility.py b/tools/ci/python_packages/idf_iperf_test_util/IperfUtility.py index ff248219e5..632da99dbc 100644 --- a/tools/ci/python_packages/idf_iperf_test_util/IperfUtility.py +++ b/tools/ci/python_packages/idf_iperf_test_util/IperfUtility.py @@ -7,11 +7,13 @@ import subprocess import time import pexpect -from idf_iperf_test_util import LineChart from pytest_embedded import Dut +from idf_iperf_test_util import LineChart + try: - from typing import Any, Tuple + from typing import Any + from typing import Tuple except ImportError: # Only used for type annotations pass @@ -30,7 +32,7 @@ PC_IPERF_TEMP_LOG_FILE = '.tmp_iperf.log' class TestResult(object): - """ record, analysis test result and convert data to output format """ + """record, analysis test result and convert data to output format""" PC_BANDWIDTH_LOG_PATTERN = re.compile(r'(\d+\.\d+)\s*-\s*(\d+.\d+)\s+sec\s+[\d.]+\s+MBytes\s+([\d.]+)\s+Mbits\/sec') DUT_BANDWIDTH_LOG_PATTERN = re.compile(r'([\d.]+)\s*-\s*([\d.]+)\s+sec\s+([\d.]+)\s+Mbits/sec') @@ -47,7 +49,7 @@ class TestResult(object): RSSI_RANGE = [-x for x in range(10, 100)] ATT_RANGE = [x for x in range(0, 64)] - def __init__(self, proto:str, direction:str, config_name:str) -> None: + def __init__(self, proto: str, direction: str, config_name: str) -> None: self.proto = proto self.direction = direction self.config_name = config_name @@ -57,7 +59,7 @@ class TestResult(object): self.heap_size = INVALID_HEAP_SIZE self.error_list = [] # type: list[str] - def _save_result(self, throughput:float, ap_ssid:str, att:int, rssi:int, heap_size:str) -> None: + def _save_result(self, throughput: float, ap_ssid: str, att: int, rssi: int, heap_size: str) -> None: """ save the test results: @@ -72,7 +74,7 @@ class TestResult(object): self.att_rssi_map[ap_ssid][att] = rssi - def record_throughput(database:dict, key_value:int) -> None: + def record_throughput(database: dict, key_value: int) -> None: try: # we save the larger value for same att if throughput > database[ap_ssid][key_value]: @@ -86,7 +88,7 @@ class TestResult(object): if int(heap_size) < self.heap_size: self.heap_size = int(heap_size) - def add_result(self, raw_data:str, ap_ssid:str, att:int, rssi:int, heap_size:str) -> float: + def add_result(self, raw_data: str, ap_ssid: str, att: int, rssi: int, heap_size: str) -> float: """ add result for one test @@ -114,21 +116,27 @@ class TestResult(object): continue throughput_list.append(throughput) max_throughput = max(max_throughput, throughput) - if throughput == 0 and rssi > self.ZERO_POINT_THRESHOLD \ - and fall_to_0_recorded < 1: + if throughput == 0 and rssi > self.ZERO_POINT_THRESHOLD and fall_to_0_recorded < 1: # throughput fall to 0 error. we only record 1 records for one test - self.error_list.append('[Error][fall to 0][{}][att: {}][rssi: {}]: 0 throughput interval: {}-{}' - .format(ap_ssid, att, rssi, result[0], result[1])) + self.error_list.append( + '[Error][fall to 0][{}][att: {}][rssi: {}]: 0 throughput interval: {}-{}'.format( + ap_ssid, att, rssi, result[0], result[1] + ) + ) fall_to_0_recorded += 1 if len(throughput_list) < self.THROUGHPUT_QUALIFY_COUNT: - self.error_list.append('[Error][Fatal][{}][att: {}][rssi: {}]: Only {} throughput values found, expected at least {}' - .format(ap_ssid, att, rssi, len(throughput_list), self.THROUGHPUT_QUALIFY_COUNT)) + self.error_list.append( + '[Error][Fatal][{}][att: {}][rssi: {}]: Only {} throughput values found, expected at least {}'.format( + ap_ssid, att, rssi, len(throughput_list), self.THROUGHPUT_QUALIFY_COUNT + ) + ) max_throughput = 0.0 if max_throughput == 0 and rssi > self.ZERO_THROUGHPUT_THRESHOLD: - self.error_list.append('[Error][Fatal][{}][att: {}][rssi: {}]: No throughput data found' - .format(ap_ssid, att, rssi)) + self.error_list.append( + '[Error][Fatal][{}][att: {}][rssi: {}]: No throughput data found'.format(ap_ssid, att, rssi) + ) self._save_result(max_throughput, ap_ssid, att, rssi, heap_size) @@ -141,7 +149,8 @@ class TestResult(object): 1. throughput value 30% worse than the next point with lower RSSI 2. throughput value 30% worse than the next point with larger attenuate """ - def analysis_bad_point(data:dict, index_type:str) -> None: + + def analysis_bad_point(data: dict, index_type: str) -> None: for ap_ssid in data: result_dict = data[ap_ssid] index_list = list(result_dict.keys()) @@ -150,19 +159,23 @@ class TestResult(object): index_list.reverse() for i, index_value in enumerate(index_list[1:]): - if index_value < self.BAD_POINT_RSSI_THRESHOLD or \ - result_dict[index_list[i]] < self.BAD_POINT_MIN_THRESHOLD: + if ( + index_value < self.BAD_POINT_RSSI_THRESHOLD + or result_dict[index_list[i]] < self.BAD_POINT_MIN_THRESHOLD + ): continue _percentage = result_dict[index_value] / result_dict[index_list[i]] if _percentage < 1 - self.BAD_POINT_PERCENTAGE_THRESHOLD: - self.error_list.append('[Error][Bad point][{}][{}: {}]: drop {:.02f}%' - .format(ap_ssid, index_type, index_value, - (1 - _percentage) * 100)) + self.error_list.append( + '[Error][Bad point][{}][{}: {}]: drop {:.02f}%'.format( + ap_ssid, index_type, index_value, (1 - _percentage) * 100 + ) + ) analysis_bad_point(self.throughput_by_rssi, 'rssi') analysis_bad_point(self.throughput_by_att, 'att') - def draw_throughput_figure(self, path:str, ap_ssid:str, draw_type:str) -> str: + def draw_throughput_figure(self, path: str, ap_ssid: str, draw_type: str) -> str: """ :param path: folder to save figure. make sure the folder is already created. :param ap_ssid: ap ssid string or a list of ap ssid string @@ -184,14 +197,17 @@ class TestResult(object): else: file_name = 'ThroughputVs{}_{}_{}.html'.format(type_name, self.proto, self.direction) - LineChart.draw_line_chart(os.path.join(path, file_name), - 'Throughput Vs {} ({} {})'.format(type_name, self.proto, self.direction), - '{} (dbm)'.format(type_name), - 'Throughput (Mbps)', - data, range_list) + LineChart.draw_line_chart( + os.path.join(path, file_name), + 'Throughput Vs {} ({} {})'.format(type_name, self.proto, self.direction), + '{} (dbm)'.format(type_name), + 'Throughput (Mbps)', + data, + range_list, + ) return file_name - def draw_rssi_vs_att_figure(self, path:str, ap_ssid:str) -> str: + def draw_rssi_vs_att_figure(self, path: str, ap_ssid: str) -> str: """ :param path: folder to save figure. make sure the folder is already created. :param ap_ssid: ap to use @@ -201,18 +217,14 @@ class TestResult(object): file_name = 'AttVsRSSI.html' else: file_name = 'AttVsRSSI.html' - LineChart.draw_line_chart(os.path.join(path, file_name), - 'Att Vs RSSI', - 'Att (dbm)', - 'RSSI (dbm)', - self.att_rssi_map, - self.ATT_RANGE) + LineChart.draw_line_chart( + os.path.join(path, file_name), 'Att Vs RSSI', 'Att (dbm)', 'RSSI (dbm)', self.att_rssi_map, self.ATT_RANGE + ) return file_name def get_best_throughput(self) -> Any: - """ get the best throughput during test """ - best_for_aps = [max(self.throughput_by_att[ap_ssid].values()) - for ap_ssid in self.throughput_by_att] + """get the best throughput during test""" + best_for_aps = [max(self.throughput_by_att[ap_ssid].values()) for ap_ssid in self.throughput_by_att] return max(best_for_aps) def __str__(self) -> str: @@ -224,8 +236,9 @@ class TestResult(object): 3. min free heap size during test """ if self.throughput_by_att: - ret = '[{}_{}][{}]: {}\r\n\r\n'.format(self.proto, self.direction, self.config_name, - 'Fail' if self.error_list else 'Success') + ret = '[{}_{}][{}]: {}\r\n\r\n'.format( + self.proto, self.direction, self.config_name, 'Fail' if self.error_list else 'Success' + ) ret += 'Performance for each AP:\r\n' for ap_ssid in self.throughput_by_att: ret += '[{}]: {:.02f} Mbps\r\n'.format(ap_ssid, max(self.throughput_by_att[ap_ssid].values())) @@ -237,10 +250,18 @@ class TestResult(object): class IperfTestUtility(object): - """ iperf test implementation """ + """iperf test implementation""" - def __init__(self, dut:Dut, config_name:str, ap_ssid:str, ap_password:str, - pc_nic_ip:str, pc_iperf_log_file:str, test_result:Any=None) -> None: + def __init__( + self, + dut: Dut, + config_name: str, + ap_ssid: str, + ap_password: str, + pc_nic_ip: str, + pc_iperf_log_file: str, + test_result: Any = None, + ) -> None: self.config_name = config_name self.dut = dut @@ -261,7 +282,7 @@ class IperfTestUtility(object): 'udp_rx': TestResult('udp', 'rx', config_name), } - def setup(self) -> Tuple[str,int]: + def setup(self) -> Tuple[str, int]: """ setup iperf test: @@ -281,8 +302,7 @@ class IperfTestUtility(object): self.dut.write('sta_scan {}'.format(self.ap_ssid)) for _ in range(SCAN_RETRY_COUNT): try: - rssi = int(self.dut.expect(r'\[{}]\[rssi=(-\d+)]'.format(self.ap_ssid), - timeout=SCAN_TIMEOUT).group(1)) + rssi = int(self.dut.expect(r'\[{}]\[rssi=(-\d+)]'.format(self.ap_ssid), timeout=SCAN_TIMEOUT).group(1)) break except pexpect.TIMEOUT: continue @@ -292,11 +312,11 @@ class IperfTestUtility(object): dut_ip = self.dut.expect(r'sta ip: ([\d.]+), mask: ([\d.]+), gw: ([\d.]+)').group(1) return dut_ip, rssi - def _save_test_result(self, test_case:str, raw_data:str, att:int, rssi:int, heap_size:int) -> Any: + def _save_test_result(self, test_case: str, raw_data: str, att: int, rssi: int, heap_size: int) -> Any: return self.test_result[test_case].add_result(raw_data, self.ap_ssid, att, rssi, heap_size) - def _test_once(self, proto:str, direction:str, bw_limit:int) -> Tuple[str, int, int]: - """ do measure once for one type """ + def _test_once(self, proto: str, direction: str, bw_limit: int) -> Tuple[str, int, int]: + """do measure once for one type""" # connect and scan to get RSSI dut_ip, rssi = self.setup() @@ -307,17 +327,21 @@ class IperfTestUtility(object): if direction == 'tx': with open(PC_IPERF_TEMP_LOG_FILE, 'w') as f: if proto == 'tcp': - process = subprocess.Popen(['iperf', '-s', '-B', self.pc_nic_ip, - '-t', str(TEST_TIME), '-i', '1', '-f', 'm'], - stdout=f, stderr=f) + process = subprocess.Popen( + ['iperf', '-s', '-B', self.pc_nic_ip, '-t', str(TEST_TIME), '-i', '1', '-f', 'm'], + stdout=f, + stderr=f, + ) if bw_limit > 0: self.dut.write('iperf -c {} -i 1 -t {} -b {}'.format(self.pc_nic_ip, TEST_TIME, bw_limit)) else: self.dut.write('iperf -c {} -i 1 -t {}'.format(self.pc_nic_ip, TEST_TIME)) else: - process = subprocess.Popen(['iperf', '-s', '-u', '-B', self.pc_nic_ip, - '-t', str(TEST_TIME), '-i', '1', '-f', 'm'], - stdout=f, stderr=f) + process = subprocess.Popen( + ['iperf', '-s', '-u', '-B', self.pc_nic_ip, '-t', str(TEST_TIME), '-i', '1', '-f', 'm'], + stdout=f, + stderr=f, + ) if bw_limit > 0: self.dut.write('iperf -c {} -u -i 1 -t {} -b {}'.format(self.pc_nic_ip, TEST_TIME, bw_limit)) else: @@ -343,11 +367,15 @@ class IperfTestUtility(object): # compatible with old iperf example binary logging.info('create iperf tcp server fail') if bw_limit > 0: - process = subprocess.Popen(['iperf', '-c', dut_ip, '-b', str(bw_limit) + 'm', - '-t', str(TEST_TIME), '-f', 'm'], stdout=f, stderr=f) + process = subprocess.Popen( + ['iperf', '-c', dut_ip, '-b', str(bw_limit) + 'm', '-t', str(TEST_TIME), '-f', 'm'], + stdout=f, + stderr=f, + ) else: - process = subprocess.Popen(['iperf', '-c', dut_ip, - '-t', str(TEST_TIME), '-f', 'm'], stdout=f, stderr=f) + process = subprocess.Popen( + ['iperf', '-c', dut_ip, '-t', str(TEST_TIME), '-f', 'm'], stdout=f, stderr=f + ) for _ in range(TEST_TIMEOUT): if process.poll() is not None: break @@ -363,8 +391,11 @@ class IperfTestUtility(object): except pexpect.TIMEOUT: # compatible with old iperf example binary logging.info('create iperf udp server fail') - process = subprocess.Popen(['iperf', '-c', dut_ip, '-u', '-b', str(bw_limit) + 'm', - '-t', str(TEST_TIME), '-f', 'm'], stdout=f, stderr=f) + process = subprocess.Popen( + ['iperf', '-c', dut_ip, '-u', '-b', str(bw_limit) + 'm', '-t', str(TEST_TIME), '-f', 'm'], + stdout=f, + stderr=f, + ) for _ in range(TEST_TIMEOUT): if process.poll() is not None: break @@ -376,7 +407,9 @@ class IperfTestUtility(object): stop_bw = 100 n = 10 step = int((stop_bw - start_bw) / n) - self.dut.write('iperf -s -u -i 1 -t {}'.format(TEST_TIME + 4 * (n + 1))) # 4 sec for each bw step instance start/stop + self.dut.write( + 'iperf -s -u -i 1 -t {}'.format(TEST_TIME + 4 * (n + 1)) + ) # 4 sec for each bw step instance start/stop # wait until DUT TCP server created try: self.dut.expect('Socket bound', timeout=5) @@ -384,8 +417,22 @@ class IperfTestUtility(object): # compatible with old iperf example binary logging.info('create iperf udp server fail') for bandwidth in range(start_bw, stop_bw, step): - process = subprocess.Popen(['iperf', '-c', dut_ip, '-u', '-b', str(bandwidth) + 'm', - '-t', str(TEST_TIME / (n + 1)), '-f', 'm'], stdout=f, stderr=f) + process = subprocess.Popen( + [ + 'iperf', + '-c', + dut_ip, + '-u', + '-b', + str(bandwidth) + 'm', + '-t', + str(TEST_TIME / (n + 1)), + '-f', + 'm', + ], + stdout=f, + stderr=f, + ) for _ in range(TEST_TIMEOUT): if process.poll() is not None: break @@ -402,18 +449,21 @@ class IperfTestUtility(object): # save PC iperf logs to console with open(self.pc_iperf_log_file, 'a+') as f: - f.write('## [{}] `{}`\r\n##### {}' - .format(self.config_name, - '{}_{}'.format(proto, direction), - time.strftime('%m-%d %H:%M:%S', time.localtime(time.time())))) + f.write( + '## [{}] `{}`\r\n##### {}'.format( + self.config_name, + '{}_{}'.format(proto, direction), + time.strftime('%m-%d %H:%M:%S', time.localtime(time.time())), + ) + ) f.write('\r\n```\r\n\r\n' + pc_raw_data + '\r\n```\r\n') self.dut.write('heap') - heap_size = self.dut.expect(r'min heap size: (\d+)\D').group(1) + heap_size = self.dut.expect(r'min heap size: (\d+)\D', timeout=120).group(1) # return server raw data (for parsing test results) and RSSI return server_raw_data, rssi, heap_size - def run_test(self, proto:str, direction:str, atten_val:int, bw_limit:int) -> None: + def run_test(self, proto: str, direction: str, atten_val: int, bw_limit: int) -> None: """ run test for one type, with specified atten_value and save the test result @@ -426,11 +476,14 @@ class IperfTestUtility(object): heap_size = INVALID_HEAP_SIZE try: server_raw_data, rssi, heap_size = self._test_once(proto, direction, bw_limit) - throughput = self._save_test_result('{}_{}'.format(proto, direction), - server_raw_data, atten_val, - rssi, heap_size) - logging.info('[{}][{}_{}][{}][{}]: {:.02f}' - .format(self.config_name, proto, direction, rssi, self.ap_ssid, throughput)) + throughput = self._save_test_result( + '{}_{}'.format(proto, direction), server_raw_data, atten_val, rssi, heap_size + ) + logging.info( + '[{}][{}_{}][{}][{}]: {:.02f}'.format( + self.config_name, proto, direction, rssi, self.ap_ssid, throughput + ) + ) self.lowest_rssi_scanned = min(self.lowest_rssi_scanned, rssi) except (ValueError, IndexError): self._save_test_result('{}_{}'.format(proto, direction), '', atten_val, rssi, heap_size) @@ -439,7 +492,7 @@ class IperfTestUtility(object): self.fail_to_scan += 1 logging.info('Fail to scan AP.') - def run_all_cases(self, atten_val:int, bw_limit:int) -> None: + def run_all_cases(self, atten_val: int, bw_limit: int) -> None: """ run test for all types (udp_tx, udp_rx, tcp_tx, tcp_rx). @@ -452,7 +505,8 @@ class IperfTestUtility(object): self.run_test('udp', 'rx', atten_val, bw_limit) if self.fail_to_scan > 10: logging.info( - 'Fail to scan AP for more than 10 times. Lowest RSSI scanned is {}'.format(self.lowest_rssi_scanned)) + 'Fail to scan AP for more than 10 times. Lowest RSSI scanned is {}'.format(self.lowest_rssi_scanned) + ) raise AssertionError def wait_ap_power_on(self) -> bool: @@ -467,8 +521,7 @@ class IperfTestUtility(object): for _ in range(WAIT_AP_POWER_ON_TIMEOUT // SCAN_TIMEOUT): try: self.dut.write('scan {}'.format(self.ap_ssid)) - self.dut.expect(r'\[{}]\[rssi=(-\d+)]'.format(self.ap_ssid), - timeout=SCAN_TIMEOUT) + self.dut.expect(r'\[{}]\[rssi=(-\d+)]'.format(self.ap_ssid), timeout=SCAN_TIMEOUT) ret = True break except pexpect.TIMEOUT: diff --git a/tools/cmake/toolchain-esp32.cmake b/tools/cmake/toolchain-esp32.cmake index 5bf1acefaa..7c6759c862 100644 --- a/tools/cmake/toolchain-esp32.cmake +++ b/tools/cmake/toolchain-esp32.cmake @@ -7,17 +7,17 @@ set(CMAKE_CXX_COMPILER xtensa-esp32-elf-g++) set(CMAKE_ASM_COMPILER xtensa-esp32-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX xtensa-esp32-elf-) -remove_duplicated_flags("-mlongcalls -Wno-frame-address \ - -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero \ - -fno-builtin-stpcpy -fno-builtin-strncpy \ - ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS + "-mlongcalls -Wno-frame-address -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero") + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-mlongcalls -Wno-frame-address \ - -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero \ - -fno-builtin-stpcpy -fno-builtin-strncpy \ - ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("-mlongcalls ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "ASM Compiler Base Flags" FORCE) + remove_duplicated_flags("-nostartfiles ${CMAKE_EXE_LINKER_FLAGS}" UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32c2.cmake b/tools/cmake/toolchain-esp32c2.cmake index d3a8b43dac..9182080127 100644 --- a/tools/cmake/toolchain-esp32c2.cmake +++ b/tools/cmake/toolchain-esp32c2.cmake @@ -7,11 +7,17 @@ set(CMAKE_CXX_COMPILER riscv32-esp-elf-g++) set(CMAKE_ASM_COMPILER riscv32-esp-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX riscv32-esp-elf-) -remove_duplicated_flags("-march=rv32imc_zicsr_zifencei ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-march=rv32imc_zicsr_zifencei") + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-march=rv32imc_zicsr_zifencei ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("-nostartfiles -march=rv32imc_zicsr_zifencei ${CMAKE_EXE_LINKER_FLAGS}" +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) +set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "Asm Compiler Base Flags" FORCE) + +remove_duplicated_flags("-nostartfiles ${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32c3.cmake b/tools/cmake/toolchain-esp32c3.cmake index e263a82e47..9182080127 100644 --- a/tools/cmake/toolchain-esp32c3.cmake +++ b/tools/cmake/toolchain-esp32c3.cmake @@ -7,13 +7,17 @@ set(CMAKE_CXX_COMPILER riscv32-esp-elf-g++) set(CMAKE_ASM_COMPILER riscv32-esp-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX riscv32-esp-elf-) -remove_duplicated_flags("-march=rv32imc_zicsr_zifencei ${CMAKE_C_FLAGS}" - UNIQ_CMAKE_C_FLAGS) +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-march=rv32imc_zicsr_zifencei") + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-march=rv32imc_zicsr_zifencei ${CMAKE_CXX_FLAGS}" - UNIQ_CMAKE_CXX_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("-nostartfiles -march=rv32imc_zicsr_zifencei ${CMAKE_EXE_LINKER_FLAGS}" +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) +set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "Asm Compiler Base Flags" FORCE) + +remove_duplicated_flags("-nostartfiles ${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32c5.cmake b/tools/cmake/toolchain-esp32c5.cmake index d0622555a5..7ca12da3b4 100644 --- a/tools/cmake/toolchain-esp32c5.cmake +++ b/tools/cmake/toolchain-esp32c5.cmake @@ -7,11 +7,17 @@ set(CMAKE_CXX_COMPILER riscv32-esp-elf-g++) set(CMAKE_ASM_COMPILER riscv32-esp-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX riscv32-esp-elf-) -remove_duplicated_flags("-march=rv32imac_zicsr_zifencei ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-march=rv32imac_zicsr_zifencei_zaamo_zalrsc") + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-march=rv32imac_zicsr_zifencei ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("-nostartfiles -march=rv32imac_zicsr_zifencei ${CMAKE_EXE_LINKER_FLAGS}" +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) +set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "Asm Compiler Base Flags" FORCE) + +remove_duplicated_flags("-nostartfiles ${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32c6.cmake b/tools/cmake/toolchain-esp32c6.cmake index d0622555a5..7ca12da3b4 100644 --- a/tools/cmake/toolchain-esp32c6.cmake +++ b/tools/cmake/toolchain-esp32c6.cmake @@ -7,11 +7,17 @@ set(CMAKE_CXX_COMPILER riscv32-esp-elf-g++) set(CMAKE_ASM_COMPILER riscv32-esp-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX riscv32-esp-elf-) -remove_duplicated_flags("-march=rv32imac_zicsr_zifencei ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-march=rv32imac_zicsr_zifencei_zaamo_zalrsc") + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-march=rv32imac_zicsr_zifencei ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("-nostartfiles -march=rv32imac_zicsr_zifencei ${CMAKE_EXE_LINKER_FLAGS}" +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) +set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "Asm Compiler Base Flags" FORCE) + +remove_duplicated_flags("-nostartfiles ${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32c61.cmake b/tools/cmake/toolchain-esp32c61.cmake index d0622555a5..7ca12da3b4 100644 --- a/tools/cmake/toolchain-esp32c61.cmake +++ b/tools/cmake/toolchain-esp32c61.cmake @@ -7,11 +7,17 @@ set(CMAKE_CXX_COMPILER riscv32-esp-elf-g++) set(CMAKE_ASM_COMPILER riscv32-esp-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX riscv32-esp-elf-) -remove_duplicated_flags("-march=rv32imac_zicsr_zifencei ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-march=rv32imac_zicsr_zifencei_zaamo_zalrsc") + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-march=rv32imac_zicsr_zifencei ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("-nostartfiles -march=rv32imac_zicsr_zifencei ${CMAKE_EXE_LINKER_FLAGS}" +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) +set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "Asm Compiler Base Flags" FORCE) + +remove_duplicated_flags("-nostartfiles ${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32h2.cmake b/tools/cmake/toolchain-esp32h2.cmake index d0622555a5..7ca12da3b4 100644 --- a/tools/cmake/toolchain-esp32h2.cmake +++ b/tools/cmake/toolchain-esp32h2.cmake @@ -7,11 +7,17 @@ set(CMAKE_CXX_COMPILER riscv32-esp-elf-g++) set(CMAKE_ASM_COMPILER riscv32-esp-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX riscv32-esp-elf-) -remove_duplicated_flags("-march=rv32imac_zicsr_zifencei ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-march=rv32imac_zicsr_zifencei_zaamo_zalrsc") + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-march=rv32imac_zicsr_zifencei ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("-nostartfiles -march=rv32imac_zicsr_zifencei ${CMAKE_EXE_LINKER_FLAGS}" +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) +set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "Asm Compiler Base Flags" FORCE) + +remove_duplicated_flags("-nostartfiles ${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32h21.cmake b/tools/cmake/toolchain-esp32h21.cmake index 6415daa59b..7ca12da3b4 100644 --- a/tools/cmake/toolchain-esp32h21.cmake +++ b/tools/cmake/toolchain-esp32h21.cmake @@ -7,12 +7,17 @@ set(CMAKE_CXX_COMPILER riscv32-esp-elf-g++) set(CMAKE_ASM_COMPILER riscv32-esp-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX riscv32-esp-elf-) -remove_duplicated_flags("-march=rv32imac_zicsr_zifencei ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-march=rv32imac_zicsr_zifencei_zaamo_zalrsc") + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-march=rv32imac_zicsr_zifencei ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("-nostartfiles -march=rv32imac_zicsr_zifencei --specs=nosys.specs \ - ${CMAKE_EXE_LINKER_FLAGS}" +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) +set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "Asm Compiler Base Flags" FORCE) + +remove_duplicated_flags("-nostartfiles ${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32h4.cmake b/tools/cmake/toolchain-esp32h4.cmake index c768ed0c75..e8ec46654f 100644 --- a/tools/cmake/toolchain-esp32h4.cmake +++ b/tools/cmake/toolchain-esp32h4.cmake @@ -7,14 +7,17 @@ set(CMAKE_CXX_COMPILER riscv32-esp-elf-g++) set(CMAKE_ASM_COMPILER riscv32-esp-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX riscv32-esp-elf-) -remove_duplicated_flags("-march=rv32imafc_zicsr_zifencei -mabi=ilp32f ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) -set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-march=rv32imafc_zicsr_zifencei -mabi=ilp32f ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) -set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("-march=rv32imafc_zicsr_zifencei -mabi=ilp32f ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) -set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "Asm Compiler Base Flags" FORCE) +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-march=rv32imafc_zicsr_zifencei_zaamo_zalrsc_xespdsp -mabi=ilp32f") -remove_duplicated_flags("-nostartfiles -march=rv32imafc_zicsr_zifencei -mabi=ilp32f --specs=nosys.specs \ - ${CMAKE_EXE_LINKER_FLAGS}" +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) +set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) +set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "Asm Compiler Base Flags" FORCE) + +remove_duplicated_flags("-nostartfiles ${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32p4.cmake b/tools/cmake/toolchain-esp32p4.cmake index 631cacff54..b546ed96fd 100644 --- a/tools/cmake/toolchain-esp32p4.cmake +++ b/tools/cmake/toolchain-esp32p4.cmake @@ -7,13 +7,17 @@ set(CMAKE_CXX_COMPILER riscv32-esp-elf-g++) set(CMAKE_ASM_COMPILER riscv32-esp-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX riscv32-esp-elf-) -remove_duplicated_flags("-march=rv32imafc_zicsr_zifencei_xesppie -mabi=ilp32f ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) -set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-march=rv32imafc_zicsr_zifencei_xesppie -mabi=ilp32f ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) -set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("-march=rv32imafc_zicsr_zifencei_xesppie -mabi=ilp32f ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) -set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "Asm Compiler Base Flags" FORCE) +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-march=rv32imafc_zicsr_zifencei_zaamo_zalrsc_xespv_xesploop -mabi=ilp32f") -remove_duplicated_flags("-nostartfiles -march=rv32imafc_zicsr_zifencei_xesppie -mabi=ilp32f ${CMAKE_EXE_LINKER_FLAGS}" +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) +set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) +set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "Asm Compiler Base Flags" FORCE) + +remove_duplicated_flags("-nostartfiles ${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32s2.cmake b/tools/cmake/toolchain-esp32s2.cmake index 77b71113d9..2e5fce33dd 100644 --- a/tools/cmake/toolchain-esp32s2.cmake +++ b/tools/cmake/toolchain-esp32s2.cmake @@ -7,17 +7,16 @@ set(CMAKE_CXX_COMPILER xtensa-esp32s2-elf-g++) set(CMAKE_ASM_COMPILER xtensa-esp32s2-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX xtensa-esp32s2-elf-) -remove_duplicated_flags("-mlongcalls \ - -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero \ - -fno-builtin-stpcpy -fno-builtin-strncpy \ - ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-mlongcalls -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero") + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-mlongcalls \ - -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero \ - -fno-builtin-stpcpy -fno-builtin-strncpy \ - ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("-mlongcalls ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "ASM Compiler Base Flags" FORCE) + remove_duplicated_flags("-nostartfiles ${CMAKE_EXE_LINKER_FLAGS}" UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32s3.cmake b/tools/cmake/toolchain-esp32s3.cmake index f3ba9f798b..0210ecf032 100644 --- a/tools/cmake/toolchain-esp32s3.cmake +++ b/tools/cmake/toolchain-esp32s3.cmake @@ -7,17 +7,16 @@ set(CMAKE_CXX_COMPILER xtensa-esp32s3-elf-g++) set(CMAKE_ASM_COMPILER xtensa-esp32s3-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX xtensa-esp32s3-elf-) -remove_duplicated_flags("-mlongcalls \ - -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero \ - -fno-builtin-stpcpy -fno-builtin-strncpy \ - ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +set(_CMAKE_TOOLCHAIN_COMMON_FLAGS "-mlongcalls -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero") + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-mlongcalls \ - -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero \ - -fno-builtin-stpcpy -fno-builtin-strncpy \ - ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) -remove_duplicated_flags("-mlongcalls ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) + +remove_duplicated_flags("${_CMAKE_TOOLCHAIN_COMMON_FLAGS} ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "ASM Compiler Base Flags" FORCE) + remove_duplicated_flags("-nostartfiles ${CMAKE_EXE_LINKER_FLAGS}" UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${UNIQ_CMAKE_SAFE_EXE_LINKER_FLAGS}" CACHE STRING "Linker Base Flags" FORCE) diff --git a/tools/test_apps/storage/std_filesystem/main/test_ops.cpp b/tools/test_apps/storage/std_filesystem/main/test_ops.cpp index 12d63c5265..eda5ea49fa 100644 --- a/tools/test_apps/storage/std_filesystem/main/test_ops.cpp +++ b/tools/test_apps/storage/std_filesystem/main/test_ops.cpp @@ -140,8 +140,7 @@ public: } std::filesystem::copy_file("/test/file", "/test/file_size"); CHECK(std::filesystem::file_size("/test/file_size") == 11); - // Not supported: libstdc++ has to be built with _GLIBCXX_HAVE_TRUNCATE - CHECK_THROWS(std::filesystem::resize_file("/test/file_size", 20)); + std::filesystem::resize_file("/test/file_size", 20); CHECK(std::filesystem::remove("/test/file_size")); } diff --git a/tools/test_apps/system/panic/main/test_memprot.c b/tools/test_apps/system/panic/main/test_memprot.c index 46116949cb..47c3a1b434 100644 --- a/tools/test_apps/system/panic/main/test_memprot.c +++ b/tools/test_apps/system/panic/main/test_memprot.c @@ -27,6 +27,11 @@ extern int _iram_text_end; #define ALIGN_UP_TO_MMU_PAGE_SIZE(addr) (((addr) + (SOC_MMU_PAGE_SIZE) - 1) & ~((SOC_MMU_PAGE_SIZE) - 1)) +__attribute__((noinline)) +static void run_function(void (*test_addr)(void)) { + test_addr(); +} + /* NOTE: Naming conventions for RTC_FAST_MEM are * different for ESP32-C3 and other RISC-V targets */ @@ -121,10 +126,9 @@ static DRAM_ATTR uint8_t s_dram_buf[1024]; void test_dram_reg1_execute_violation(void) { memcpy(&s_dram_buf, &foo_d, sizeof(s_dram_buf)); - void (*func_ptr)(void); - func_ptr = (void(*)(void))&s_dram_buf; + void *test_addr = &s_dram_buf; printf("DRAM: Execute operation | Address: %p\n", &s_dram_buf); - func_ptr(); + run_function(test_addr); } /* DRAM: Heap region */ @@ -136,9 +140,8 @@ void test_dram_reg2_execute_violation(void) printf("DRAM: Execute operation | Address: %p\n", instr); memcpy(instr, &foo_d, 1024); - void (*func_ptr)(void); - func_ptr = (void(*)(void))instr; - func_ptr(); + void *test_addr = instr; + run_function(test_addr); } /* ---------------------------------------------------- RTC Violation Checks ---------------------------------------------------- */ @@ -156,28 +159,28 @@ static RTC_IRAM_ATTR void foo_f(void) void test_rtc_fast_reg1_execute_violation(void) { #if CONFIG_IDF_TARGET_ARCH_RISCV - void (*test_addr)(void) = (void(*)(void))((uint32_t)&_rtc_fast_start); + void *test_addr = &_rtc_fast_start; #else - void (*test_addr)(void) = (void(*)(void))((uint32_t)&_rtc_text_start); + void *test_addr = &_rtc_text_start; #endif printf("RTC_MEM (Fast): Execute operation | Address: %p\n", test_addr); - test_addr(); + run_function(test_addr); } /* RTC_FAST_MEM: .text section boundary */ void test_rtc_fast_reg2_execute_violation(void) { - void (*test_addr)(void) = (void(*)(void))((uint32_t)&_rtc_text_end - 0x04); + void *test_addr = &_rtc_text_end - 1; printf("RTC_MEM (Fast): Execute operation | Address: %p\n", test_addr); - test_addr(); + run_function(test_addr); } /* RTC_FAST_MEM: .data section */ void test_rtc_fast_reg3_execute_violation(void) { - void (*test_addr)(void) = (void(*)(void))((uint32_t)&_rtc_force_fast_start + 0x04); + void *test_addr = &_rtc_force_fast_start + 1; printf("RTC_MEM (Fast): Execute operation | Address: %p\n", test_addr); - test_addr(); + run_function(test_addr); } #endif @@ -193,17 +196,17 @@ static RTC_SLOW_ATTR void foo_s(void) /* RTC_SLOW_MEM: Data tagged with RTC_SLOW_ATTR */ void test_rtc_slow_reg1_execute_violation(void) { - void (*test_addr)(void) = (void(*)(void))((uint32_t)&_rtc_force_slow_start); + void *test_addr = &_rtc_force_slow_start; printf("RTC_MEM (Slow): Execute operation | Address: %p\n", test_addr); - test_addr(); + run_function(test_addr); } /* RTC_SLOW_MEM: Region start */ void test_rtc_slow_reg2_execute_violation(void) { - void (*test_addr)(void) = (void(*)(void))((uint32_t)&_rtc_data_start); + void *test_addr = &_rtc_data_start; printf("RTC_MEM (Slow): Execute operation | Address: %p\n", test_addr); - test_addr(); + run_function(test_addr); } #endif @@ -243,10 +246,9 @@ void test_drom_reg_write_violation(void) void test_drom_reg_execute_violation(void) { - printf("Flash (DROM): Execute operation | Address: %p\n", foo_buf); - void (*func_ptr)(void); - func_ptr = (void(*)(void))foo_buf; - func_ptr(); + void *test_addr = (void *)foo_buf; + printf("Flash (DROM): Execute operation | Address: %p\n", test_addr); + run_function(test_addr); } // Check if the memory alignment gaps added to the heap are correctly configured @@ -255,9 +257,9 @@ void test_spiram_xip_irom_alignment_reg_execute_violation(void) { extern int _instruction_reserved_end; if (ALIGN_UP_TO_MMU_PAGE_SIZE((uint32_t)(&_instruction_reserved_end)) - (uint32_t)(&_instruction_reserved_end) >= 4) { - void (*test_addr)(void) = (void(*)(void))((uint32_t)(&_instruction_reserved_end + 0x4)); + void *test_addr = &_instruction_reserved_end + 1; printf("SPIRAM (IROM): Execute operation | Address: %p\n", test_addr); - test_addr(); + run_function(test_addr); } else { printf("SPIRAM (IROM): IROM alignment gap not added into heap\n"); } @@ -270,9 +272,9 @@ void test_spiram_xip_drom_alignment_reg_execute_violation(void) { extern int _rodata_reserved_end; if (ALIGN_UP_TO_MMU_PAGE_SIZE((uint32_t)(&_rodata_reserved_end)) - (uint32_t)(&_rodata_reserved_end) >= 4) { - void (*test_addr)(void) = (void(*)(void))((uint32_t)(&_rodata_reserved_end + 0x4)); + void *test_addr = &_rodata_reserved_end + 0x4; printf("SPIRAM (DROM): Execute operation | Address: %p\n", test_addr); - test_addr(); + run_function(test_addr); } else { printf("SPIRAM (DROM): DROM alignment gap not added into heap\n"); } @@ -290,9 +292,8 @@ void test_invalid_memory_region_write_violation(void) void test_invalid_memory_region_execute_violation(void) { - void (*func_ptr)(void); - func_ptr = (void(*)(void))(SOC_DRAM_HIGH + 0x40); - printf("Execute operation | Address: %p\n", func_ptr); - func_ptr(); + void *test_addr = (void *)(SOC_DRAM_HIGH + 0x40); + printf("Execute operation | Address: %p\n", test_addr); + run_function(test_addr); } #endif diff --git a/tools/test_apps/system/panic/pytest_panic.py b/tools/test_apps/system/panic/pytest_panic.py index 85237ccff8..a98bc8fdd5 100644 --- a/tools/test_apps/system/panic/pytest_panic.py +++ b/tools/test_apps/system/panic/pytest_panic.py @@ -113,13 +113,15 @@ def get_default_backtrace(config: str) -> List[str]: return [config, 'app_main', 'main_task', 'vPortTaskWrapper'] -def expect_coredump_flash_write_logs(dut: PanicTestDut, config: str) -> None: +def expect_coredump_flash_write_logs(dut: PanicTestDut, config: str, check_cpu_reset: Optional[bool] = True) -> None: dut.expect_exact('Save core dump to flash...') if 'extram_stack' in config: dut.expect_exact('Backing up stack @') dut.expect_exact('Restoring stack') dut.expect_exact('Core dump has been saved to flash.') dut.expect(dut.REBOOT) + if check_cpu_reset: + dut.expect_cpu_reset() def expect_coredump_uart_write_logs(dut: PanicTestDut, check_cpu_reset: Optional[bool] = True) -> Any: @@ -173,8 +175,9 @@ def common_test( dut.process_coredump_uart(coredump_base64, expected_coredump) check_cpu_reset = False # CPU reset is already checked in expect_coredump_uart_write_logs elif 'flash' in config: - expect_coredump_flash_write_logs(dut, config) + expect_coredump_flash_write_logs(dut, config, check_cpu_reset) dut.process_coredump_flash(expected_coredump) + check_cpu_reset = False # CPU reset is already checked in expect_coredump_flash_write_logs elif 'panic' in config: dut.expect(dut.REBOOT, timeout=60) diff --git a/tools/tools.json b/tools/tools.json index 94f8366f43..0b69e58149 100644 --- a/tools/tools.json +++ b/tools/tools.json @@ -182,51 +182,51 @@ "versions": [ { "linux-amd64": { - "sha256": "e3e6dcf3d275c3c9ab0e4c8a9d93fd10e7efc035d435460576c9d95b4140c676", - "size": 174652716, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-x86_64-linux-gnu.tar.xz" + "sha256": "45d60317d7a35414ce7fe4c900e636d90c4b0e16d85f2a5c03b523b4efadf3bb", + "size": 125612316, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/xtensa-esp-elf-15.1.0_20250607-x86_64-linux-gnu.tar.xz" }, "linux-arm64": { - "sha256": "ac2b311dc0003386425086bfc813bf2aeb3cdf3b117845802df6ebef5f69955f", - "size": 176920772, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-aarch64-linux-gnu.tar.xz" + "sha256": "22a2c9c4a4e6954ba024330266e10ab3eb980614b94859be5ae88c95d781a8bc", + "size": 119180760, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/xtensa-esp-elf-15.1.0_20250607-aarch64-linux-gnu.tar.xz" }, "linux-armel": { - "sha256": "c54c2877582070115fe6f4870a88a4db4f2f945becf2d70bb1f71e5ab1cac673", - "size": 167715268, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-arm-linux-gnueabi.tar.xz" + "sha256": "31f7b786416893ee4a095ed23cb82183f4e0172c19736a104d9ef0223ee3047c", + "size": 121484960, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/xtensa-esp-elf-15.1.0_20250607-arm-linux-gnueabi.tar.xz" }, "linux-armhf": { - "sha256": "04addfee56b45d62b6980967c71fafd6aec2be6dee6d8501e9db70345a6179d2", - "size": 168451936, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-arm-linux-gnueabihf.tar.xz" + "sha256": "8bda79cb1287c0d7e12fee8a0d32b85ba9c6801ccb7128d95d324152bd0ce49f", + "size": 116521168, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/xtensa-esp-elf-15.1.0_20250607-arm-linux-gnueabihf.tar.xz" }, "linux-i686": { - "sha256": "acf3fb7e37274413cd8c812894a6a0e3a0b3a78e9d5b533893d304008cc996c2", - "size": 178264512, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-i586-linux-gnu.tar.xz" + "sha256": "787e9779d507af185f7bb104286b1a6373e5b7d483bc67a7e22db225b4a54522", + "size": 127704840, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/xtensa-esp-elf-15.1.0_20250607-i586-linux-gnu.tar.xz" }, "macos": { - "sha256": "1ca7a93825d5b84f6547fa73e6174acadb9af5c877f365e50e176936784383ea", - "size": 182782108, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-x86_64-apple-darwin.tar.xz" + "sha256": "07200c2e6d4db648762f25c91806a3a38c994231f5b7f2752386825d09aa0c3c", + "size": 126819660, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/xtensa-esp-elf-15.1.0_20250607-x86_64-apple-darwin.tar.xz" }, "macos-arm64": { - "sha256": "b9732bb3cdcd6a50420c25eb9a8d90eb1216a0a0a274c8ffd4c2037167b5081f", - "size": 167948176, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-aarch64-apple-darwin.tar.xz" + "sha256": "0cd6922eb3414a2011099db5095547dfea9c829ed83a0950a73a585afa844fde", + "size": 112300796, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/xtensa-esp-elf-15.1.0_20250607-aarch64-apple-darwin.tar.xz" }, - "name": "esp-14.2.0_20241119", + "name": "esp-15.1.0_20250607", "status": "recommended", "win32": { - "sha256": "b30e450e0af279783c54a9ae77c3b367dd556b78eda930a92ec7b784a74c28c8", - "size": 382457717, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-i686-w64-mingw32.zip" + "sha256": "07b33dea9729f7b244f46b28206dd685de5a6fd4773067dd601e27bde37c7e72", + "size": 315612119, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/xtensa-esp-elf-15.1.0_20250607-i686-w64-mingw32.zip" }, "win64": { - "sha256": "62ae704777d73c30689efff6e81178632a1ca44d1a2d60f4621eb997e040e028", - "size": 386316009, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-x86_64-w64-mingw32.zip" + "sha256": "2c307163a2bb366acc9c5c637035dc1f6bbd03f8c4407cff40cd9a4e016b14d0", + "size": 317468441, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/xtensa-esp-elf-15.1.0_20250607-x86_64-w64-mingw32.zip" } } ] @@ -395,51 +395,51 @@ "versions": [ { "linux-amd64": { - "sha256": "7faaa86d272f3e43c233f8a5ffeba327673224a752c2eb72394655d5e7950000", - "size": 298069324, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-x86_64-linux-gnu.tar.xz" + "sha256": "9bfe9b4fe08bd07614d085482301f5206a15a075ce4e9cf1c9c3d9d3e0d6b110", + "size": 267310332, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/riscv32-esp-elf-15.1.0_20250607-x86_64-linux-gnu.tar.xz" }, "linux-arm64": { - "sha256": "762eac9ee3d909cf806dcbd26feeb4a83061640d1afea39bc36efdb566b77b03", - "size": 294868260, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-aarch64-linux-gnu.tar.xz" + "sha256": "5089bee512dc575ebb726661edb1ee99923630bfacc43d94ea080c488e6b009f", + "size": 264000536, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/riscv32-esp-elf-15.1.0_20250607-aarch64-linux-gnu.tar.xz" }, "linux-armel": { - "sha256": "f5b92a7f91c97e11f8c871cffbb040310a3cea1049e967621e5dfc0ff1a601bc", - "size": 296925780, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-arm-linux-gnueabi.tar.xz" + "sha256": "83d4f1125e5f9b79e34afb411b582808a985f82a3ac64981583039d9dd080cad", + "size": 256938340, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/riscv32-esp-elf-15.1.0_20250607-arm-linux-gnueabi.tar.xz" }, "linux-armhf": { - "sha256": "14e7962cb4d00ef5c45bc2df2d5f7f2af796d4b68def9f9861d82ac05bb1831f", - "size": 297745292, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-arm-linux-gnueabihf.tar.xz" + "sha256": "467326b387dbd3defee6c573afd423063d5e7e77a94586beab4c541d2c260ba7", + "size": 262701388, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/riscv32-esp-elf-15.1.0_20250607-arm-linux-gnueabihf.tar.xz" }, "linux-i686": { - "sha256": "39f12f204d3aef7b0c4f3f3e58846ff1ee0a90526db56e91d11bc1c093b645c0", - "size": 304492976, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-i586-linux-gnu.tar.xz" + "sha256": "c4151af6cfc62c9a1b6c5d97a4f73e472d0bffc21c50b4f429e1cd05a8dd60e9", + "size": 276360208, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/riscv32-esp-elf-15.1.0_20250607-i586-linux-gnu.tar.xz" }, "macos": { - "sha256": "fd7543ca97f4d971798b8323e1e7315e648dded4cf2c16a82c3093447b0358fa", - "size": 305253540, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-x86_64-apple-darwin.tar.xz" + "sha256": "4ee3deecb24e4fcf2215e764392516b362d93e460ea5bdcc5f859f1b507bffad", + "size": 282706680, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/riscv32-esp-elf-15.1.0_20250607-x86_64-apple-darwin.tar.xz" }, "macos-arm64": { - "sha256": "b0e54a077c8abd261a588ee96b4079a95218ad9c3124b70ef7275c5de262277d", - "size": 285259728, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-aarch64-apple-darwin.tar.xz" + "sha256": "8a771237cf8784bd4a86bd2f5050d54480a60ae36be2ffc1bab8b944ab08ea50", + "size": 262326564, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/riscv32-esp-elf-15.1.0_20250607-aarch64-apple-darwin.tar.xz" }, - "name": "esp-14.2.0_20241119", + "name": "esp-15.1.0_20250607", "status": "recommended", "win32": { - "sha256": "54193a97bd75205678ead8d11f00b351cfa3c2a6e5ab5d966341358b9f9422d7", - "size": 672055172, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-i686-w64-mingw32.zip" + "sha256": "019c1ff3f4dbd4427917034e136df2019f1a0bceaae0c68e098ce6ad668e1d05", + "size": 689243750, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/riscv32-esp-elf-15.1.0_20250607-i686-w64-mingw32.zip" }, "win64": { - "sha256": "24c8407fa467448d394e0639436a5ede31caf1838e35e8435e19df58ebed438c", - "size": 677812937, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-x86_64-w64-mingw32.zip" + "sha256": "cc6df1e6f828487321fabd3c612097115e14937cb30eaab245f5fe931b481864", + "size": 696505388, + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-15.1.0_20250607/riscv32-esp-elf-15.1.0_20250607-x86_64-w64-mingw32.zip" } } ]