Our team is developing a library for ARM targets (Cortex M3 and M4) to support a hardware product. We have developed it in PlatformIO. Since the hardware is being targeted for the SAMD platforms out there such as the Adafruit Feather M0 and M4, we need to test with the Arduino IDE as a prerequisite to a publishing. Only under the Arduino IDE we seem to have code that operates differently in Arduino IDE, pertaining to separate threaded processes (main vs ISR). Difficult to diagnose: since we are developing in an environment with hardware debugging (JLINK), but attempting to validate in a blind, difficult IDE that most of our users will likely use to build their project.
While I would like everyone of our customers to move to PlatformIO, that is unlikely to help our hardware sales.
Has anyone experienced a issue with code working in PlatformIO and not when built with Arduino IDE?
If so did you find a solution?
What were the symptoms?
What change accomplished an improvement?
Thanks for helping with this stab in the dark,
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.