The first thing to do would be to look out for version differences in the used Arduino core. What core / board manager URL are you using for the SAMD Arduino integration in the Arduino IDE? There might be multiple ones. Diff’ing the source code of PIO’s version of the core (see core
subfolders in ~/.platformio/packages/framework-arduinosam
) with the one your Arduino IDE is using (core is also somewhere in the Arduino IDE installation) will help you gain some insight here. The problem might simply be that you’re using a different core with a different behaviour or a different version of the core.
Next, compiler flags would have to be investiaged. You can do a verbose compile run with PIO using pio run -v
. You can then check for the used compiler flags (optimization level, defined macros, …). You can also activate verbosity in the Arduino IDE (File->Settings->..
) and thus compare the two.
Not entirely true. Even the Arduino IDE should at some point produce a firmware ELF file (with hopefully some debugging symbols, if not check how to add compiler flags to the build). So you can take the Arduino-IDE produced firmware, flash it onto the MCU and also give it to openocd
and arm-none-eabi-gdb
to start debugging it. This will allow you to analyze that runtime error if you haven’t already. You might also find my tutorial on setting up openocd / gdb in Eclipse or whatever helpful. The same working principle holds also for other chip types.