1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

pkg/esp32_sdk: additional patches required for ESP32-S3

The patches include the following changes:
- define ARRAY_SIZE in `component/spi_flash/spi_flash_timing_tuning.c` only if it is not yet defined by RIOT macros
- add alternative implementations for`spi_flash_disable_interrupts_caches_and_other_cpu` and `spi_flash_enable_interrupts_caches_and_other_cpu` if compiled for RIOT
- fix the undefined reference to `rtc_gpio_force_hold_en_all` in `components/driver/gpio.c`
- rename the bootloader patch to fix the serial number
This commit is contained in:
Gunar Schorcht 2022-07-31 11:14:08 +02:00
parent 3f1ac8a6b3
commit ca34e970f1
4 changed files with 91 additions and 33 deletions

View File

@ -1,47 +1,51 @@
From 85fc96683ff351d5780388bfd870f023c9d2e486 Mon Sep 17 00:00:00 2001
From 5285a8f5898074d38d71054010cf912c2d7ffb2d Mon Sep 17 00:00:00 2001
From: Gunar Schorcht <gunar@schorcht.net>
Date: Sun, 30 Jan 2022 09:50:50 +0100
Subject: [PATCH 10/12] spi_flash: disable functions not required or not
supported
Various cache utility functions are neither required nor can they be supported by the means of RIOT. For example, it is not possible to change the priority of a thread. They have to be therefore disabled in RIOT.
- Various cache utility functions are neither required nor can they be supported by the means of RIOT. For example, it is not possible to change the priority of a thread. They have to be therefore disabled in RIOT.
- Add alternative implementations for `spi_flash_disable_interrupts_caches_and_other_cpu` and `spi_flash_enable_interrupts_caches_and_other_cpu` if compiled for RIOT
---
components/spi_flash/cache_utils.c | 4 ++++
1 file changed, 4 insertions(+)
components/spi_flash/cache_utils.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/components/spi_flash/cache_utils.c b/components/spi_flash/cache_utils.c
index 7715900055..79b6f0a685 100644
index 7715900055..d7d750abdd 100644
--- a/components/spi_flash/cache_utils.c
+++ b/components/spi_flash/cache_utils.c
@@ -62,6 +62,7 @@ static __attribute__((unused)) const char *TAG = "cache";
#define DPORT_CACHE_GET_VAL(cpuid) (cpuid == 0) ? DPORT_CACHE_VAL(PRO) : DPORT_CACHE_VAL(APP)
#define DPORT_CACHE_GET_MASK(cpuid) (cpuid == 0) ? DPORT_CACHE_MASK(PRO) : DPORT_CACHE_MASK(APP)
@@ -67,6 +67,8 @@ static void IRAM_ATTR spi_flash_restore_cache(uint32_t cpuid, uint32_t saved_sta
static uint32_t s_flash_op_cache_state[2];
+#ifndef RIOT_VERSION
static void IRAM_ATTR spi_flash_disable_cache(uint32_t cpuid, uint32_t *saved_state);
static void IRAM_ATTR spi_flash_restore_cache(uint32_t cpuid, uint32_t saved_state);
+
#ifndef CONFIG_FREERTOS_UNICORE
static SemaphoreHandle_t s_flash_op_mutex;
static volatile bool s_flash_op_can_start = false;
@@ -293,6 +295,22 @@ void IRAM_ATTR spi_flash_enable_interrupts_caches_no_os(void)
@@ -357,6 +358,7 @@ static void IRAM_ATTR spi_flash_restore_cache(uint32_t cpuid, uint32_t saved_sta
Cache_Resume_ICache(saved_state >> 16);
#endif
}
+#endif /* RIOT_VERSION */
IRAM_ATTR bool spi_flash_cache_enabled(void)
{
@@ -373,6 +375,7 @@ IRAM_ATTR bool spi_flash_cache_enabled(void)
return result;
}
+#ifndef RIOT_VERSION
#if CONFIG_IDF_TARGET_ESP32S2
IRAM_ATTR void esp_config_instruction_cache_mode(void)
{
@@ -939,3 +942,4 @@ void IRAM_ATTR spi_flash_enable_cache(uint32_t cpuid)
spi_flash_restore_cache(0, 0); // TODO cache_value should be non-zero
#endif
}
#endif // CONFIG_FREERTOS_UNICORE
+#else /* RIOT_VERSION */
+
+void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu(void)
+{
+ irq_disable();
+ spi_flash_disable_cache(0, &s_flash_op_cache_state[0]);
+}
+
+void IRAM_ATTR spi_flash_enable_interrupts_caches_and_other_cpu(void)
+{
+ spi_flash_restore_cache(0, s_flash_op_cache_state[0]);
+ irq_enable();
+}
+
+#endif /* RIOT_VERSION */
+
/**
* The following two functions are replacements for Cache_Read_Disable and Cache_Read_Enable
* function in ROM. They are used to work around a bug where Cache_Read_Disable requires a call to
--
2.17.1

View File

@ -0,0 +1,27 @@
From 1cb888fc95a0374523e164d513952681e4e5847c Mon Sep 17 00:00:00 2001
From: Gunar Schorcht <gunar@schorcht.net>
Date: Fri, 8 Apr 2022 16:45:44 +0200
Subject: [PATCH 21/23] spi_flash: changes for RIOT for esp32s3
Define ARRAY_SIZE in `component/spi_flash/spi_flash_timing_tuning.c` only if it is not yet defined by RIOT macros.
---
components/spi_flash/spi_flash_timing_tuning.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/components/spi_flash/spi_flash_timing_tuning.c b/components/spi_flash/spi_flash_timing_tuning.c
index 8b2efd1450..de8a0a60e9 100644
--- a/components/spi_flash/spi_flash_timing_tuning.c
+++ b/components/spi_flash/spi_flash_timing_tuning.c
@@ -20,7 +20,9 @@
#include "esp32s3/rom/cache.h"
#endif
+#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(*(arr)))
+#endif
#if SPI_TIMING_FLASH_NEEDS_TUNING || SPI_TIMING_PSRAM_NEEDS_TUNING
const static char *TAG = "MSPI Timing";
--
2.17.1

View File

@ -0,0 +1,27 @@
From ff70fdaa8c4c11e060772c47195c271188b7bf01 Mon Sep 17 00:00:00 2001
From: Gunar Schorcht <gunar@schorcht.net>
Date: Fri, 27 May 2022 15:29:14 +0200
Subject: [PATCH 22/23] driver/gpio: fix undefined reference to
rtc_gpio_force_hold_all
Fix the undefined reference to `rtc_gpio_force_hold_en_all` in `components/driver/gpio.c`
---
components/driver/gpio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/driver/gpio.c b/components/driver/gpio.c
index db27ab45ab..0c696f0d9f 100644
--- a/components/driver/gpio.c
+++ b/components/driver/gpio.c
@@ -682,7 +682,7 @@ void gpio_deep_sleep_hold_dis(void)
esp_err_t gpio_force_hold_all()
{
#if SOC_RTCIO_HOLD_SUPPORTED
- rtc_gpio_force_hold_all();
+ rtc_gpio_force_hold_en_all();
#endif
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
gpio_hal_force_hold_all(gpio_context.gpio_hal);
--
2.17.1

View File

@ -1,14 +1,14 @@
From 442a8e58c9a385b289fbac4554df78a999266be6 Mon Sep 17 00:00:00 2001
From c6789a3f627915ff7d9f6909c2202eac2cb9db0c Mon Sep 17 00:00:00 2001
From: Gunar Schorcht <gunar@schorcht.net>
Date: Tue, 31 May 2022 22:32:47 +0200
Subject: [PATCH 24/24] bootloader: remove compile from banner
Subject: [PATCH 23/23] bootloader: remove compile time from banner
---
components/bootloader_support/src/bootloader_init.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/components/bootloader_support/src/bootloader_init.c b/components/bootloader_support/src/bootloader_init.c
index 1d73f5dc26b..9e45b1d415a 100644
index 1d73f5dc26..9e45b1d415 100644
--- a/components/bootloader_support/src/bootloader_init.c
+++ b/components/bootloader_support/src/bootloader_init.c
@@ -91,5 +91,7 @@ void bootloader_enable_random(void)