Writing bootloader for SAMD21 with SPI flash

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Hi,

I am currently trying to write a bootloader with the SAMD21 Xplained pro development kit by reading firmware from the EDBG UART and writing the firmware to the onboard SPI flash memory. I then use methods similar to the SAMD20 SPI master bootloader example project to load that file into memory. Through debugging, it seems as though I am writing the file into the NVM, but once I try to start the application from the application start address, the MCU seems to be doing nothing (or at least not running from the application start address).

I'm not completely sure how the below code works, and was hoping understanding that may give me some insight as to where my problem lies. I've also attached a picture of my debug window right before the last line of code is executed.

  

void (*application_code_entry)(void);

  /* Rebase the Stack Pointer */
  __set_MSP(*(uint32_t *) APP_START_ADDRESS);

  /* Rebase the vector table base address */
  SCB->VTOR = ((uint32_t) APP_START_ADDRESS & SCB_VTOR_TBLOFF_Msk);

  /* Load the Reset Handler address of the application */
  application_code_entry = (void (*)(void))(unsigned *)(*(unsigned *)(APP_START_ADDRESS + (uint32_t)0x00000004));

  /* Jump to user Reset Handler in the application */
  application_code_entry();

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Am afraid I can't help you with this right now.

But what all findings that you make will be really valuable to me as am expected to create a USB bootloader for SAM E70.

I haven't started doing the bootloader section, anyway, all the best.

Keep up the good work.

I'll let you know it i come across any important details

yes

Silly beans are always silly
:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Problem solved: Everything was working properly, but had to modify the linker in my new firmware file...

 

described in the creating a binary file section of this document: http://www.atmel.com/images/atme...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good work.yes

Silly beans are always silly
:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, could you share the code to store the firmware file onto the serial flash instead of an external USB storage? I would really appreciate.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i am also writing a bootloader for my samd21 19A i have given the bootloader address and app adress in trhe ld file but i getting no data after 00001c20 i have to write to my application flash from usb am new to this

Attachment(s):