SDU Boot for SAMD21

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.

  1. Program the SAMD21 with SDUBoot.ino.
  2. Export a program from Ardunio IDE(say Blink.ino) and save it in the SD card as UPDATE.ino.
  3. 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));

Difference is in SDUBoot.ino it is

uint32_t resetHandlerAddress = (uint32_t) * (SKETCH_START + 1);

whereas Atmel documentation says

app_start_address = *(uint32_t *)(APP_START + 4);

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

the flash layout:
0x0 bootloader
SDU_START SDUboot
SDU_START + SDU_SIZE sketch

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. .

Thanks in advance

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.

Thanks in advance for your cooperation.

Apologies @UKHeliBob.

If anyone could give me some insight on this, it would be great. I did try searching for a SDUBoot with SAMD51. But was not successful at all.

did you read my comment?

Hi Juraj,

I did. I was not able to get it working like that. But then I followed the below steps and got it working on SAMD21(Sparkfun Dev Breadkout board).

  • Change the flash origin address in linker script file.
  • Export the binary and save it in the SD card.
  • Flash the SDUBoot.ino to SAMD21

This got me working on SAMD21. Now I am trying to do the same thing on SAMD51 chip. Any ideas?

razor101:
Hi Juraj,

I did. I was not able to get it working like that. But then I followed the below steps and got it working on SAMD21(Sparkfun Dev Breadkout board).

  • Change the flash origin address in linker script file.
  • Export the binary and save it in the SD card.
  • Flash the SDUBoot.ino to SAMD21

This got me working on SAMD21. Now I am trying to do the same thing on SAMD51 chip. Any ideas?

the same steps?

Did not work for me.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.