In MPLAB, I need to use bootloader for PIC32MX795F512L. I am able to program boot section into kseg boot memory till 0x8fc00000 and application code into kseg0_program_mem at 0x9d000000. I can jump from bootloader to application using jump to addr command but I am facing problem while jumping from application to bootloader. I have tried with jump to addr (bootloader address) but it won't work. Please assist me
Asked
Active
Viewed 455 times
2 Answers
0
Just use a reset command, it will set you back to the processor start address. Check the POR bits for a SW reset to see if you caused the reset or if the board was just powered on.

blsmit5728
- 434
- 3
- 11
-
Checked same procedure. But its not getting reset to bootloader address – GeekCoder_Ajit Aug 04 '17 at 13:01
-
use: asm("reset"); and in the bootloader check if(RCONbits.SWR) /* I triggered bootloader */ – blsmit5728 Aug 07 '17 at 11:30
0
I found this in one of the many pdf's for my PIC32MX270, I believe it's consistent for the whole PIC32MX family:
/* The following code illustrates a software Reset */
// assume interrupts are disabled
// assume the DMA controller is suspended
// assume the device is locked
/* perform a system unlock sequence */
// starting critical sequence
SYSKEY = 0x00000000; //write invalid key to force lock
SYSKEY = 0xAA996655; //write key1 to SYSKEY
SYSKEY = 0x556699AA; //write key2 to SYSKEY
// OSCCON is now unlocked
/* set SWRST bit to arm reset */
RSWRSTSET = 1;
/* read RSWRST register to trigger reset */
_excep_code = RSWRST;
/* prevent any unwanted code execution until reset occurs*/
while(1);
The while(1) will also lock up the uC so that the watchdog should reset the device if all else fails. I've got this code in my exception handler too (system_exceptions.c if you are using Harmony), that way when something goes wonky (DMA disaster or you try to sprintf(foo_string, "%f", NAN)), the device will reset instead of becoming a paperweight.

grambo
- 283
- 2
- 10