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:
- Usually you
#include <SDU.h>
in your code. Change it to #include <SDU_fixed.h>
.
- 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 https://github.com/arduino/ArduinoCore-samd/tree/master/libraries/SDU/src/boot
// 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
- 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)