This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new e05292f9dab [arch|board]/risc-v: Allow BSS segments on PSRAM for
ESP32-P4
e05292f9dab is described below
commit e05292f9dabe4ee0622688372519203f57930756
Author: Tiago Medicci Serrano <[email protected]>
AuthorDate: Tue May 12 13:36:45 2026 +0200
[arch|board]/risc-v: Allow BSS segments on PSRAM for ESP32-P4
This commits enables moving BSS data segments to the external PSRAM
on ESP32-P4. This is controlled by a Kconfig option.
Signed-off-by: Tiago Medicci Serrano <[email protected]>
---
arch/risc-v/src/common/espressif/CMakeLists.txt | 2 +-
arch/risc-v/src/common/espressif/Kconfig | 14 ++++++++++++++
arch/risc-v/src/common/espressif/Make.defs | 2 +-
arch/risc-v/src/common/espressif/esp_start.c | 5 +++++
boards/risc-v/esp32p4/common/scripts/esp32p4_sections.ld | 15 +++++++++++++++
.../esp32p4/common/scripts/esp32p4_sections.rev3.ld | 15 +++++++++++++++
6 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/arch/risc-v/src/common/espressif/CMakeLists.txt
b/arch/risc-v/src/common/espressif/CMakeLists.txt
index 3141406868e..928e09226ce 100644
--- a/arch/risc-v/src/common/espressif/CMakeLists.txt
+++ b/arch/risc-v/src/common/espressif/CMakeLists.txt
@@ -213,7 +213,7 @@ if(DEFINED ENV{ESP_HAL_3RDPARTY_VERSION})
CACHE STRING "ESP HAL 3rdparty version")
else()
set(ESP_HAL_3RDPARTY_VERSION
- e10e44f52e41aee7a617b4d144982a1998a17fc5
+ 627f38f94c1084b6b2d90ce09c0ce5517e8eaed7
CACHE STRING "ESP HAL 3rdparty version")
endif()
diff --git a/arch/risc-v/src/common/espressif/Kconfig
b/arch/risc-v/src/common/espressif/Kconfig
index 3c16ea9c4a2..1f35df66b4d 100644
--- a/arch/risc-v/src/common/espressif/Kconfig
+++ b/arch/risc-v/src/common/espressif/Kconfig
@@ -61,6 +61,7 @@ config ESPRESSIF_SPIRAM_BOOT_INIT
config ESPRESSIF_SPIRAM_IGNORE_NOTFOUND
bool "Ignore SPIRAM not found"
+ depends on !ESPRESSIF_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
default n
---help---
Keep booting even if PSRAM detection fails.
@@ -118,6 +119,19 @@ config ESPRESSIF_SPIRAM_USER_HEAP
---help---
Add SPIRAM as an additional NuttX heap region.
+config ESPRESSIF_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
+ bool "Allow .bss segment placed in external memory"
+ default n
+ ---help---
+ If enabled, variables with EXT_RAM_BSS_ATTR attribute will be
+ placed in SPIRAM instead of internal DRAM.
+
+ BSS sections from esp-hal-3rdparty components can also be placed
+ in SPIRAM through linker fragment mappings when enabled.
+
+ Note that variables placed in SPIRAM this way are still
+ zero-initialized at startup.
+
endif # ESPRESSIF_SPIRAM
config ESPRESSIF_IDF_ENV_FPGA
diff --git a/arch/risc-v/src/common/espressif/Make.defs
b/arch/risc-v/src/common/espressif/Make.defs
index d9b4560e0d9..9fafb834f5f 100644
--- a/arch/risc-v/src/common/espressif/Make.defs
+++ b/arch/risc-v/src/common/espressif/Make.defs
@@ -221,7 +221,7 @@ endif
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
ifndef ESP_HAL_3RDPARTY_VERSION
- ESP_HAL_3RDPARTY_VERSION = e10e44f52e41aee7a617b4d144982a1998a17fc5
+ ESP_HAL_3RDPARTY_VERSION = 627f38f94c1084b6b2d90ce09c0ce5517e8eaed7
endif
ifndef ESP_HAL_3RDPARTY_URL
diff --git a/arch/risc-v/src/common/espressif/esp_start.c
b/arch/risc-v/src/common/espressif/esp_start.c
index 4c11918994d..7207349a0e8 100644
--- a/arch/risc-v/src/common/espressif/esp_start.c
+++ b/arch/risc-v/src/common/espressif/esp_start.c
@@ -506,6 +506,7 @@ void __esp_start(void)
#else
bootloader_clear_bss_section();
#endif
+
/* Initialize the per CPU areas */
#ifdef CONFIG_RISCV_PERCPU_SCRATCH
@@ -605,6 +606,10 @@ void __esp_start(void)
}
#endif
+#ifdef CONFIG_ESPRESSIF_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
+ esp_psram_bss_init();
+#endif
+
/* Disable clock of unused peripherals */
esp_perip_clk_init();
diff --git a/boards/risc-v/esp32p4/common/scripts/esp32p4_sections.ld
b/boards/risc-v/esp32p4/common/scripts/esp32p4_sections.ld
index 1bf07cf4756..9733978ef70 100644
--- a/boards/risc-v/esp32p4/common/scripts/esp32p4_sections.ld
+++ b/boards/risc-v/esp32p4/common/scripts/esp32p4_sections.ld
@@ -20,6 +20,8 @@
*
****************************************************************************/
+#include <nuttx/config.h>
+
/* Default entry point: */
ENTRY(__start);
@@ -683,13 +685,26 @@ SECTIONS
*/
*(.bss .bss.*)
*(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb
.gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2
.sbss2.* .scommon .share.mem)
+#ifndef CONFIG_ESPRESSIF_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
*(.ext_ram.bss .ext_ram.bss.*)
+#endif
*(COMMON)
. = ALIGN(4);
_bss_end_high = ABSOLUTE(.);
} > sram_high
+#ifdef CONFIG_ESPRESSIF_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
+ /* This section holds .ext_ram.bss data and places it in external RAM. */
+ .ext_ram.bss (NOLOAD) :
+ {
+ _ext_ram_bss_start = ABSOLUTE(.);
+ *(.ext_ram.bss .ext_ram.bss.*)
+ . = ALIGN(4);
+ _ext_ram_bss_end = ABSOLUTE(.);
+ } > ext_ram_seg
+#endif
+
/* Heap region for sram_high: from end of bss to end of sram_high segment */
_sram_high_heap_start = _bss_end_high;
_sram_high_heap_end = ORIGIN(sram_high) + LENGTH(sram_high);
diff --git a/boards/risc-v/esp32p4/common/scripts/esp32p4_sections.rev3.ld
b/boards/risc-v/esp32p4/common/scripts/esp32p4_sections.rev3.ld
index 70b244bf5ef..8afb4d1e0cd 100644
--- a/boards/risc-v/esp32p4/common/scripts/esp32p4_sections.rev3.ld
+++ b/boards/risc-v/esp32p4/common/scripts/esp32p4_sections.rev3.ld
@@ -20,6 +20,8 @@
*
****************************************************************************/
+#include <nuttx/config.h>
+
/* Default entry point: */
ENTRY(__start);
@@ -526,7 +528,9 @@ SECTIONS
*(COMMON)
*(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb
.gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2
.sbss2.* .scommon .share.mem)
+#ifndef CONFIG_ESPRESSIF_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
*(.ext_ram.bss .ext_ram.bss.*)
+#endif
. = ALIGN(4);
_ebss = ABSOLUTE(.);
@@ -538,6 +542,17 @@ SECTIONS
_bss_end = ABSOLUTE(.);
} > sram_seg
+#ifdef CONFIG_ESPRESSIF_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
+ /* This section holds .ext_ram.bss data and places it in external RAM. */
+ .ext_ram.bss (NOLOAD) :
+ {
+ _ext_ram_bss_start = ABSOLUTE(.);
+ *(.ext_ram.bss .ext_ram.bss.*)
+ . = ALIGN(4);
+ _ext_ram_bss_end = ABSOLUTE(.);
+ } > ext_ram_seg
+#endif
+
.flash.text :
{
_stext = .;