I’m facing a weird problem when, using vscode and pio, I try to debug Marlin firmware.
Firmware is compiling correctly when clicking on build task, so platformio.ini is correct (or so I think)
but when I click for “start debugging” i get a linker error. This let me think that standard link options are different from debug ones…where do I find them?
but changing source with:
static uint8_t fan_speed_scaler[FAN_COUNT];
works fine even in debug. I think it’s a optimization option but, again, where do are stored passed options? only in platformio.ini? There is nothing there that specialized for debug
Linking .pioenvs\adafruit_grandcentral_m4\firmware.elf
.pioenvs/adafruit_grandcentral_m4/src/src/module/planner.cpp.o: In function Planner::check_axes_activity()': c:\Users\Giuliano\Documents\GitHub\Marlin/Marlin\src\module/planner.cpp:1298: undefined reference to Temperature::fan_speed_scaler’
collect2.exe: error: ld returned 1 exit status
*** [.pioenvs\adafruit_grandcentral_m4\firmware.elf] Error 1
In a PIO Terminal (or just cmd.exe if it has access to PIO commands)
pio run -t clean
pio run -v > normal_compile.log 2>&1
pio debug -v > debug_compile.log 2>&1
Should create the log files. You might have to kill the second command after some time if it doesn’t terminate but wait for imput, after it has filled the log.
-Og is optimize for debugging (Optimize Options (Using the GNU Compiler Collection (GCC))), -Os is optimize for size (there’s also -O0, -O1, -O2, -O3 for various degrees of code optimization. Which code optimization flags break the code?
This is kind of strange thing and has maybe to do with the fact that the code is using constexpr whose compilation result is dependent on the optimzation level? Not sure yet. Does just removing constexpr get good results for each compile?
Yes, that was one of my first test…I think marlin uses constexpr to optimize code/memory use. I can’t remove for sure constexpr…maybe I can change it only in debug
edit: removing constexpr works, and this was my first test