Atmel SAM4E Bootloader/VTOR executing new application

I've written a boot loader for the Atmel SAM4E device which is working to a point, it can receive new application code via SPI, erase flash and write to flash, but I don't understand how to execute the new application. I've learned the VTOR can be relocated, but I'm not sure how. (my application sits at address 0x00420000).
I'm very new to writing code for ARM, so I'd appreciate any help.

Many thanks

Paul

Parents
  • I just checked the code in flash;

    :020000040042B8

    :10000000A0450020F92042006920420069204200FA

    Pulling out the first 32bit word in the VTOR gives me the SP; A0450020

    Putting that the correct way round gives; 200045A0,

    Stepping through the code, after this line has run - asm volatile ("ldr sp,[%0,#0]": "=r" (v) : "0" (v));

    it does indeed show SP as 200045A0

    However when the next line - ((start_fn *)  *((uint32_t *) 0x00420004))();

    Causes the stack overflow but the PC is showing as 0x0040660A, so is in the boot loader code rather than the application code.


    Paul

Reply
  • I just checked the code in flash;

    :020000040042B8

    :10000000A0450020F92042006920420069204200FA

    Pulling out the first 32bit word in the VTOR gives me the SP; A0450020

    Putting that the correct way round gives; 200045A0,

    Stepping through the code, after this line has run - asm volatile ("ldr sp,[%0,#0]": "=r" (v) : "0" (v));

    it does indeed show SP as 200045A0

    However when the next line - ((start_fn *)  *((uint32_t *) 0x00420004))();

    Causes the stack overflow but the PC is showing as 0x0040660A, so is in the boot loader code rather than the application code.


    Paul

Children