Hello,
Im having a real hard time getting my bootloader to jump to my application.
I found this method searching the forum i liked it because i keep debug ability by not mixing asm and c.
// declare pmain var as a function pointer to a int(void) function int (*pmain)(void);
// do whatever you do, and load the target address in pmain pmain = (int (*)(void)) 0x2000; // cast it to the func ptr type
// ...
// now call the code pointed by pmain. pmain();
// pmain will never return ...
My Application code starts at 0x2000. I have created a jump table that offsets all the inturrupt jumps to start at base of 0x2000. (0x2000 is now essentially my startup inturrupt vector for my app).
This method of jumping only seems to work if i call the function imediatly on the entrance of the bootloader.
This will jump: main{
pmain = (int (*)(void)) 0x2000; pmain();
...rest of my BL code which will never execute
}
Adding 3 lines of code to disable the watchdog where shown here and my application no longer runs.
main{
[disable watchdog]
init_devices(); ... ...
One observation ive made is that it seems that pmain(); is infact called in both cases. I can watch as i step in the debugger in both examples a jump to 0x2000.
Obviously there is no point in the init_devices after the pmain() call. I just moved the function from where it was in my bootloader to the first line of main() and it worked. Then i started moving it down the line to see where it stoped working.
In the example that does not work, my app is unresponsive when i send a command to it via the Uart.
The watchdog gets disabled im my main app aswell, so i have no idea why this dosent work. How does disableing the Watchdog mess evertyhing up?
I really need to get this code working. Any help would be greatly appreciated.
Thanks, Tom