I’m using version 3.5.0a of PlatformIO. Sketches I build (Blinky to start) for a couple Adafruit Feather M0 boards upload successfully but do not run. Building the same code in Arduino IDE 1.8.1 loads and runs fine.
I’m using the following in platformio.ini [env:feather]
I have sparkfun_samd21_mini_usb, the same MCU as adafruit_feather_m0 has. I even tried to flash SparkFun board using adafruit_feather_m0 configuration. All works well.
Please navigate to project folder/.pioenvs/adafruit_feather_m0 and find firmware.bin. Archive it and send to contact@pioplus.com. We will debug your firmware.
Could you try to remove “Blink.ino” from src folder and create here main.cpp with the next contents
main.cpp
/*
* Blink
* Turns on an LED on for one second,
* then off for one second, repeatedly.
*/
#include "Arduino.h"
// Set LED_BUILTIN if it is not defined by Arduino framework
// #define LED_BUILTIN 13
void setup()
{
// initialize LED digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
// wait for a second
delay(200);
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// wait for a second
delay(200);
}
I figured out the problem. As part of trying to get BlackMagic probe debugging working, a few weeks ago I edited .platformio/packages/framework-arduinosam/variants/feather_m0/linker_scripts/gcc/flash_with_bootloader.ld and I must have changed the Flash origin (without remembering or putting a note to myself about it). When I restored it (+0x2000) PlatformIO upload worked as smoothly as every - no problem.
Thank you so much for looking into my self-imposed problem.
I’m very sorry to have wasted your time with this.
When I run with debug_tool=blackmagic and build_flags=-ggdb3 it loads and shows me the first line of Arduino main.cpp. I step past the first lines of initialization to a delay(1) line right before USB initialization. Invariably the debugger breaks in the middle of an ISR and hangs there. Break/continue and the stack continues to be in the same location. I’ll collect more details later.
Sorry to keep you on the edge of your seat - I haven’t had a chance to explore more.
It doesn’t seem like anything in PlatformIO is broken. But specifying the board and debugger should build a binary that runs successfully. I suspect I need to find the right combination of build flags - maybe disable USB or disable the Adafruit Bootloader entirely.
Interesting to note: If I step into the delay() function and step around the loop
do
{
yield() ;
} while ( _ulTickCount - start < ms ) ;
the signal handler is never called (neither is _ulTickCount ever incremented, so I stay in the loop forever). Only when I Resume does it break in the signal handler.