This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSPM0G3107: Timer not working after jump to application from bootloader

Part Number: MSPM0G3107


Tool/software:

My bootloader is at 0x0000 and application at 0x2000, in application if i use delayCycle then it blinks led, but when i use timer then it not working.

this is my jump application

void jumpToNewApp(void)
{
    uint32_t newAppStackPointer = *((uint32_t *)(MAIN_BASE_ADDRESS));
    uint32_t newAppResetHandler = *((uint32_t *)(MAIN_BASE_ADDRESS + 4));

    NVIC_DisableIRQ(UART0_INT_IRQn);
    NVIC_DisableIRQ(TIMER_0_INST_INT_IRQN);

    // Disable interrupts
    __disable_irq();

    // Set Main Stack Pointer (MSP) to the new app's value
    __set_MSP(newAppStackPointer);

    SCB->VTOR = MAIN_BASE_ADDRESS;
   
    // Jump to the new app's Reset Handler
    AppEntryFunction appEntry = (AppEntryFunction)newAppResetHandler;
    appEntry();

}
  • Hi Sara,

    You can try use this code to jump from bootloader to app:

    __STATIC_INLINE void invokeBSLAsm(void)
    {
        /* Erase SRAM completely before jumping to BSL */
        __asm(
    #if defined(__GNUC__)
            ".syntax unified\n" /* Load SRAMFLASH register*/
    #endif
            "ldr     r4, = 0x41C40018\n" /* Load SRAMFLASH register*/
            "ldr     r4, [r4]\n"
            "ldr     r1, = 0x03FF0000\n" /* SRAMFLASH.SRAM_SZ mask */
            "ands    r4, r1\n"           /* Get SRAMFLASH.SRAM_SZ */
            "lsrs    r4, r4, #6\n"       /* SRAMFLASH.SRAM_SZ to kB */
            "ldr     r1, = 0x20300000\n" /* Start of ECC-code */
            "adds    r2, r4, r1\n"       /* End of ECC-code */
            "movs    r3, #0\n"
            "init_ecc_loop: \n" /* Loop to clear ECC-code */
            "str     r3, [r1]\n"
            "adds    r1, r1, #4\n"
            "cmp     r1, r2\n"
            "blo     init_ecc_loop\n"
            "ldr     r1, = 0x20200000\n" /* Start of NON-ECC-data */
            "adds    r2, r4, r1\n"       /* End of NON-ECC-data */
            "movs    r3, #0\n"
            "init_data_loop:\n" /* Loop to clear ECC-data */
            "str     r3, [r1]\n"
            "adds    r1, r1, #4\n"
            "cmp     r1, r2\n"
            "blo     init_data_loop\n"
            /* Force a reset calling BSL after clearing SRAM */
            "str     %[resetLvlVal], [%[resetLvlAddr], #0x00]\n"
            "str     %[resetCmdVal], [%[resetCmdAddr], #0x00]"
            : /* No outputs */
            : [ resetLvlAddr ] "r"(&SYSCTL->SOCLOCK.RESETLEVEL),
            [ resetLvlVal ] "r"(DL_SYSCTL_RESET_BOOTLOADER_ENTRY),
            [ resetCmdAddr ] "r"(&SYSCTL->SOCLOCK.RESETCMD),
            [ resetCmdVal ] "r"(
                SYSCTL_RESETCMD_KEY_VALUE | SYSCTL_RESETCMD_GO_TRUE)
            : "r1", "r2", "r3", "r4");
    }

    Thanks!

    Best Regards

    Johnson

  • I am working on custom bootloader. My interrupt problem for timer resolved by removing 

        // Disable interrupts
        __disable_irq();  


    Now I am able to jump Boot to App1, also App1 to Boot.
    Only facing issue when I write different app2 at same address of App1 then it's not working



  • Hi Sara,

    Does those two app have same memory configuration in compiler? If yes, I think should not have issue.

    Thanks!

    Best Regards

    Johnson

  • In both app only difference is led numbed all other is same. I am generating both .bin just editing led number.

    Both App working properly when I freshly flash through bootloader code.
    As like Boot to App1 and Boot to App2 working properly.

    Problem in Boot to App1 to Boot to App2

  • 1. I flash boot code through debugger.
    2. Flash App1 using UART.  It's working.

    3. Jump App1 to Boot successfully.

    4. In boot I write App2, This app2 not working.

    If I write App2 after fresh bootloader debug it's working 

  • Hi Sara,

    Some understand from my side as below:

    You can three image: BOOT + APP1 + APP2, and download those to MSPM0 together.

    BOOT in 0x00 address, and be able to jump to AAP1 or APP2, no issue here.

    But if you add some code in APP1, the function is jump to APP2, they you will encountered some issue?

    Thanks!

    Best Regards

    Johnson

  • no, my boot at 0x0000 and write App1 at 0x2000 and jump to 0x2000, it's working.

    Now I jump from App1(0x2000) to boot(0x0000) and my boot code running again.

    In boot I write App2 at (0x2000) and again jump to 0x2000, it's not working.

  • 1. Flash bootloader through debugger, write App1 using UART and jump to App1, It's working 

    2. Flash bootloader through debugger, write App2 using UART and jump to App2, It's working 

    3. Flash bootloader through debugger, write App1 using UART and jump to App1, It's working . Next I jump from App1 to Boot it's working, next I write App2 and trying to jump it's fail

  • Hi Sara,

    Understood, have you checked if the APP2 have been write normally via readout?

    Another point, not sure if this cause by SRAM or some register not cleared, you can try use the previous code I provide at above to jump from boot to app.

    Thanks!

    Best Regards

    Johnson

  •                         NVIC_DisableIRQ(UART0_INT_IRQn);
                            NVIC_ClearPendingIRQ(UART0_INT_IRQn);
                            SysTick->CTRL = 0;

                            SCB->VTOR = (uint32_t) (0x00000000);
                            NVIC_SystemReset();


    this is app to boot jump in both app same
  •     uint32_t newAppStackPointer = *((uint32_t *)(MAIN_BASE_ADDRESS));
        uint32_t newAppResetHandler = *((uint32_t *)(MAIN_BASE_ADDRESS + 4));

        NVIC_DisableIRQ(UART0_INT_IRQn);
        NVIC_ClearPendingIRQ(UART0_INT_IRQn);
        SysTick->CTRL = 0;

        // __disable_irq();

        // Set Main Stack Pointer (MSP) to the new app's value
        __set_MSP(newAppStackPointer);

        SCB->VTOR = (uint32_t) (MAIN_BASE_ADDRESS);
       
        // Jump to the new app's Reset Handler
        AppEntryFunction appEntry = (AppEntryFunction)newAppResetHandler;
        appEntry();



    this is boot to app jump. both app i am writing at 0x2000
  • app1 and app2 are just my software version change

  • I am not using bootloader provinded in SDK example. I write bootloader code as such it only receive .bin through uart and write in flash at 0x2000, without using BCR ans BSL configuration of MSPM0

  • Hi Sara,

    Understood, just very general software bootloader. Let me check with team if have some idea and back here.

    Thanks!

    Best Regards

    Johnson

  • this issue resolved, I was not erasing flash correctly. 

  • Looks fine. Great!