Memory usage after debug still too much

Hi.
I am using vs-code > platformio to program “wemos_D1_mini32”
I used >Advanced>Debug for my program because the MCU resets sometimes and I wanted to find out why.
Debugging obviously generates a bigger .elf file and I actually don’t know how to use that function correctly. So I returned to use “build” (and “debug” by using “serial.println”) but now the elf file is always too big, as though the debug command is still in effect.

Shouldn’t “build” simply work without adding debug information to the code?
I am lost at the moment.

Probably I need to provide more information for you people to help me through this, but i need to be told what to show you.
My platformio.ini looks like this:


[env:wemos_d1_mini32]
platform = espressif32
board = wemos_d1_mini32
framework = arduino
monitor_speed = 115200
lib_extra_dirs = ~/Documents/Arduino/libraries
lib_deps = beegee-tokyo/DHT sensor library for ESPx@^1.18


is there anything else I should look for or show you?

THX in advance

During a debug build, the -Os (minimal size) optimization is exchanged for -Og (optimize for debugging) level, which severely increases the size of the firmware and slows it down, but gives better debug info.

If you don’t like this, use the debug_build_flags as documented, e.g. by keeping the same optimization level as in a release build, but with added debug information. Preparea to see a lot of “this variable is optimized out” and jumps from one line to another thanks to the optimizer though.

debug_build_flags = -Os -ggdb3 -g3

Depending on your firmware, levels -O2 or -O1 may also be acceptable.

Hi Max,
I read about this in the documentation, but here starts my (currently) total inability to cope with the IDE. (I am dumbfounded by multiple possibilities to influence the behavior)

I added to the file platformio.ini the following:

[env:debug]
debug_build_flags = -Os -ggdb3 -g3

This is what comes back
(Still the firmware is too big and the entry seems not to be correct)


Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
Error: The program size (1440021 bytes) is greater than maximum allowed (1310720 bytes)
RAM:   [==        ]  16.2% (used 53052 bytes from 327680 bytes)
Flash: [===*** [checkprogsize] Explicit exit, status 1
=======]  109.9% (used 1440021 bytes from 1310720 bytes)
======================================== [FAILED] Took 74.83 seconds ========================================

Processing debug ()
--------------------------------------------------------------------------------------------------------------
Error: Please specify platform for 'debug' environment

then I changed platformio.ini to look like this, no better result


[env:wemos_d1_mini32]
platform = espressif32
board = wemos_d1_mini32
framework = arduino
monitor_speed = 115200
lib_extra_dirs = ~/Documents/Arduino/libraries
lib_deps = beegee-tokyo/DHT sensor library for ESPx@^1.18`
debug_build_flags = -Os -ggdb3 -g3

I put this information in the wrong place, I assume.

Where does

have to go?

I appreciate your knowledge and reply

This should be correct. No need to create a separate environment. What is the flash usage after a regular build?

A different approach on the ESP32 is to just use a different partition table with no ota and small filesystem. If you add

board_build.partitions = huge_app.csv

to the platformio.ini, it should be able to do a debug build, even without any debug_build_flags.

At least no more memory size overflow.
Where does the csv file go?

You do not need this CSV file in your project since it’s built-in in the Arduino core.

I see, anyway, adding this line solved my current problem and the firmware has a good size again.

THX a lot.

For being complete, (I did not answer this)

Platformio.ini
[env:wemos_d1_mini32]
platform = espressif32
board = wemos_d1_mini32
framework = arduino
monitor_speed = 115200
lib_extra_dirs = ~/Documents/Arduino/libraries
lib_deps = beegee-tokyo/DHT sensor library for ESPx@^1.18
;board_build.partitions = huge_app.csv
debug_build_flags = -Os -ggdb3 -g3

returns

Checking size .pio/build/wemos_d1_mini32/firmware.elf
Error: The program size (1440041 bytes) is greater than maximum allowed (1310720 bytes)
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
*** [checkprogsize] Explicit exit, status 1
RAM:   [==        ]  16.2% (used 53052 bytes from 327680 bytes)
Flash: [==========]  109.9% (used 1440041 bytes from 1310720 bytes)

so only the

board_build.partitions = huge_app.csv

is useful.

Anyway this leads to another question:
If I want to debug my code using inline debugging, this would be impossible that way
because of the high memory usage.
(I also use ports which would be necessary for JTAG)
What would you recommend how to handle this situation if I NEED to debug the code
inline?
(I still experience resets due to kernel exceptions -Core 1 panic’ed-)
Code running:
Core 0 task (read data from sensors into proprietary variables, locked by semaphores, controlled by Core1 Timer interrupt)
Core 1 Timer Interrupt (Copy Data from proprietary variables to display buffer every ~5 seconds, open semaphores to read ThRH ore Time)
Core 1 Loop() Scan display buffer to four 7 Segment Digits