MKR1000 SDU soft reset

Hi,

So i'm trying to get the SDU library to work with my MKR1000 and from my understanding, the SDU library need to get a hard reset to update the sketch

__set_MSP(*SKETCH_START);
SCB->VTOR = ((uint32_t)(SKETCH_START) & SCB_VTOR_TBLOFF_Msk);
uint32_t resetHandlerAddress = (uint32_t) * (SKETCH_START + 1);
asm("bx %0"::"r"(resetHandlerAddress));

I'm wondering if i can use a watchdog reset (Adafruit Sleepydog library) instead?
How would i do it?
thanks

NVIC_SystemReset();

Where do i put it in the code to actually have it update, all it does is reset the current code?

dfontaine:
Where do i put it in the code to actually have it update, all it does is reset the current code?

if your sketch includes the SDU library, it works like a second stage bootloader. it checks the SD card and if it finds an bin for update it applies it and resets again.

if you save the bin to card in a PC and then put it in the Arduino and the sketch in the Arduino runs with SDU library, it will load the new sketch on startup.

if you load the bin to SD in the Arduino over networks, spi, i2c, Serial, the you must reset the Arduino after saveing the bin to card to apply the update. again the sketch active in Arduino must include the SDU library

I saved the UPDATE.bin from my PC.

I modified the SDUBoot.ino to match the mrk specs and set the CS pin to 11 (the one i'm using) but it doesn't want to update. i just need to include the SDU.h in the sketch right?

i'm kind of running out of ideas to be honest, i even tried to integrate the SDUBoot into my code, needless to say, it didint work.

Do i have to do something with the linker script?

dfontaine:
I saved the UPDATE.bin from my PC.

I modified the SDUBoot.ino to match the mrk specs and set the CS pin to 11 (the one i'm using) but it doesn't want to update. i just need to include the SDU.h in the sketch right?

i'm kind of running out of ideas to be honest, i even tried to integrate the SDUBoot into my code, needless to say, it didint work.

Do i have to do something with the linker script?

SDU is not a normal library. the included .h file contains only binary code of the second stage bootloader.

SDUBoot is the source code of the second stage bootloader which is first compiled to a bin. this bin is then converted to a C array and put into the SDU.h.

why not send the update over WiFi with WiFi101OTA library? it doesn't need the SD card

i can't manually push the updates, arduino has to check with a custom c++ server if any updates are available. the server then pushes the .bin file to it.

The OTA functionality is what i need but i can't use the IDE and i dont know how to push to the network port without the IDE. i figured that the server could push it to the MKR, who would then store it to the SD card and then update itself.

dfontaine:
i can't manually push the updates, arduino has to check with a custom c++ server if any updates are available. the server then pushes the .bin file to it.

The OTA functionality is what i need but i can't use the IDE and i dont know how to push to the network port without the IDE. i figured that the server could push it to the MKR, who would then store it to the SD card and then update itself.

You can do the same simpler with the InternalStorage object of the WiFi101OTA library. It has a simple interface and stores and then applies the new bin

But the doesn't it use the board's ram? My updates are 90kb and will only get bigger

dfontaine:
But the doesn't it use the board's ram? My updates are 90kb and will only get bigger

InternalStorage uses upper half of the flash memory to store the binary. On apply() it moves the binary at the run location and resets the board.