First time poster. I’m not too familiar with platformIO yet.
I’m trying to setup CLion IDE to do building and debugging of my Arduino/ESP8266 projects. The PlatformIO instructions and community comments have got me to the point where Building and Uploading works.
I think I have a memory corruption issue causing an exception that can’t easily be debugged using Serial prints. There is a CLion configuration called “PlatformIO Debug”, but when I try to run this I get an instant error “Debugger process finished with exit code 1”.
Can anyone offer any advice on how I can get this working please? Ideally, I’d like to be able to break and step through the code.
in the platformio.ini, re-flashing and restarting the serial monitor should show the decode of the exception when it occurrs.
Otherwise PlatformIO features a static code analyzer (aka cppcheck) that can catch a lot of bugs. You can run that over your project in the VSCode PIO Home → Inspect screen.
Thanks for the very quick response Max! I’ll investigate your suggestions and reply here with the results.
I did manage to decode the stacktrace using a plugin tool for Arduino IDE, but as is often the case with memory corruption, you find where it was noticed and not where it occurred. Good call on using static code analysis tools. Is there a way I can run it on the command line, or as part of a standard build in CLion? I tried updating the config but didn’t see anything different in the build output. I would guess it needs to be a specific build? I’m not keen on learning another IDE (VSCode) just for this, but if there’s no other option…
pio check is available on the commandline, and also accessible via the normal Tools → PlatformIO → Check menu.
Notice that you can also launch PlatofrmIO → Home which then opens the same website VSCode is looking at. From there, Inspect is accessible too.
Caveat: Sometimes the pio check command requires the --skip-packages option because cppcheck otherwise chokes on framework files…
Note: If you are working with the Arduino-ESP8266 core and are experiencing a memory corruption in the heap, the core has facilities to detect that, using special heap wrappers.
So you can catch the culprit in the act. Can be activated with e.g. build_flags = -DUMM_POISON_CHECK in the platformio.ini. Also has a usage manual.