Adafruit Feather m0 - firmware.bin not running



I am currently using the Arduino SDUBoot library allowing me to change sketches on the fly via an SD card on my Adafruit Feather M0 whilst being able to keep the standard boot loader.

All works fine, provided that I export the binary from Arduino IDE. For some reason, the firmware.bin file produced by PlatformIO does not load into the flash and I cannot determine why. The PIO sketches only work if directly built/uploaded, and not via SD card. Only the exported bin files from Arduino IDE work correctly.

Test Case:
SD Card: MS-DOS (FAT32)
Hardware setup - default SPI bus, but the SD CS is on hardware pin 8 (A2)

  1. Upload the SDUBoot project to Feather via USB. Connect SD card to SPI bus and CS to hardware pin 8 (A2)
  2. Format SD card to MS-DOS FAT32
  3. Copy FIRMWARE.bin from Blink_ArduinoIDE and insert SD card
  4. Press reset on board and the LED should flash 250ms on/250ms off
  5. Remove SD card and copy FIRMWARE.bin from Blink_PIO
  6. Press reset on board and see how LED speed doesn’t change (LED should flash 1s on/1s off) and how file doesnt get deleted from SD card
  7. Copy FIRMWARE.bin from Fade_ArduinoIDE and insert SD card
  8. Press reset on board and the LED should fade on and off slower than the boot loader fade

All I can assume is that PIO is doing something differently under the hood as the binary files seem a lot smaller than those from Arduino IDE. Then again, I’ve been staring at a screen for a long time, so I hope I am not missing something stupid.

Hoping someone has one of these boards and can help figure out what’s going on, as it’s extremely frustrating having to keep messing around with two different IDE’s.

Link to example code on Gitlab


Did you solve this?
I found a workaround for my Adafruit M0 custom board

  1. download the ArduinoCore for Samd

  2. modify ArduinoCore-samd-master/libraries/SDU/extras/SDUBoot/SDUBoot.ino to use your settings
    here are mine

     #ifndef SDCARD_SS_PIN
     #define SDCARD_SS_PIN 10
     #define UPDATE_FILE "UPDATE.BIN" 
  3. run the script /ArduinoCore-samd-master/libraries/SDU/extras/SDUBoot/ : it will use the Arduino IDE to compile a special bootloader into the ArduinoCore-samd-master/libraries/SDU/src/boot folder

  4. keep that zero.h file

  5. copy SDU.cpp and SDU.h into your src folder in the Platformio folder

  6. copy the zero.h freshly made into src/boot in your Plaftormio folder

  7. add #include <SDU.h> to your code and upload it once

  8. change something and copy the firmware.bin to the SD card and reset :smile:

I have tried in different projects: you just need to copy these 3 files at the right place in your various Platformio projects



sorry but this is not working on a second machine
I need to find why !


Could you try the latest upstream version? Does it work?


To be honest I ended up stopping using PIO completely because of weird quirks like this and the fact it hijacks Atom.

I’ll try again in the coming days.


In fact, it’s working again ONLY as I described it previously.
It’s ok for me like that and I don’t want to change anything for now
I’ll keep watching all the updates you make here:
to make sure it still works
Anyway it will require the user to make its own boot section prior to using it: maybe having the SDUBoot.ino in the src directory would be the solution to allows compiling the required boot section it before linking to the code
(not sure I am using the correct vocabulary but you get the idea)


Have you tried upstream version mentioned above?


We recommend migrating to PlatformIO IDE for VSCode.