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.

CC1311P3: Program Fault when using Timer in Bootloader

Part Number: CC1311P3


Tool/software:

I am implementing a bootloader on the CC1311P3.  I used Timer0 as a timer to trigger an LED blink so I know when the bootloader is running (or the application).  I noticed that when I use the timer and jump to the application, the system goes to a fault handler.  This happens even when I call Timer_stop() and Timer_close() in the bootloader before jumping to the application.  If I remove the Timer_* calls in the bootloader, the application seems to run normally.

Can this be fixed so I can use the timer in the bootloader?

  • Hi David,

    Are you starting from one of our examples? Also, what SDK version are you using, what compiler and such?

    Regards,

    Arthur

  • The bootloader and application are essentially done.  I started with examples but they are quite a bit more complex now then they were.

    simplelink_cc13xx_cc26xx_sdk_7_41_00_17

    ti-cgt-armllvm_4.0.2.LTS (under ccs2011)

    I have the CCFG generated with the bootloader project.  Bootloader is stored at 0x00050000, and the CCFG has set Address of Flash Vector Table set to 0x00050000.

    I use this function I found on the forums to jump to the application (loaded to 0x2000, there is an image header stored at 0x0):

    void jumpToPrgEntry(uint32_t *vectorTable)
    {   /* Reset the SP with the value stored at vector_table[0] */
        __asm volatile ("MSR msp, %0" : : "r" (vectorTable[0]) : );
    
        /* Jump to the Reset Handler address at vector_table[1] */
        ( (void (*)(void)) (*(vectorTable + 1)) )();
    }
    
    ...
    
    // Jump to app
    jumpToPrgEntry((uint32_t*)0x2000);

    I thought it interesting we don't need to set the VTOR in the NVIC like we do on other CPUs.  Maybe because many of the IRQs are handled by the ROM?

  • David,

    Can you share a dump of the core registers ? I want to see what kind of exception you are seeing.

    Also, are you using TI-RTOS, or no rtos at all in your bootloader?

    In our mcuboot examples, note that we reset the stack pointer as well:

    Regards,

    Arthur

  • I am using No RTOS.  Screenshot of the registers inside the FaultISR after calling Timer_stop().

    The fault occurs on call to Timer_stop().  If I comment out Timer_stop() and Timer_close(), the bootloader proceeds to jump function, but then I get a fault in the application.  There seems to be something wrong in the Timer API.

    Regarding the jump code, your referenced assembly and my C code appear equivalent.

    Regarding the VTOR, each image (bootloader and app) should have their own vector tables.  Normally you point the VTOR to the table for the image you are about to run, or set it during the init code of the image.  Only setting the MSP/PC is NOT the same as setting the VTOR.  I have to assume in this case either (A) the SimpleLink / ROM driver init code is handling the VTOR, or (B) the vectors are set to addresses in ROM code (so they don't change for the app vs. bootloader).  Is either of these correct?

    Clearly the IRQs work for the Timers and UART in both bootloader and app, so I have to assume the vectors are pointing to ROM or otherwise generic handlers.  Then I think this points the problem back to a Timer API issue.

  • Also the CPU_SCS might be helpful:

  • I figured it out.  I need to provide the Timer_Handle handle to Timer_close() and Timer_stop().  I was providing the CONFIG_TIMER_0 which is just an index and not the actual handle.  This can be closed.