Good day. I have an espressif clone that uses NodeMCU-32s board and the arduino framework. When I try to upload my code to the board I am met with the following error:
/Users/kstanl27/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/nodemcu-32s/firmware.elf section `.dram0.bss' will not fit in region `dram0_0_seg'
/Users/kstanl27/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: DRAM segment data does not fit.
/Users/kstanl27/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: region `dram0_0_seg' overflowed by 156768 bytes
After searching through other topics on this forum, and other places across the search engines, I’ve seen where it’s an issue with the number of uninitialized static variables exceeding the size limit of the .bss memory space and to look in the corresponding .map file to see which variables are the offenders.
The problem I’m running into, and have had no luck finding how to solve, is that there does not seem to be a .map file generated by platformio, or if it is, it’s being auto-removed before I can look at it.
I am using CLion 2020.3 and the PlatformIO plugin 203.5981.106 from Jetbrains. This is my first C++ project, and my first time using PlatformIO; in other words, my apologies if I missed something otherwise simple or obvious. And if you need any other information from me, please let me know.
Thank you in advance for any assistance. I’m banging my head on the keyboard over here.
But there’s still some tricks to be used. We can ‘simply’ change the linker file and expand the size of the region dram0_0_seg so that it forcefully builds, and then take a look at what’s hogging up memory so badly.
After doing a verbose build, we see the final linker command (is huge)…
to the absolute path where my xtensa-esp32-elf-nm is (C:\Users\Max\.platformio\packages\toolchain-xtensa32\bin\xtensa-esp32-elf-nm). The thing was originally written for ARM. So I’ll just let it run on the .elf file…
C:\Users\Max\mbed-os-linker-report>elfsize.py -i C:\Users\Max\Documents\PlatformIO\Projects\dbuddy\.pio\build\nodemcu-32s\firmware.elf -b
C:\Users\Max\.platformio\packages\toolchain-xtensa32\bin\xtensa-esp32-elf-nm -l -S -C -f sysv C:\Users\Max\Documents\PlatformIO\Projects\dbuddy\.pio\build\nodemcu-32s\firmware.elf
[INFO] data written to C:\Users\Max\mbed-os-linker-report\html\data-flare.js
[INFO] opening in browser file://C:\Users\Max\mbed-os-linker-report\index.html
and we get nice graphs that show how memory is being used in flash (code, constant variables, …) and ram (bss, global initialized but modifyable variables, etc.)
and that thing is 256 kilobytes in its current config!! Much too large than what fits in the bss section for the ESP32 when using the Arduino-ESP32 linker script (and they probably put a lot of thought into that).
Now let’s modify what you have written in your config file…
to set that to (64*1024) and also revert the linker file hacks in esp32_out.ld and build again…