Hot!Jump from bootloader to App

Author
Blue_Key
Junior Member
  • Total Posts : 115
  • Reward points : 0
  • Joined: 2011/12/20 04:48:22
  • Location: 0
  • Status: offline
2018/11/05 09:57:15 (permalink)
0

Jump from bootloader to App

I wrote my own bootloader, and i'm trying to jump from the bootloader to the app.
 
I've used this method which appears often on the forum, without success. (it seems to do nothing at all).
 

void (*fptr)(void);
fptr = (void (*)(void))SOFT_MAIN_ADDRESS;
fptr();
 

 
BOOTLOADER_MAIN_ADDRESS being #define SOFT_MAIN_ADDRESS (0x9D000000 + 0x480)
 
Linker script of the app:
 
  kseg0_program_mem (rx) : ORIGIN = 0x9D000000 + 0x480, LENGTH = 0x100000 - 0x480
  kseg0_boot_mem : ORIGIN = 0x9D000000, LENGTH = 0x0
  debug_exec_mem : ORIGIN = 0x9FC20490, LENGTH = 0x3B20
  kseg0_boot_mem : ORIGIN = 0x9FC20490, LENGTH = 0x0
  kseg1_boot_mem : ORIGIN = 0x9D000000, LENGTH = 0x480
  kseg1_boot_mem_4B0 : ORIGIN = 0xBFC004B0, LENGTH = 0x3B00

 
 
I'm not sure to fully understand the boot sequence, or if there is any subtility to jump to the application ..?
#1

5 Replies Related Threads

    Jim Nickerson
    User 452
    • Total Posts : 5842
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: Jump from bootloader to App 2018/11/05 09:58:09 (permalink)
    0
    I wonder which processor you might be using ?
    #2
    Blue_Key
    Junior Member
    • Total Posts : 115
    • Reward points : 0
    • Joined: 2011/12/20 04:48:22
    • Location: 0
    • Status: offline
    Re: Jump from bootloader to App 2018/11/05 10:01:35 (permalink)
    0
    PIC32MK
    #3
    Jim Nickerson
    User 452
    • Total Posts : 5842
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: Jump from bootloader to App 2018/11/05 10:05:10 (permalink)
    0
    I think there might be a bootloader in Harmony you could have a look at to get some ideas.
    You could make the application a loadable project to the bootloader and debug the combination to see where it is jumping to.
     
    #4
    Blue_Key
    Junior Member
    • Total Posts : 115
    • Reward points : 0
    • Joined: 2011/12/20 04:48:22
    • Location: 0
    • Status: offline
    Re: Jump from bootloader to App 2018/11/05 10:29:09 (permalink)
    0
    I spent 8 hours trying to figure out how to user Harmony's bootloader, I went through the code and decided to give up.
     
    When I see harmony's code, I believe this project is already dead. I was hoping they would improve from the previous framework (upon which I spent about 5 years fixing bugs), but no, still keep cryptic function names, 200 lines while loops and non-sense... take a look at APP_ProgramHexRecord on nvm.c of the Harmony framework...
     
    Took 5h to write a new bootloader from scratch.
     
    Anyhow I think I found the problem, I forgot the _RESET_ADDR  directive from the linker.
     

    _RESET_ADDR = 0x9D000480;
    ....
    kseg0_program_mem (rx) : ORIGIN = 0x9D000000 + 0x800, LENGTH = 0x100000 - 0x800
    kseg0_boot_mem : ORIGIN = 0x9D000000, LENGTH = 0x0
    debug_exec_mem : ORIGIN = 0x9FC20490, LENGTH = 0x3B20
    kseg0_boot_mem : ORIGIN = 0x9FC20490, LENGTH = 0x0

     
    I'm still not sure if that's the correct way to put it but it seems to now work.
     
    I've seen another example here https://www.microchip.com/forums/m942247.aspx
    where the _RESET_ADDR  is set to the kseg1_boot_mem, which I tried but the linker then says pic32m-ld.exe: section .app_excpt loaded at [9d000180,9d00018f] overlaps section .reset loaded at [9d000000,9d0001f3]
    #5
    NKurzman
    A Guy on the Net
    • Total Posts : 17128
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Jump from bootloader to App 2018/11/05 12:11:49 (permalink)
    0
    fptr = (void (*)(void))0xbd000010; // set the reset address
    fptr(); // and call it
     
    Try the )0xbd address and make sure you have disable all the Interrupt, Not just the master flag.
    and I did not use the 0x480 offset  the reset vector is ox0. (unless you linker script moved it).
     
    #define SOFT_MAIN_ADDRESS (0xBD000000)
     
     
    #6
    Jump to:
    © 2019 APG vNext Commercial Version 4.5