PIC24 Firmware Bootloader doesn't start loaded program
I know this might not be the best place for this question but I tried the Microchip forum and didn't haven't gotten a response yet. I am working trying to get an HID bootloader project working on a prototype board that I build using a PIC24FJ64GB002. I modified the example HID Bootloader project to work with my board and I modified the example HID Mouse project to work with my board as well. When I program my device with the bootloader code it runs fine and the Microchip Bootloader Windows Program finds the device and displays "Device attached.". But when I try to load the hex file of the Mouse program onto my device it says it completes successfully but the mouse program never runs. I am not sure if I am using the correct linker scripts. Has anyone done this and know what linker scripts I should be using for the bootloader project and the 开发者_开发知识库loadable project?
I was able to get a breadboarded PIC24FJ64GB002 working with the Microchip HID bootloader and the Microchip HID mouse app.
The key things to do are use the the correct linker script for the bootloader and the app.
Bootloader Linker changes:
MEMORY
{
...
program (xr) : ORIGIN = 0x400, LENGTH = 0x1000
app_ivt : ORIGIN = 0x1400, LENGTH = 0xC0
...
}
__CODE_BASE = 0x400;
App linker changes:
MEMORY
{
...
app_ivt : ORIGIN = 0x1400, LENGTH = 0xC0
program (xr) : ORIGIN = 0x14C0, LENGTH = 0x96E8
...
}
__CODE_BASE = 0x200;
After you load the application via the bootloader, you must reset the device. The following code at the beginning of main() in the bootloader is what causes the bootloader to jump to the application.
mInitSwitch2();
if((sw2==1) && ((RCON & 0x83) != 0))
{
__asm__("goto 0x1400");
}
精彩评论