Wednesday, 1 March 2023

Bootloader doesn't change reset vector

I am using MPLAB IDE, MPLAB XC8 v6 Compiler, PIC18F25Q10. We are working with a bootloader project. While in the bootloader phase, it is expected to update the application and jump to a certain address (example code offset = 0x1000). However, we are having problems with reset vector, interrrupt vectors. We cannot move the reset vector and interrupt vectors to an address we want.

We did some research on the forums, Low and High Interrupt vector addresses can be changed with a command like "IVTBASE", but it is not used in the processor we use (PIC18F25Q10). A different way is to try the following line of code.

#define PROG_START  0x1000  
asm("PSECT reset_vector,class=CODE,delta=2,abs");  
asm("ORG  0x00"); 
asm("GOTO " \___mkstr(PROG_START)" + 0x00");
asm("PSECT HiVector,class=CODE,delta=2,abs");  
asm("ORG  0x08");  
asm("GOTO " \___mkstr(PROG_START)" + 0x08");  
asm("PSECT LoVector,class=CODE,delta=2,abs");  
asm("ORG  0x18"); 
asm("GOTO " \___mkstr(PROG_START)" + 0x18");

When we load this code into the processor via ICD4, it works correctly with the vector addresses correctly moved to address 0x1000. However, it does not work when we throw it through the bootloader application. Our hex output is as in the photo below.

enter image description here

We have a problem when we print this hex file with the bootloader application. For example, the reset vector address of the first 3 lines in the hex file is 0x0000, High Vector address = 0x0008, Low vector address = 0x0018 . When we print in this way, these vector addresses and bootloader application addresses conflict. We print to flash in the bootloader application.

How can we move the reset vectors through the bootloader application correctly? thank you.



from Bootloader doesn't change reset vector

No comments:

Post a Comment