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
  • Hi,

    I tried this code ;

    1.   uint32_t v=0x00420000
    2.   asm volatile ("ldr sp,[%0,#0]": "=r" (v) : "0" (v)); 
    3.   ((start_fn *)  *((uint32_t *) 0x00420004))(); 

    Here's the output of my boot loader

    -- Boot Loader --

    VTOR:0x00400000                                                     <- I have a printf to show me the current VTOR value

    BootLoader Starting....

    BootVTORValue = 0xffffffff                                         <- This is the value read from flash location 0x00420004, before receiving the code

    waiting..... for 165 bytes                                             <- this is my code waiting for data

    PageNumber:511                                                       <- This is the code showing it has recived 512 pages (each being 256 bytes, so 64K)

    65536 Bytes Page Written to 00420000                    <- This is showing

    Wait For Flash Ready                                                <- Pause whilst flash writes

    NewBootVTORValue = 0x004220f9                          <- This is the value read from flash location 0x00420004, after receiving the code

    reboot                                                                         <- This is sent by the bootloader just before jumping to the new code.

    stack overflow 20015b68 Monitor                              <- this is what I got after trying your code.

    At this point, the PC is wrong, it's showing - 0x0040660A

    The SP is showing - 0x20014AC0

Reply
  • Hi,

    I tried this code ;

    1.   uint32_t v=0x00420000
    2.   asm volatile ("ldr sp,[%0,#0]": "=r" (v) : "0" (v)); 
    3.   ((start_fn *)  *((uint32_t *) 0x00420004))(); 

    Here's the output of my boot loader

    -- Boot Loader --

    VTOR:0x00400000                                                     <- I have a printf to show me the current VTOR value

    BootLoader Starting....

    BootVTORValue = 0xffffffff                                         <- This is the value read from flash location 0x00420004, before receiving the code

    waiting..... for 165 bytes                                             <- this is my code waiting for data

    PageNumber:511                                                       <- This is the code showing it has recived 512 pages (each being 256 bytes, so 64K)

    65536 Bytes Page Written to 00420000                    <- This is showing

    Wait For Flash Ready                                                <- Pause whilst flash writes

    NewBootVTORValue = 0x004220f9                          <- This is the value read from flash location 0x00420004, after receiving the code

    reboot                                                                         <- This is sent by the bootloader just before jumping to the new code.

    stack overflow 20015b68 Monitor                              <- this is what I got after trying your code.

    At this point, the PC is wrong, it's showing - 0x0040660A

    The SP is showing - 0x20014AC0

Children