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.

TMS570LC4357, Boot Loader - Application software with interrupt dispatcher

Other Parts Discussed in Thread: TMS570LC4357

Hi all,

I have two separate projects with the controller TMS570LC4357.

One is called "Boot Loader" and one is my "Application". The "Boot Loader" is stored in the flash0 ssector.
Vectors 0x00000000, lenght 0x20.
Flash0    0x00000020 ,lenght 0x1FFFE0

The "Application" is stored in flash1 sector.
Vectors 0x00200000, lenght 0x20.
Flash0    0x00200020 ,lenght 0x1FFFE0

The "Application" software is using the interrupt dispatcher mode. I used the dispacther code:
; irqDispatch_a.asm
; (c) Texas Instruments 2009-2012, All rights reserved.

and

/** @file  irqDispatch_c.c
 *  @brief contains Second Level IRQ Dispatcher C routine
 *  @date  5/13/2014

I want to use the RTI to generate a independet milli second timer in my application software.

And I wrote the following code (File: HL_sys_intervecs.asm) to jump from the Boot loader into the Application:

********************************************************************************
    .sect ".intvecs"

;-------------------------------------------------------------------------------
; import reference for interrupt routines

    .ref _c_int00
;-------------------------------------------------------------------------------
; interrupt vectors
; Please change the #0x???? for your specified image location defined in bl_config.h

        b   _c_int00               ;0x00
        b   #0x1FFFF8              ;0x04
        b   #0x1FFFF8              ;0x08, Software interrupt
        b   #0x1FFFF8              ;0x0C, Abort (prefetch)
        b   #0x1FFFF8              ;0x10, Abort (data)

reservedEntry
        b   reservedEntry          ;0x14, reserved
        b   #0x1FFFF8              ;0x18, irqDispatcher
        ldr pc,[pc, #-0x1b0]       ;0x1C, FIQ


The jump from the Boot Loader to the Application software is running. The first milli second interrupt (RTI) in my application is also running.
But than my system crashes.


Any ideas where I have to look to find my failure ?


Best regards

Lars

  • Hi Lars,
    How do you jump from bootloader to application? Does it matter if you use the RTI or not in the application code? In your application code did you have correct setup for all the stack pointers in different CPU modes?
  • Hi Charles,


    as I wrote the Boot Loader is stored in the area:

    flash0 ssector.
    Vectors 0x00000000, lenght 0x20.
    Flash0    0x00000020 ,lenght 0x1FFFE0

    and the Application software is stored in the area:

    flash1 sector.
    Vectors 0x00200000, lenght 0x20.
    Flash0    0x00200020 ,lenght 0x1FFFE0

    -------------------------------------------------------------------------------------------------------------

    The jump fom the boot loader to the application software is realized like:

        ucTestPin = (((uint8)gioPORTA->DIN) & 0x80u);

        if(ucTestPin == OPEN){
            /* Start Application */
            StartAddress = (uint32_t)0x00200000;
            ((void (*)(void))StartAddress)()
        }else{
            BOOT_MONI_START();
        }

    I read a Pin, if the pin is set --> Boot Loader starts, if not jump to address 0x200000 (Application sofwtare).

    -------------------------------------------------------------------------------------------------------------

    The start of the application software is:

    File: HL_sys_invecs

        .sect ".intvecs"
        .arm

        .ref _c_int00
        .ref _irqDispatch
        .ref phantomInterrupt
        .def resetEntry

    resetEntry
            b   _c_int00
    undefEntry
            b   undefEntry
    svcEntry
            b   svcEntry
    prefetchEntry
            b   prefetchEntry
    dataEntry
            b   dataEntry
            b   phantomInterrupt
            b   _irqDispatch
            ldr pc,[pc,#-0x1b0]

    File HL_sys_startup.c

    void _c_int00(void);

    #pragma CODE_STATE(_c_int00, 32)
    #pragma WEAK(_c_int00)

    void _c_int00(void)
    {
        _coreInitRegisters_();

        _memInit_();

        _coreInitStackPointer_();

    -------------------------------------------------------------------------------------------------------------

    The function coreInitStackPointers includes:

        .def     _coreInitStackPointer_
        .asmfunc

    _coreInitStackPointer_

            cps   #17
            ldr   sp,       fiqSp
            cps   #18
            ldr   sp,       irqSp
            cps   #19
            ldr   sp,       svcSp
            cps   #23
            ldr   sp,       abortSp
            cps   #27
            ldr   sp,       undefSp
            cps   #31
            ldr   sp,       userSp
            bx    lr

    userSp  .word 0x08000000+0x00001000
    svcSp   .word 0x08000000+0x00001000+0x00000100
    fiqSp   .word 0x08000000+0x00001000+0x00000100+0x00000100
    irqSp   .word 0x08000000+0x00001000+0x00000100+0x00000100+0x00000100
    abortSp .word 0x08000000+0x00001000+0x00000100+0x00000100+0x00000100+0x00000100
    undefSp .word 0x08000000+0x00001000+0x00000100+0x00000100+0x00000100+0x00000100+0x00000100

        .endasmfunc

    Hope this will help.


    Best regards

    Lars

  • Hi Lars,
    Looking at your code I don't really spot anything wrong.

    Could you please tell me if you are getting any abort exception when you said the system crashed?

    You said something about the RTI was working at least for the first time and afterward it crashed. What if you disable the RTI and will it still crash?
    After crash, did you notice any flags in the ESM status registers?

    I will also suggest that you put a breakpoint at the line 'b #0x1FFFF8 ;0x18, irqDispatcher' and observe how the RTI interrupt is dispatched to its ISR handler.
  • HI,


    thanks for your help. The Problem is an abort exception from the Boot Loader --> Line       

    b   #0x2FFFF8              ;0x10, Abort (data)


    The Abort_Registers are:

    SPSR_ABT= 0x800003D2

    R13_ABT = 0x08001400

    R14_ABT = 0x0030F204


    and the ESM Register are all zero except

    Stat1 = 0x00000008

    IntOffstHgh = 0x00000024

    LtCntPre = 0x00003FFF

    ShdwStat2 = 0x00000008

    Do you have any idea where I have to look ?

    Best regards

    Lars

  • Hi Lars,

     The abort exception was taken after you are already running in the application, right?

     Not sure if you have a typo. You have b   #0x2FFFF8              ;0x10, Abort (data). Shouldn't it be b   #0x1FFFF8              ;0x10, Abort (data)?

     Can you also read out the DFSR (Data Fault Status Register) and DFAR (Data Fault Address Register) inside the CPU? They provide the source of the abort. 

  • Hi,

    I found the error, the problem was initialisation from the application software. The followiing codeline solves the problem in the application software, file HL_sys_startup.c:

        switch(getResetSource())
        {
            case POWERON_RESET:
            case DEBUG_RESET:
            case EXT_RESET:

    /* USER CODE BEGIN (6) */
            case NO_RESET:             <<<<<------------------ new code line
    /* USER CODE END */

    Thanks a lot

    Best regards

    Lars

  • Hi Lars,
    Could you elaborate a bit about how the problem is resolved by adding the 'case NO_RESET'? When you jump from the bootloader to the application and since there is no reset, where did the code end up that caused to crash/abort? It will certainly help the community if similar problem arises?

    Also if you problem is resolved, can you please close the thread by clicking the 'Verify Answer' button? Thanks.
  • Hi,

    what I have done is the following things:

    I have two projects, one is called Boot Loader and one is called application SW as I wrote before.

    The problem was the initialisation of the system. If power on the processor it jumps to the files "HL_sys_intvecs.asm", "HL_sys_startup.c" and later in the main file of the Boot Loader. The initialisation of the porcessor is done in the file "HL_sys_startup.c".

    To jump from the boot loader into the application SW I used the following code lines in the main:

        ucTestPin = (((uint8)gioPORTA->DIN) & 0x80u);

        if(ucTestPin == OPEN){
            /* Start Application */
            StartAddress = (uint32_t)0x00200000;
            ((void (*)(void))StartAddress)()
        }else{
            BOOT_MONI_START();
        }

    But if the porcessor jumps into the application SW (StartAddress) the files HL_sys_intvecs.asm" and "HL_sys_startup.c are repeated (Project application SW). In the file "HL_sys_startup" no condition (POWERON_RESET, DEBUG_RESET, EXT_RESET) for a new initialisation is given. So I made a new case, called "NO_RESET" (possible return value from the file "getResetSource") to make a new initialisation of my application SW.

    Best regards

    Lars