This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Clean bootloader to application Jump

Hi,
I am developing a boot-loader for lpc1769 based custom board using KEIL uv5. My approach is to have a separate boot-loader project starting at flash 0x00000000. The main application is another project which exists at a higher address on flash. My boot-loader uses USB for communication with PC software as a simple VCOM and relies on reading some settings from I2C EEPROM. In short, it uses some RAM(all static data). Both my projects have default KEIL startup file and settings(taken from lpcopen 2.10 distribution) with only flash start address of application changed to a higher value. To jump after a successful Bootloader flash, I am trying to use this piece of code from
www.nxp.com/.../AN10866.pdf

__asm void boot_jump( uint32_t address ){
   LDR SP, [R0]         ;Load new stack pointer address
   LDR PC, [R0, #4]     ;Load new program counter address
}

void execute_user_code(void)
{
        /* Change the Vector Table to the USER_FLASH_START
        in case the user application uses interrupts */
        SCB->VTOR = USER_FLASH_START & 0x1FFFFF80;

        boot_jump(USER_FLASH_START);
}

I am not very convinced by this. First, I think before loading PC, the instruction pipeline should be flushed. Second, interrupts should be disabled as USB, systick all are active.
Now in my example, main application has it's own startup file, so it will do a copy of RW and ZI data to RAM. Because my application has same RAM start address as BL, I assume this is as good as reclaiming Bootloader RAM. But this means I will have to reinit USB and other peripherals. I am confused if this is the best way to do it as on every startup there is a overhead of init-deint peripherals and again init'ing them in main application. Also I guess, I have to manually clear Interrupt pending register before jumping to application. This bring me to my rather convoluted query. -
What would be the best way to have a 'fake' reset so that application starts cleanly at its address?
Is there any way to convince cortex m3 to start at a different address than 0x0000000 on reset?
Is it possible in KEIL debugger to set up two projects and see step through this jump from BL to application ?

Thanks.