From 6c304267770241ed1b79394328d684375dfdc41f Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Wed, 9 Feb 2022 17:16:37 +0700 Subject: [PATCH 1/2] ulp_riscv: suppress -Wstringop-overflow --- components/ulp/ulp_riscv/ulp_riscv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/ulp/ulp_riscv/ulp_riscv.c b/components/ulp/ulp_riscv/ulp_riscv.c index aa828c40a4..588d13bef5 100644 --- a/components/ulp/ulp_riscv/ulp_riscv.c +++ b/components/ulp/ulp_riscv/ulp_riscv.c @@ -159,8 +159,12 @@ esp_err_t ulp_riscv_load_binary(const uint8_t* program_binary, size_t program_si uint8_t* base = (uint8_t*) RTC_SLOW_MEM; //Start by clearing memory reserved with zeros, this will also will initialize the bss: +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" memset(base, 0, CONFIG_ULP_COPROC_RESERVE_MEM); memcpy(base, program_binary, program_size_bytes); +#pragma GCC diagnostic pop return ESP_OK; } From 6b15dce39c6eb1858aa3ab01945d05a38d2cf964 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Tue, 22 Feb 2022 12:58:25 +0700 Subject: [PATCH 2/2] ulp test: suppress -Wstringop-overflow and -Warray-bounds --- components/ulp/test/ulp_fsm/test_ulp.c | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/components/ulp/test/ulp_fsm/test_ulp.c b/components/ulp/test/ulp_fsm/test_ulp.c index 59ee733913..42d325fe41 100644 --- a/components/ulp/test/ulp_fsm/test_ulp.c +++ b/components/ulp/test/ulp_fsm/test_ulp.c @@ -50,8 +50,12 @@ static void hexdump(const uint32_t* src, size_t count) { TEST_CASE("ULP FSM addition test", "[ulp]") { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" /* Clear the RTC_SLOW_MEM region for the ULP co-processor binary to be loaded */ memset(RTC_SLOW_MEM, 0, CONFIG_ULP_COPROC_RESERVE_MEM); +#pragma GCC diagnostic pop /* ULP co-processor program to add data in 2 memory locations using ULP macros */ const ulp_insn_t program[] = { @@ -84,8 +88,12 @@ TEST_CASE("ULP FSM subtraction and branch test", "[ulp]") { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 260 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" /* Clear the RTC_SLOW_MEM region for the ULP co-processor binary to be loaded */ memset(RTC_SLOW_MEM, 0, CONFIG_ULP_COPROC_RESERVE_MEM); +#pragma GCC diagnostic pop /* ULP co-processor program to perform subtractions and branch to a label */ const ulp_insn_t program[] = { @@ -155,8 +163,12 @@ TEST_CASE("ULP FSM light-sleep wakeup test", "[ulp]") { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 260 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" /* Clear the RTC_SLOW_MEM region for the ULP co-processor binary to be loaded */ memset(RTC_SLOW_MEM, 0, CONFIG_ULP_COPROC_RESERVE_MEM); +#pragma GCC diagnostic pop /* ULP co-processor program to perform some activities and wakeup the main CPU from deep-sleep */ const ulp_insn_t program[] = { @@ -197,8 +209,12 @@ TEST_CASE("ULP FSM deep-sleep wakeup test", "[ulp][reset=SW_CPU_RESET][ignore]") { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 260 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" /* Clearout the RTC_SLOW_MEM region for the ULP co-processor binary to be loaded */ memset(RTC_SLOW_MEM, 0, CONFIG_ULP_COPROC_RESERVE_MEM); +#pragma GCC diagnostic pop /* ULP co-processor program to perform some activities and wakeup the main CPU from deep-sleep */ const ulp_insn_t program[] = { @@ -239,8 +255,12 @@ TEST_CASE("ULP FSM can write and read peripheral registers", "[ulp]") /* Clear ULP timer */ CLEAR_PERI_REG_MASK(RTC_CNTL_STATE0_REG, RTC_CNTL_ULP_CP_SLP_TIMER_EN); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" /* Clear the RTC_SLOW_MEM region for the ULP co-processor binary to be loaded */ memset(RTC_SLOW_MEM, 0, CONFIG_ULP_COPROC_RESERVE_MEM); +#pragma GCC diagnostic pop /* ULP co-processor program to read from and write to peripheral registers */ const ulp_insn_t program[] = { @@ -288,8 +308,12 @@ TEST_CASE("ULP FSM I_WR_REG instruction test", "[ulp]") { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 260 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" /* Clear the RTC_SLOW_MEM region for the ULP co-processor binary to be loaded */ memset(RTC_SLOW_MEM, 0, CONFIG_ULP_COPROC_RESERVE_MEM); +#pragma GCC diagnostic pop /* Define the test set */ typedef struct { @@ -354,8 +378,12 @@ TEST_CASE("ULP FSM controls RTC_IO", "[ulp][ignore]") { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 260 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" /* Clear the RTC_SLOW_MEM region for the ULP co-processor binary to be loaded */ memset(RTC_SLOW_MEM, 0, CONFIG_ULP_COPROC_RESERVE_MEM); +#pragma GCC diagnostic pop /* ULP co-processor program to toggle LED */ const ulp_insn_t program[] = { @@ -416,12 +444,20 @@ TEST_CASE("ULP FSM power consumption in deep sleep", "[ulp][ignore]") { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 4 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" /* Clear the RTC_SLOW_MEM region for the ULP co-processor binary to be loaded */ memset(RTC_SLOW_MEM, 0, CONFIG_ULP_COPROC_RESERVE_MEM); +#pragma GCC diagnostic pop /* Put the ULP coprocessor in halt state */ ulp_insn_t insn = I_HALT(); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" memcpy(&RTC_SLOW_MEM[0], &insn, sizeof(insn)); +#pragma GCC diagnostic pop /* Set ULP timer */ ulp_set_wakeup_period(0, 0x8000); @@ -442,8 +478,12 @@ TEST_CASE("ULP FSM timer setting", "[ulp]") { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 32 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" /* Clear the RTC_SLOW_MEM region for the ULP co-processor binary to be loaded */ memset(RTC_SLOW_MEM, 0, CONFIG_ULP_COPROC_RESERVE_MEM); +#pragma GCC diagnostic pop /* * Run a simple ULP program which increments the counter, for one second. @@ -503,8 +543,12 @@ TEST_CASE("ULP FSM can use temperature sensor (TSENS) in deep sleep", "[ulp][ign { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 260 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" /* Clear the RTC_SLOW_MEM region for the ULP co-processor binary to be loaded */ memset(RTC_SLOW_MEM, 0, CONFIG_ULP_COPROC_RESERVE_MEM); +#pragma GCC diagnostic pop // Allow TSENS to be controlled by the ULP SET_PERI_REG_BITS(SENS_SAR_TSENS_CTRL_REG, SENS_TSENS_CLK_DIV, 10, SENS_TSENS_CLK_DIV_S); @@ -571,8 +615,12 @@ TEST_CASE("ULP FSM can use ADC in deep sleep", "[ulp][ignore]") const int channel = 0; const int atten = 0; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Warray-bounds" /* Clear the RTC_SLOW_MEM region for the ULP co-processor binary to be loaded */ memset(RTC_SLOW_MEM, 0, CONFIG_ULP_COPROC_RESERVE_MEM); +#pragma GCC diagnostic pop #if defined(CONFIG_IDF_TARGET_ESP32) // Configure SAR ADCn resolution