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

SMT32 bootloader / application

Hi,

using a SMT32F103 processor, I want to install an bootloader as well as an application. Two different projects, so that the bootloader (usb) is able to erase / update the application on this processor.

Is it possible to debug the application when the bootloader is starting first?

Is this a proper way to jump from the bootloader app to the application?

// switch to supervisor mode so that stacks in the next startup file can be set (once is
// user mode, only an exception can bring the processor out of it. SWI is such an exception.)
void __swi(0) jump_to_application_code(void);
void __SWI_0  (void)
{
    void   (*lp_application_start)(void);

    // interrupt vectors are mapped using the RAM_INTVEC REMAP RAM_MODE macros in the ASM tab of uv3
    lp_application_start = (void (*)(void))APPLICATION_FLASH_START;
    lp_application_start();

}

int main(void)
{
        jump_to_application_code() ;
}

Do I have to do additional things for the normal application? for example: that all interrupts will work in the application?

best regards
Harald

Parents
  • Is it possible to debug the application when the bootloader is starting first?

    Yes - of course. But you cannot "debug" both at the same time. The best you can hope for the debug one's source, and place a breakpoint in the disassembly of the other, assuming debug information is used.

    Is this a proper way to jump from the bootloader app to the application?

    No. You need to extract the reset vector and the stack pointer from the interrupt vector first, like this:

    __asm void jump_to_application(void)
    {
        ; program stack pointer of application
        LDR     R0, =0x1000
        LDR     SP, [R0]
    
        ; extract entry point into application
        LDR     R0, =0x1004
    
        ; jump
        LDR     PC, [R0]
    }
    

    assuming your application starts at 0x1000.

Reply
  • Is it possible to debug the application when the bootloader is starting first?

    Yes - of course. But you cannot "debug" both at the same time. The best you can hope for the debug one's source, and place a breakpoint in the disassembly of the other, assuming debug information is used.

    Is this a proper way to jump from the bootloader app to the application?

    No. You need to extract the reset vector and the stack pointer from the interrupt vector first, like this:

    __asm void jump_to_application(void)
    {
        ; program stack pointer of application
        LDR     R0, =0x1000
        LDR     SP, [R0]
    
        ; extract entry point into application
        LDR     R0, =0x1004
    
        ; jump
        LDR     PC, [R0]
    }
    

    assuming your application starts at 0x1000.

Children