tmedicci opened a new pull request, #18728:
URL: https://github.com/apache/nuttx/pull/18728
## Summary
* boards/xtensa/esp32/esp32-devkitc: Fix psram_usrheap defconfig
* When both CONFIG_ESP32_SPIRAM and CONFIG_ESP32_SPIRAM_USER_HEAP are
selected, the device must not select CONFIG_NSH_ARCHINIT. Instead,
CONFIG_BOARD_LATE_INITIALIZE must be selected. This is necessary because the
SPI flash initialization disables the cache, and only internal memory is then
accessible. So, if the SPI flash initialization is performed by the entry task
(nsh_main, a regular task), it would use the user heap to allocate memory,
which would cause a system crash when the cache is disabled. On the other hand,
by selecting CONFIG_BOARD_LATE_INITIALIZE, a kernel thread is dedicated to
perform the initialization, and the cache can be safely disabled.
* arch/xtensa/esp32: Fix ROM strdup heap issue in USER_HEAP mode
* When ESP32's flat build mode is selected with the external PSRAM on
USER_HEAP mode, the ROM strdup internally calls malloc which may be mapped to a
different heap than lib_free, causing cross-heap allocation issues and system
crashes.
Please note that this PR incorporates (and closes)
https://github.com/apache/nuttx/pull/18563. Original authorship is kept.
## Impact
<!-- Please fill the following sections with YES/NO and provide a brief
explanation -->
Impact on user: Yes. Enable using `esp32-devkitc:psram_usrheap` as expected.
Impact on build: No.
Impact on hardware: Yes. ESP32 with an external PSRAM (which can now be
assigned to the user heap)
Impact on documentation: No.
Impact on security: No.
Impact on compatibility: No.
## Testing
Build `esp32-devkitc:psram_usrheap` with DEBUG_ASSERTIONS. Flash the
firmware, format the SPI flash partition and check user and kernel heap.
### Building
```
make -j distclean
./tools/configure.sh -S esp32-devkitc:psram_usrheap
kconfig-tweak -e DEBUG_ASSERTIONS
make olddefconfig
make flash EXTRAFLAGS="-Wno-cpp -Werror" ESPTOOL_BINDIR=./
ESPTOOL_PORT=/dev/ttyUSB1 -s -j$(nproc)
```
### Running
After flashing, use `picocom -b 115200 /dev/ttyUSB1`, to run `mksmartfs
/dev/smart0` and check available memory with `free`
### Results
```
*** Booting NuttX ***
dram: lma 0x00001020 vma 0x3ffb5d30 len 0xf74 (3956)
iram: lma 0x00001f9c vma 0x40080000 len 0x951c (38172)
padd: lma 0x0000b4c8 vma 0x00000000 len 0x4b50 (19280)
imap: lma 0x00010020 vma 0x400d0020 len 0x24cb0 (150704)
padd: lma 0x00034cd8 vma 0x00000000 len 0xb340 (45888)
dmap: lma 0x00040020 vma 0x3f400020 len 0xb738 (46904)
total segments stored 6
[CPU1] ERROR: Failed to mount the FS volume: -19
[CPU1] Smartfs seems unformatted. Did you run 'mksmartfs /dev/smart0'?
[CPU1] ERROR: Failed to setup smartfs
[CPU1] ERROR: Failed to initialize SPI Flash
NuttShell (NSH) NuttX-10.4.0
nsh> mksmartfs /dev/smart0
nsh> free
total used free maxused maxfree nused nfree name
300232 19608 280624 20008 164560 53 4 Kmem
4198096 5320 4192776 5720 4192600 10 2 Umem
nsh>
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]