You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "tmedicci (via GitHub)" <gi...@apache.org> on 2025/02/12 20:17:14 UTC
[PR] xtensa/esp32s3: allow moving .bss data to the external PSRAM [nuttx]
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] xtensa/esp32s3: allow moving .bss data to the external PSRAM [nuttx]
Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on PR #15825:
URL: https://github.com/apache/nuttx/pull/15825#issuecomment-2656647782
> @tmedicci please include a Documentation/ with the information you added here, this way users will know how to use it in their applications
done!
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] xtensa/esp32s3: allow moving .bss data to the external PSRAM [nuttx]
Posted by "cederom (via GitHub)" <gi...@apache.org>.
cederom commented on PR #15825:
URL: https://github.com/apache/nuttx/pull/15825#issuecomment-2669620764
Thank you @tmedicci great work, "RAM is not the limit" now! :-) :-) Please remember to use `git commit -s` :-)
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] xtensa/esp32s3: allow moving .bss data to the external PSRAM [nuttx]
Posted by "nuttxpr (via GitHub)" <gi...@apache.org>.
nuttxpr commented on PR #15825:
URL: https://github.com/apache/nuttx/pull/15825#issuecomment-2654769480
[**\[Experimental Bot, please feedback here\]**](https://github.com/search?q=repo%3Aapache%2Fnuttx+13552&type=issues)
This PR description mostly meets the NuttX requirements, but could be improved in a few ways:
**Strengths:**
* **Clear Summary:** The summary explains the change, its purpose, and how it works.
* **Specific Impact Descriptions:** The impact section clearly identifies the areas affected and provides concise explanations. The "YES" answers are well-supported.
* **Detailed Testing Information:** The testing section provides build instructions, expected output, and how to interpret the results. The reference to the ESP32-S3 TRM and the included diagram are excellent.
**Areas for Improvement:**
* **Summary - References:** While it mentions .bss, it might be helpful to link to relevant documentation about this memory section within NuttX or a general explanation for those unfamiliar.
* **Testing - Before Change Logs:** The template requests "Testing logs before change." While the behavior before the change is implied (`.bss` would be in internal memory), explicitly showing the output of the `hello` example *before* the patch would make the comparison more compelling. This would demonstrate the difference in memory addresses and confirm the change is working as intended.
* **Testing - Host Information:** The "Build Host(s)" section is missing. Include details about the development environment used for testing (OS, CPU architecture, compiler version). This helps with reproducibility and understanding the context of the test.
* **Testing - Target Details:** While "esp32s3-devkit" is mentioned, specifying the exact configuration (e.g., the specific `defconfig` used) would be beneficial. Consider adding the output of `toplevel_config.h` or relevant sections to ensure the test setup is fully documented.
* **Consider a Kconfig Option:** For a change like this, which affects memory allocation, a Kconfig option might be desirable. This would allow users to enable or disable placing .bss data in external PSRAM. If a Kconfig option is not included, explain the rationale for not providing one.
**Revised Testing Section Example (Illustrative):**
```
## Testing
I confirm that changes are verified on local setup and works as intended:
* Build Host(s): Ubuntu 22.04, x86_64, GCC 11.3.0
* Target(s): esp32s3-devkit:nsh (using `esp32s3_defconfig`)
Testing logs before change:
```
nsh> hello
Hello, World!!
data_bss: 0x3fc8a758 <-- Note: Address in internal RAM
data_bss_ext: 0x3fc8a960 <-- Note: Also in internal RAM
nsh>
```
Testing logs after change:
```
nsh> hello
Hello, World!!
data_bss: 0x3fc8a758
data_bss_ext: 0x3c050000 <-- Now in external PSRAM
nsh>
```
(Include output of `cat build/esp32s3-devkit/nsh/toplevel_config.h | grep CONFIG_ESP32S3_SPIRAM` or similar to document the SPIRAM configuration)
```
By addressing these points, the PR will be even stronger and better aligned with NuttX's requirements. This will make it easier for reviewers to understand, verify, and ultimately merge the changes.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] xtensa/esp32s3: allow moving .bss data to the external PSRAM [nuttx]
Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on PR #15825:
URL: https://github.com/apache/nuttx/pull/15825#issuecomment-2659637252
@acassis @xiaoxiang781216 , can you please take a look?
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] xtensa/esp32s3: allow moving .bss data to the external PSRAM [nuttx]
Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on PR #15825:
URL: https://github.com/apache/nuttx/pull/15825#issuecomment-2668785833
Hi @acassis @lupyuen @jerpelea @cederom @raiden00pl @xiaoxiang781216 !
Is anything missing here? If not, can this PR be merged?
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] xtensa/esp32s3: allow moving .bss data to the external PSRAM [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #15825:
URL: https://github.com/apache/nuttx/pull/15825#issuecomment-2654781305
@tmedicci please include a Documentation/ with the information you added here, this way users will know how to use it in their applications
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] xtensa/esp32s3: allow moving .bss data to the external PSRAM [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #15825:
URL: https://github.com/apache/nuttx/pull/15825
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org