tmedicci opened a new pull request, #15825: URL: https://github.com/apache/nuttx/pull/15825
## Summary <!-- This field should contain a summary of the changes. It will be pre-filled with the commit's message and descriptions. Adjust it accordingly --> * xtensa/esp32s3: allow moving .bss data to the external PSRAM This commit allows placing .bss data into the external PSRAM. Previously, the PSRAM was fully allocated to the heap memory only and now part of it can be used to allocate .bss data freeing the internal memory. ## Impact <!-- Please fill the following sections with YES/NO and provide a brief explanation --> Impact on user: YES. User's application that set `__attribute__ ((section (".ext_ram.bss")))` for a static variable will allocate it to the external PSRAM (freeing the internal memory). Impact on build: NO. It doesn't break any existing build Impact on hardware: YES. This allows non-initialized data (`.bss`) to be allocated in the external PSRAM of ESP32-S3, freeing the internal memory. Impact on documentation: NO. Impact on security: NO. Impact on compatibility: NO. ## Testing It can be simply tested by setting the `__attribute__ ((section (".ext_ram.bss")))` attribute to a static variable. Please consider the following patch that adds it to the hello world app of `nuttx-apps`: ``` diff --git a/examples/hello/hello_main.c b/examples/hello/hello_main.c index fd194a623a..4f9b6f6a28 100644 --- a/examples/hello/hello_main.c +++ b/examples/hello/hello_main.c @@ -27,6 +27,9 @@ #include <nuttx/config.h> #include <stdio.h> +static int data_bss[1024]; +__attribute__ ((section (".ext_ram.bss"))) static int data_bss_ext[1024]; + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -38,5 +41,7 @@ int main(int argc, FAR char *argv[]) { printf("Hello, World!!\n"); + printf("data_bss: %p\n", (void *)data_bss); + printf("data_bss_ext: %p\n", (void *)data_bss_ext); return 0; } ``` ### Building After applying the patch, one can build and flash it on ESP32-S3: ``` $ make -j distclean && ./tools/configure.sh esp32s3-devkit:nsh && kconfig-tweak -e EXAMPLES_HELLO && make olddefconfig && make flash EXTRAFLAGS="-Wno-cpp -Werror" ESPTOOL_PORT=/dev/ttyUSB0 -s -j$(nproc) && minicom ``` ### Running On NSH: ``` nsh> hello Hello, World!! data_bss: 0x3fc8a758 data_bss_ext: 0x3c050000 nsh> ``` ### Results The memory address is consistent with ESP32-S3's [TRM](https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf) (figure 4.2-1):  The variable that had the attribute set (`data_bss_ext`) is allocated to the external memory (PSRAM) while the `data_bss` refers to the internal memory. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org