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 GitHub - arduino/ArduinoCore-samd: Arduino Core for SAMD21 CPU

  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: Releases · platformio/platform-atmelsam · GitHub
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.

Old thread, but maybe helpful for people finding it on Google…

That sounds similar to a problem I had with an Arduino MKR GSM 1400.
Here is what I did to fix it for me. Maybe it’s helpful to you, too.

For the SAMD boards there is a library called “SDU” for OTA update via SD card.

There seems to be a difference in the way how PlatformIO and Arduino IDE compile the code: In Arduino IDE it is working as expected, in PlatformIO it’s not.
Here is what I did to fix it:

  1. Usually you #include <SDU.h> in your code. Change it to #include <SDU_fixed.h>.
  2. Make a new file “SDU_fixed.h”:
#ifndef SDU_fixed_h
#define SDU_fixed_h

#include <Arduino.h>

// copy and paste code from h-file according to your board model from
// here: mkrgsm1400.h
__attribute__((section(".sketch_boot"))) unsigned char sduBoot[0x4000] = {
    0x00, 0x80, 0x00, 0x20, 0x95, 0x3b, 0x00, 0x00, 0x7d, 0x3b, 0x00, 0x00,
    0x7d, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x1d, 0x48, 0x00, 0x00, 0xc1, 0x4a, 0x00, 0x00, 0xb5, 0x20, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00};

#endif // SDU_fixed_h
  1. The difference to the original library is that we copy and paste the board specific code for sduBoot directly instead of including the file (here: mkrgsm1400.h) containing the code. Here you have to copy and paste the code according to your board model. (Then of course your code is only working for that specific model.)

First, you could try this fix with the example here ArduinoCore-samd/libraries/SDU/examples/Usage at master · arduino/ArduinoCore-samd · GitHub
An indicator of whether it worked or not is when the file size of the firmware.bin increases by 16KB.
(“firmware.bin” need to be renamed to “UPDATE.bin” before putting it on the SD card)

Again old thread, but I found this thread while debugging this problem.

I looked into this a bit and I think the problem with SDU in platformio is that
SDU doesn’t export any symbols, so if it is linked in as an archive dot-a file,
then the SDU code doesn’t get linked in.

The solution proposed above, to put the code directly in the header file, works
because it compiles the code into the current file rather than relying on the linker
to bring it in. But there is a simpler solution that works for me on my
feather adalogger board:

Find the SDU/src library under .platformio/packages. In that directory add
a file called ‘library.json’ with the contents:

    "name": "SDU",
    "version": "1.0.0",
    "authors": [
            "name": "Arduino",
            "email": "",
            "url": "",
            "maintainer": "Arduino <>"
    "description": "Update the sketch on your board from an SD card",
    "platforms": [
    "build": {
        "libArchive": false

The key part of this is the ‘libArchive false’. That tells the platformio build process
to link in the SDU code even though there aren’t any symbols that we need from
it. And, as described above, if you do this, you should see the executable size
increase by 16KB.

Maybe there’s a better way of controlling the build process as I’m fairly new to
platformio, but for now this works for me.

  • Denis