Skip to content

[arch|board]/risc-v: Allow BSS segments on PSRAM for ESP32-P4#18874

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
tmedicci:feature/place_bss_psram
May 14, 2026
Merged

[arch|board]/risc-v: Allow BSS segments on PSRAM for ESP32-P4#18874
xiaoxiang781216 merged 1 commit into
apache:masterfrom
tmedicci:feature/place_bss_psram

Conversation

@tmedicci
Copy link
Copy Markdown
Contributor

Summary

  • [arch|board]/risc-v: Allow BSS segments on PSRAM for ESP32-P4
    • Enables moving BSS data segments to the external PSRAM on ESP32-P4. This is controlled by a Kconfig option.

Impact

Impact on user: No.

Impact on build: Yes. Allows .bss specific segments to the external PSRAM.

Impact on hardware: No.

Impact on documentation: No.

Impact on security: No.

Impact on compatibility: No.

Testing

We need to force a specific segment to check if it's being properly moved to the external PSRAM. ext_ram.bss.* segments are located at the external PSRAM. To test it, it's possible to enable the FS_HEAPSIZE and set FS_HEAPBUF_SECTION=".ext_ram.bss.buf". Considering the esp32p4-function-ev-board:psram_usrheap defconfig as a starting point:

Building

make -j distclean
./tools/configure.sh -S esp32p4-function-ev-board:psram_usrheap
kconfig-tweak -e ESPRESSIF_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
kconfig-tweak -e FS_TMPFS
kconfig-tweak --set-val FS_HEAPSIZE 2097152
kconfig-tweak --set-str FS_HEAPBUF_SECTION ".ext_ram.bss.buf"
make olddefconfig
make flash ESPTOOL_PORT=/dev/ttyACM0 
picocom -b 115200 /dev/ttyUSB1

Running

Check free to ensure that the fs_heap has 2MiB and user heap is less than the expected 32MiB - 2MiB (the difference is now part of the fs heap).

Also, check NuttX's nuttx.map to check if .ext_ram.bss.buf is properly assigned to the external RAM.

Results

free

nsh> free
      total       used       free    maxused    maxfree  nused  nfree name
    2097148       1564    2095584       1944    2095584     17      1 heapfs
     601860       5452     596408       8088     594152     24      2 Kmem
   31457276       4276   31453000       4656   31453000      8      1 Umem

nuttx.map

.ext_ram.bss    0x48000000   0x200000
                0x48000000                        _ext_ram_bss_start = ABSOLUTE (.)
 *(.ext_ram.bss .ext_ram.bss.*)
 .ext_ram.bss.buf
                0x48000000   0x200000 /home/tiago/Documents/work/espressif/projects/nuttx/nuttxspace/nuttx/staging/libfs.a(fs_heap.o)
                0x48200000                        . = ALIGN (0x4)
                0x48200000                        _ext_ram_bss_end = ABSOLUTE (.)

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 <tiago.medicci@espressif.com>
@github-actions github-actions Bot added Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Size: S The size of the change in this PR is small Board: risc-v labels May 13, 2026
@xiaoxiang781216 xiaoxiang781216 merged commit e05292f into apache:master May 14, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Board: risc-v Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants