SAMD20G17 not jumping to application in SAM-BA bootloader

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

Hi

 

I have a bootloader running on my custom board using SAMD20G17. UART, LEDs and NVM read/write are working. However when I try to jump to the application, it fails to jump. 

 

The main app is built on Atmel Studio 7 using Start project. The main app start address is defined as byte address 0x1000. In flash, I have verified that bootloader is programmed at 0x0 and main app is programmed at byte address 0x1000. In bootloader code, the application start address is defined as 0x800 (because flash is u16 addressed, right?)

 

This is my jump routine

static void start_application()
{
        uint32_t app_start_address;

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

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

        /* Jump to application Reset Handler in the application */
        app_start_address = *(uint32_t *)(APP_START_ADDRESS + 4);
        asm("bx %0"::"r"(app_start_address));
}

Any clues on why the jump to main app is failing?

TIA

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

 u16 addressed? The original main.c has 

#if SAM_BA_INTERFACE == SAM_BA_USBCDC_ONLY  ||  SAM_BA_INTERFACE == SAM_BA_UART_ONLY
#define APP_START_ADDRESS                 0x00001000
#elif SAM_BA_INTERFACE == SAM_BA_BOTH_INTERFACES
#define APP_START_ADDRESS                 0x00002000
#endif

(and that define is used like in your code) so no, not u16 addressed. 

/Lars