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.

CCS: Code Composer Studio™︎ forum

Other Parts Discussed in Thread: HALCOGEN, UNIFLASH, TMS570LC4357

Tool/software: Code Composer Studio

I try to make bootloader when the application is act with Hercules SafeTI Diagnostic Library.

There are some question to make bootloader. (The bootloader code is based on )

1. When I jump to application, There are some reset is occurred (maybe 2 times). I think this reset is occurred because the initialization is difference between bootloader and Safe Ti library.

I wonder there is no matter to change as follows,

(1) Origin : 4265.HL_sys_startup_origin.c

(2) Change : 6266.HL_sys_startup_change.c

2. About setting HL_sys_intvec.asm, I wonder why FIQ and IRQ are set as follows.

(1) When I set HL_sys_intvec.asm as follows, the application is not act.

;-------------------------------------------------------------------------------
; interrupt vectors

b _c_int00
b #0x2000F8 ; application start addr
b #0x2000F8 ; Software interrupt
b #0x2000F8 ; Abort (prefetch)
b #0x2000F8 ; Abort (data)
b #0x2000F8 ; phantom
b #0x2000F8 ; IRQ
b #0x2000F8 ; FIQ

(2) the application is act well.

;-------------------------------------------------------------------------------
; interrupt vectors

b _c_int00
b #0x2000F8 ; application start addr
b #0x2000F8 ; Software interrupt
b #0x2000F8 ; Abort (prefetch)
b #0x2000F8 ; Abort (data)
b #0x2000F8 ; phantom
ldr pc,[pc, #-0x1b0] ; IRQ
ldr pc,[pc, #-0x1b0] ; FIQ

Regards,

Minwoo

  • Hello Minwoo,

    Does your application code perform CPU selftest? After CPU selftest, the CPU reset is issued.

    You don't need to change the IRQ and FIQ address in HL_sys_intvec.asm. The following is the correct way for IRQ and FIQ:

    ldr pc,[pc, #-0x1b0]  
    ldr pc,[pc, #-0x1b0] 

    After the interrupt is received by the CPU, the CPU branches to 0x18 (IRQ) or 0x1C (FIQ). The instruction placed here should be LDR PC, [PC,#-0x1B0]. The pending ISR address is written into the corresponding vector register (IRQVECREG for IRQ, FIQVECREG for FIQ). The CPU reads the content of the register and branches to the ISR.

  • Hello QJ Wang,

    Thanks for your answer. But I stiil don'tu nderstand clearly. So, here are my questions.

    1. Your answer about my second question : it means that IRQ and FIQ is ACT in fixed Address, is alright?

    2. About CPU reset, The applications is based on Safe Ti Library. The Reset is occurred in the function SL_Init_R5Registers() of Application.

      - This phenomenon is occurred when the initialization of bootloader is different from Application. 

     -> My question is why the reset is occurred three times when the initialization is different.

    Regards,

    Minwoo

  • Hello Minwoo,

    1. Please use

        ldr pc,[pc, #-0x1b0]  
        ldr pc,[pc, #-0x1b0] 

        for IRQ and FIQ of both bootloader and application.

       In the application, for Undef, SVC, Prefetch, Data abort, etc, please use the interrupt handlers instead of the fixed address (#2000F8).

       for example:

    b _c_int00
    b _excpt_vec_udef_instr
    b _svc
    b _excpt_vec_abort_pref
    b _excpt_vec_abort_data
    b phantomInterrupt
    ldr pc,[pc,#-0x1b0]
    ldr pc,[pc,#-0x1b0]

     

  • Hello Minwoo,

    How do you know that the Reset is caused by SL_Init_R5Registers() of Application?

    You can add a while() before calling SL_Init_R5Registers(), then step into this function to check which instruction causes the reset problem.

    void _c_int00(void)
    {

    /* USER CODE BEGIN (5) */

       unsigned int abc=1;

       while(abc);

    /* USER CODE END */

    /* Initialize Core Registers to avoid CCM Error */

       SL_Init_R5Registers();

    After the execution jumps to application, it will run while(), then you can suspend the execution and change the abc to zero manually. 

  • Hello QJ wang,

    Thanks for your kind answer.

    The intvec setting problem is cleared.

    I check the reset occur in SL_Init_R5Registers() by as follow, (I use the debugger - SDS100i)

    1. bootloader download by debugger : 0x0 ~ 0x100000

    2. Application download by debugger : 0x200100 ~ 0x300000

    3. Start in application and Reset -> act bootloader

    4. jump to application by Serial (Uart)

    5. Make break point at SL_Init_R5Registers() in HL_sys_startup.c by debugger

    6. when step over SL_Init_R5Registers() -> the bootloader code act again.

    Regards,

    Minwoo

  • Hi Minwoo,

    Do you change the memory address for the application in linker cmd file?

    MEMORY

    {
           VECTORS (X) : origin = 0x00200100    length = 0x00000020
           FLASH (RX) :    origin = 0x00200120    length = ...

  • Hello QJ Wang,


    I already change the Application memory address as your guide.

    The problem is Chip reset when the bootloader initialization is different from application.

    After 2 times reset, the application act well. The act flow as followes,

    1.Bootloader act

    2. jump to 0x200100

    3. Reset (first time reset)

    4. Bootloader act

    5. jump to 0x200100

    6. Reset (second time reset)

    7. Bootloader act

    8. jump to 0x200100

    9. The application act well

    So, I change the initialization of bootloader (in _c_int00())

        /* Initialize Core Registers to avoid CCM Error */
        _coreInitRegisters_();
     
        /* Initialize Stack Pointers */
        _coreInitStackPointer_();

    change to

        SL_Init_R5Registers();

        /* Initialize Stack Pointers
         * The SL_Init_ResetReason API (and the correspondig HALCoGen getresetsource API) is a C function which uses stack.
         * Stack must be setup correctly before calling this function.*/
        SL_Init_StackPointers();

        SL_Init_Memory(RAMTYPE_RAM);
        /* Enable CPU Event Export */
        /* This allows the CPU to signal any single-bit or double-bit errors detected
         * by its ECC logic for accesses to program flash or data RAM.
         */
        /* NOTE - needs to be called on every reset */
        _SL_Init_EnableEventExport();

    to same as Safe Ti Library. Then, there are no reset when Jump to 0x200100.

    I wonder why the reset is occurred and It is no problem to initialize above the code.

    Regards,

    Minwoo 

  • Hello Minwoo,

    What happen if the board is power cycled? 

    Can you run the memory initialization before checking the reset source? The code generated by HALCoGen doesn't perform memory initialization if the reset is caused by CPU reset or SW reset which is used normally by bootloader.

  • Hello QJ Wang,

    I make the project as followes,

    boot-loader : 0x0 ~ 0x1FFFFF.

    Application : 0x200100 ~ 0x3FFFFF

    1. What happen if the board is power cycled?

    - Only the Bootloader is loaded. And stay the Uart key act as follower the given Boot-loader source.

    2. Can you run the memory initialization before checking the reset source?

    - I don't understand is question. In bootloader reference source, _coreInitRegisters_(); and _coreInitStackPointer_(); is acted in HL_sys_start. If there are more need to set in boot time?

    Regards,

    Minwoo

  • Hello Minwoo,

    I mean to call "_memInit_();" before "rstSrc = getResetSource();".

    /* Initialize Core Registers to avoid CCM Error */
    _coreInitRegisters_();

    /* Initialize Stack Pointers */
    _coreInitStackPointer_();

    /* Initialize L2RAM to avoid ECC errors right after power on */
    _memInit_();

    /* Reset handler: the following instructions read from the system exception status register
    * to identify the cause of the CPU reset.
    */
    rstSrc = getResetSource();
    switch(rstSrc)
    {

    ....

    The code generated by HALCOGen doesn't initialize the memory for SW reset and CPU reset.

  • Hello QJ Wang,

    I try to revise and act as your guide, but it is same.

    I check the where the reset is occurred, I find the LR address is wrong. why this case is happen?

    I check the as follows,

    1. Download bootloader 0x0 ~

    2. Download application 0x200100 ~

    3. Act with Debugger.

    4. System reset ( 0x0 start)

    5. Jump App(0x200100) - with serial

    6. Break point the application and Check LR

    The Result as followes,

    1. The correct address act : Use  HL_sys_startup_change.c  in first question.

    2. Weird address act : Ues HL_sys_startup_origin.c in first question. (Moreover, It is same result when _memInit_(); is added.

    (1) When first jump (0x200100)


    (2) When second jump (0x200100)

    (3) When third jump (0x200100)

    Additionally, I check as followes,

    1. Change mode  SVC (0x13) in finish of _coreInitRegisters_() in bootloader.

    2. Change mode  SVC (0x13) in start of SL_Init_R5Registers() in application

    All of them, act same.

    I wonder why LR address is different in application as bootloader initialization.

    Regards,

    Minwoo

  • Hello Minwoo,

    1. Download bootloader 0x0 ~

    2. Download application 0x200100 ~

    QJ> Is the application downloaded through the bootloader or through the CCS or Uniflash? 

    3. Act with Debugger.

    QJ> Is the CCS environment for application? 

    4. System reset ( 0x0 start)

    QJ> Is the system reset from CCS "System Reset" or from nRST button on board?

    5. Jump App(0x200100) - with serial

    QJ> what does "with serial" mean? 

            I thought the code jumps to application through instruction like:

            g_ulTransferAddress = (uint32_t)APP_START_ADDRESS;
            ((void (*)(void))g_ulTransferAddress)();

    Can your bootloader and application projects?

  • Hello, QJ Wang

    1. Download bootloader 0x0 ~

    2. Download application 0x200100 ~

    QJ> Is the application downloaded through the bootloader or through the CCS or Uniflash

    Minwoo> Download with CCS(Debugger : Only 0x200100 ~ 0x3FFFFF)

    3. Act with Debugger.

    QJ> Is the CCS environment for application? 

    Minwoo> Yes. to debug application

    4. System reset ( 0x0 start)

    QJ> Is the system reset from CCS "System Reset" or from nRST button on board?

    Minwoo> I use CCS "System Reset"

    5. Jump App(0x200100) - with serial

    QJ> what does "with serial" mean? 

    Minwoo> In the bootloader,  connect to PC and send "1"  (reference code is TMS570LC4357_UART_Boot )

    - the part of soure code

    {

       UART_putString(UART, "\r================== Main Menu ==========================\r\n");
       UART_putString(UART, "  1. Download Application Image To the Internal Flash \r\n");
       UART_putString(UART, "  2. Upload The Application Image From the Internal Flash \r\n");
       UART_putString(UART, "  3. Execute The Application Code \r\n");
       UART_putString(UART, "  4. Get Bootloader Version \r\n");
       UART_putString(UART, "  5. Get Device Information \r\n");

       UART_putString(UART,   "=======================================================\r\n\n");

       key = UART_getKey(UART);

       if (key == 0x31)
       {
          /* Download user application in the Flash */
          UART_Download();
       }
          else if (key == 0x32)
          {
            /* Upload user application from the Flash */
            UART_Upload();
          }
       else if (key == 0x33)
       {
        UART_putString(UART, "The application is running now !! \n\r\n\r");
              JumpAddress = (uint32_t)(APP_START_ADDRESS);
              ((void (*)(void))JumpAddress)();
       }

    }

    APP_START_ADDRESS -> set as 0x200100;

            I thought the code jumps to application through instruction like:

            g_ulTransferAddress = (uint32_t)APP_START_ADDRESS;
            ((void (*)(void))g_ulTransferAddress)();

    Can your bootloader and application projects?

    Minwoo> you mean show my projects?

    Bootloader code is based on the Source code as your applied in the other E2E forum. And just change sci1 register to sci4 register.

    So, I can show my project if you want.

    But, application code is hard to open.

    Regards,

    Minwoo

  • Hello,

    Minwoo> In the bootloader,  connect to PC and send "1"  (reference code is TMS570LC4357_UART_Boot )

    I think you mean "3" rather than "1"  -->  UART_putString(UART, "  3. Execute The Application Code \r\n");

  • Hello, QJ Wang

    I think you mean "3" rather than "1"  -->  UART_putString(UART, "  3. Execute The Application Code \r\n");  => I miss it, You are right .

    Then, I act as follow that I mentioned. I want to know the Reset reason when Initialization is different.

    Thanks and Regards,

    Minwoo 

  • Hello Minwoo,

    I will do test tomorrow. 

  • Hello QJ Wang,

    Thanks for your help.

    I think the Test firmware as followes, 

    Bootloader : TMS570LC4357_UART_Boot.7z in ()

    Application : Herculus Ti Safety library based sourse code.

     

    Regards,

    Minwoo

  • Hello Minwoo,

    I am using the same UART bootloader. 

  • Hello QJ Wang,

    I wonder the test result. Is it the same result or not?

    Regards,

    Minwoo 

  • Hello Minwoo,

    Attached are my test projects. TI LC43x launchpad is used. The applications blink one of USER LED.

    1. TMS570LC4357_UART_Boot: UART bootloader for LC43x

    2. TMS570LC43x_rtiBlinky_BL_APP200020: LED Blinky located at 0x200020. The binary file is located in debug folder.

    3. TMS570LC43x_rtiBlinky_BL_SDL_APP200020: 2nd application using APIs of safety library. The binary file is also located in debug folder.

    1830.TMS570LC43x_BL_and_Applications.zip