I have a large (900+ LOC) arduino single sketch which is becoming a nightmare to maintain, so I decided to refactor and clean it up. To make my life easier I decided to leave Arduino IDE and use PlatoformIO, but PlatormIO compiled program doesn’t work as expected on my arduino (or at least as Arduino IDE compiled sketch).
My code uses SPI
My arduino is an atmega328p nano
I figured out this might be because of some wrong settings of the compiler, what I tried:
Adding the same compile flags Arduino IDE uses
Using all levels of optimization: -O0 works as expected but inacceptably slow, -Os -O1 -O2 -O3 compiled code seems to get stuck into a for loop in loop() function
Done. The differences between the two outputs are more or less just about locations for avr and other tools on my hard disk. Anyway I noticed that that pio builds of my code are 4kb smaller that Arduino IDE ones, even with the same optimization flags