I know questions regarding to SDU have been asked quite a number of times in this forum. But I cannot seem to find any solid answer on how to get it working. I'll keep my question as detailed as possible so that it would benefit many.
So I am working on SDUBoot.ino example and the way I have tried to get it working is as below.
Program the SAMD21 with SDUBoot.ino.
Export a program from Ardunio IDE(say Blink.ino) and save it in the SD card as UPDATE.ino.
I have checked it with an Atmel ICE and I can see the address space is being properly written from the SD card to the flash. So it is fair enough to assume that writing from SD to flash is working.
The part where I am stuck is the next few steps.
// jump to the sketch
__set_MSP(*SKETCH_START);
//Reset vector table address
SCB->VTOR = ((uint32_t)(SKETCH_START) & SCB_VTOR_TBLOFF_Msk);
// address of Reset_Handler is written by the linker at the beginning of the .text section (see linker script)
uint32_t resetHandlerAddress = (uint32_t) * (SKETCH_START + 1);
// jump to reset handler
asm("bx %0"::"r"(resetHandlerAddress));
Nothing seems to be happening after that and definitely the Blink program is not running.
I also saw another code snippet from Atmel that in order to create a soft reset, you should do the following.
#define APP_START 0x00000000
uint32_t app_start_address; //Global variable
app_start_address = *(uint32_t *)(APP_START + 4);
/* Rebase the Stack Pointer */
__set_MSP(*(uint32_t *) APP_START);
/* Rebase the vector table base address */
SCB->VTOR = ((uint32_t) APP_START & SCB_VTOR_TBLOFF_Msk);
/* Jump to application Reset Handler in the application */
asm("bx %0"::"r"(app_start_address));
All in all, I have tried both methods but unable to get the sketch working after uploading from the SD card. Any insights would be highly appreciated.
Thanks in advance
the SDUboot expects that the binary in update.bin contains the SDU library.
it skips that part and writes the rest after SDUboot area, then it jumps to sketch address
SDU library is an array containing the compiled SDUBoot sketch and padding to 4kB. the linker puts the section for this array at the beginning of the binary.
when you do a Serial upload the sketch is written as normal, but first the SDUBoot code is executed. it then jumps to sketch code
As far as I am aware, I think the SDUBoot library is only supported by SAMD21 chip family. I am just wondering if someone has figured out a way to get the SDU library(or a similar way of flashing the chip using SD card) working on SAMD51J19A. .
Duplicate topics moved to the same forum section and merged
Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting will result in a timeout from the forum.
In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.