From 3b838603dedfe0ac7ab80c865548de9df8c75b8e Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Tue, 11 Apr 2023 17:27:31 +0200 Subject: [PATCH 1/5] components: systimer: improve includes sys/param.h can't be used in Zephyr context, due to conflicts with MIN/MAX definitions. Sort headers so that Zephyr ones come first (so we avoid any potential conflicts with redefinitions). Signed-off-by: Gerard Marull-Paretas --- .../esp_timer/src/esp_timer_impl_systimer.c | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/components/esp_timer/src/esp_timer_impl_systimer.c b/components/esp_timer/src/esp_timer_impl_systimer.c index e4d88a8430..324597879a 100644 --- a/components/esp_timer/src/esp_timer_impl_systimer.c +++ b/components/esp_timer/src/esp_timer_impl_systimer.c @@ -4,7 +4,21 @@ * SPDX-License-Identifier: Apache-2.0 */ +#ifndef __ZEPHYR__ #include "sys/param.h" +#include "freertos/FreeRTOS.h" +#else +#ifdef CONFIG_SOC_ESP32C3 +#include +#define ISR_HANDLER isr_handler_t +#else +#include +#define ISR_HANDLER intr_handler_t +#endif +#include +#include +#endif /* __ZEPHYR__ */ + #include "esp_timer_impl.h" #include "esp_err.h" #include "esp_timer.h" @@ -14,21 +28,9 @@ #include "soc/periph_defs.h" #include "soc/soc_caps.h" #include "soc/rtc.h" -#ifndef __ZEPHYR__ -#include "freertos/FreeRTOS.h" -#endif #include "hal/systimer_ll.h" #include "hal/systimer_types.h" #include "hal/systimer_hal.h" -#include - -#ifdef CONFIG_SOC_ESP32C3 -#include -#define ISR_HANDLER isr_handler_t -#else -#include -#define ISR_HANDLER intr_handler_t -#endif /** * @file esp_timer_systimer.c From 15d40cb9d87d4d3e08ca8bf27101b25272424532 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Wed, 12 Apr 2023 10:33:54 +0200 Subject: [PATCH 2/5] components: bit_defs: avoid redefining Zephyr BIT When building for Zephyr, use sys/util.h. Signed-off-by: Gerard Marull-Paretas --- components/esp_common/include/esp_bit_defs.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/esp_common/include/esp_bit_defs.h b/components/esp_common/include/esp_bit_defs.h index 40125c2f50..6907248c2e 100644 --- a/components/esp_common/include/esp_bit_defs.h +++ b/components/esp_common/include/esp_bit_defs.h @@ -83,9 +83,13 @@ #define BIT32 (0x00000001ULL << 32) #ifndef __ASSEMBLER__ +#ifndef __ZEPHYR__ #ifndef BIT #define BIT(nr) (1UL << (nr)) #endif +#else +#include +#endif #ifndef BIT64 #define BIT64(_n) (1ULL << (_n)) #endif From be25b4feb9c6d41d84c63f2934744c809238c6c4 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Wed, 12 Apr 2023 10:51:36 +0200 Subject: [PATCH 3/5] components: fix sys/param.h conflicts sys/param.h is not needed in some cases, in others, it conflicts with Zephyr so let's use Zephyr sys/util.h. Signed-off-by: Gerard Marull-Paretas --- components/efuse/esp32c3/esp_efuse_utility.c | 1 - components/esp_system/port/soc/esp32c3/clk.c | 1 - components/esp_system/port/soc/esp32s2/clk.c | 1 - components/esp_system/port/soc/esp32s3/clk.c | 1 - components/esp_timer/src/esp_timer.c | 1 - components/hal/systimer_hal.c | 4 ++++ components/spi_flash/esp32s3/spi_timing_config.c | 4 ++++ components/spi_flash/flash_ops.c | 7 ++++++- 8 files changed, 14 insertions(+), 6 deletions(-) diff --git a/components/efuse/esp32c3/esp_efuse_utility.c b/components/efuse/esp32c3/esp_efuse_utility.c index 40eb064f12..340d4028a8 100644 --- a/components/efuse/esp32c3/esp_efuse_utility.c +++ b/components/efuse/esp32c3/esp_efuse_utility.c @@ -4,7 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include #include "sdkconfig.h" #include "esp_log.h" #include "assert.h" diff --git a/components/esp_system/port/soc/esp32c3/clk.c b/components/esp_system/port/soc/esp32c3/clk.c index 762ec29fb1..09f4edf17d 100644 --- a/components/esp_system/port/soc/esp32c3/clk.c +++ b/components/esp_system/port/soc/esp32c3/clk.c @@ -9,7 +9,6 @@ #if !defined(__ZEPHYR__) #include #endif -#include #include "sdkconfig.h" #include "esp_attr.h" #include "esp_log.h" diff --git a/components/esp_system/port/soc/esp32s2/clk.c b/components/esp_system/port/soc/esp32s2/clk.c index 4b6628654b..6a2eb952d9 100644 --- a/components/esp_system/port/soc/esp32s2/clk.c +++ b/components/esp_system/port/soc/esp32s2/clk.c @@ -9,7 +9,6 @@ #if !defined(__ZEPHYR__) #include #endif -#include #if !defined(__ZEPHYR__) #include "sdkconfig.h" diff --git a/components/esp_system/port/soc/esp32s3/clk.c b/components/esp_system/port/soc/esp32s3/clk.c index 12ce0e83a8..77f3558fb3 100644 --- a/components/esp_system/port/soc/esp32s3/clk.c +++ b/components/esp_system/port/soc/esp32s3/clk.c @@ -10,7 +10,6 @@ #include #include "sdkconfig.h" #endif -#include #include "esp_attr.h" #include "esp_log.h" #include "esp32s3/clk.h" diff --git a/components/esp_timer/src/esp_timer.c b/components/esp_timer/src/esp_timer.c index 69241e23a4..554929c6d7 100644 --- a/components/esp_timer/src/esp_timer.c +++ b/components/esp_timer/src/esp_timer.c @@ -3,7 +3,6 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include #include #include "soc/soc.h" #include "esp_types.h" diff --git a/components/hal/systimer_hal.c b/components/hal/systimer_hal.c index 6484a39928..59aafe83c2 100644 --- a/components/hal/systimer_hal.c +++ b/components/hal/systimer_hal.c @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifndef __ZEPHYR__ #include +#else +#include +#endif #include "soc/soc_caps.h" #include "hal/systimer_hal.h" #include "hal/systimer_ll.h" diff --git a/components/spi_flash/esp32s3/spi_timing_config.c b/components/spi_flash/esp32s3/spi_timing_config.c index 53b302b6e8..f64dcb1167 100644 --- a/components/spi_flash/esp32s3/spi_timing_config.c +++ b/components/spi_flash/esp32s3/spi_timing_config.c @@ -5,7 +5,11 @@ */ #include +#ifndef __ZEPHYR__ #include +#else +#include +#endif #include "sdkconfig.h" #include "string.h" #include "esp_attr.h" diff --git a/components/spi_flash/flash_ops.c b/components/spi_flash/flash_ops.c index 212138335e..fd3ce00d4b 100644 --- a/components/spi_flash/flash_ops.c +++ b/components/spi_flash/flash_ops.c @@ -8,7 +8,6 @@ #include #include #include -#include // For MIN/MAX(a, b) #if !defined(__ZEPHYR__) #include @@ -16,6 +15,12 @@ #include #endif +#if !defined(__ZEPHYR__) +#include // For MIN/MAX(a, b) +#else +#include +#endif + #include #include #include "sdkconfig.h" From 0926273712406c886f00e467beba69a69219f558 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Wed, 12 Apr 2023 14:54:28 +0200 Subject: [PATCH 4/5] components: rom: s/EMPTY/EMPTY_STATE The EMPTY enumeration collides with Zephyr EMPTY definition. Rename to EMPTY_STATE. Signed-off-by: Gerard Marull-Paretas --- components/esp_rom/include/esp32c3/rom/uart.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_rom/include/esp32c3/rom/uart.h b/components/esp_rom/include/esp32c3/rom/uart.h index 4e7e5b8ee6..33e4aae25c 100644 --- a/components/esp_rom/include/esp32c3/rom/uart.h +++ b/components/esp_rom/include/esp32c3/rom/uart.h @@ -122,7 +122,7 @@ typedef enum { } UartFlowCtrl; typedef enum { - EMPTY, + EMPTY_STATE, UNDER_WRITE, WRITE_OVER } RcvMsgBuffState; From e9c86654631079fc33bee9c5e2aaae0dbad43911 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Wed, 12 Apr 2023 15:11:28 +0200 Subject: [PATCH 5/5] components: spi_flash: fix ARRAY_SIZE conflicts The definition collides with Zephyr definition. Signed-off-by: Gerard Marull-Paretas --- components/spi_flash/spi_flash_timing_tuning.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/spi_flash/spi_flash_timing_tuning.c b/components/spi_flash/spi_flash_timing_tuning.c index 8b2efd1450..cec0d15547 100644 --- a/components/spi_flash/spi_flash_timing_tuning.c +++ b/components/spi_flash/spi_flash_timing_tuning.c @@ -20,7 +20,11 @@ #include "esp32s3/rom/cache.h" #endif +#ifndef __ZEPHYR__ #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(*(arr))) +#else +#include +#endif #if SPI_TIMING_FLASH_NEEDS_TUNING || SPI_TIMING_PSRAM_NEEDS_TUNING const static char *TAG = "MSPI Timing";