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.

TMS320F28388D: How to jump to entry point of secondary application in CM

Part Number: TMS320F28388D

Hello,

I'm writing some applicaiton which acts as an bootloader and flash writer for firmware update.

But I'm struck in some problem. It has ended up that it fails to jump to the secondary application from the bootloader app.

The code of my own boot application for jumping to the second app is like below.

//
// Included Files
//
#include "driverlib_cm.h"
#include "cm.h"

#define APP_START_ADDRESS               0x00270000U

void exit(uint32_t address){
    //
    // Jump to entry address
    //
    __asm("   bx r0");
}

//
// Main
//
void main(void)
{
    CM_init();
    GPIO_writePin(120U,0);

    exit(APP_START_ADDRESS);
}

//
// End of File
//

and the link command script is the same as below.

MEMORY
{
   /* Flash sectors */
   CMBANK0_RESETISR : origin = 0x00200000, length = 0x00000008 /* Boot to Flash Entry Point */
   CMBANK0_SECTOR0  : origin = 0x00200008, length = 0x00003FF8
   CMBANK0_SECTOR1  : origin = 0x00204000, length = 0x00004000
   CMBANK0_SECTOR2  : origin = 0x00208000, length = 0x00004000

   C1RAM            : origin = 0x1FFFC000, length = 0x00002000
   C0RAM            : origin = 0x1FFFE000, length = 0x00002000

   BOOT_RSVD        : origin = 0x20000000, length = 0x00000800 /* Part of S0, BOOT rom will use this for stack */
   S0RAM            : origin = 0x20000800, length = 0x00003800
   S1RAM            : origin = 0x20004000, length = 0x00004000
   S2RAM            : origin = 0x20008000, length = 0x00004000
   S3RAM            : origin = 0x2000C000, length = 0x00004000
   E0RAM            : origin = 0x20010000, length = 0x00004000

   CPU1TOCMMSGRAM0  : origin = 0x20080000, length = 0x00000800
   CPU1TOCMMSGRAM1  : origin = 0x20080800, length = 0x00000800
   CMTOCPU1MSGRAM0  : origin = 0x20082000, length = 0x00000800
   CMTOCPU1MSGRAM1  : origin = 0x20082800, length = 0x00000800
   CPU2TOCMMSGRAM0  : origin = 0x20084000, length = 0x00000800
   CPU2TOCMMSGRAM1  : origin = 0x20084800, length = 0x00000800
   CMTOCPU2MSGRAM0  : origin = 0x20086000, length = 0x00000800
   CMTOCPU2MSGRAM1  : origin = 0x20086800, length = 0x00000800
}

SECTIONS
{
   .resetisr        : > CMBANK0_RESETISR
   .vftable         : > CMBANK0_SECTOR0   /* Application placed vector table in Flash*/
   .vtable          : > S0RAM             /* Application placed vector table in RAM*/
   .text            : >> CMBANK0_SECTOR0 | CMBANK0_SECTOR1
   .cinit           : > CMBANK0_SECTOR0
   .pinit           : >> CMBANK0_SECTOR0 | CMBANK0_SECTOR1
   .switch          : >> CMBANK0_SECTOR0 | CMBANK0_SECTOR1
   .sysmem          : > S2RAM

   .stack           : > C1RAM
   .ebss            : > C1RAM
   .econst          : >> CMBANK0_SECTOR0 | CMBANK0_SECTOR1
   .esysmem         : > C1RAM
   .data            : > S3RAM
   .bss             : > S3RAM
   .const           : >> CMBANK0_SECTOR0 | CMBANK0_SECTOR1

    MSGRAM_CM_TO_CPU1 : > CMTOCPU1MSGRAM0, type=NOINIT
    MSGRAM_CM_TO_CPU2 : > CMTOCPU2MSGRAM0, type=NOINIT
    MSGRAM_CPU1_TO_CM : > CPU1TOCMMSGRAM0, type=NOINIT
    MSGRAM_CPU2_TO_CM : > CPU2TOCMMSGRAM0, type=NOINIT

    .TI.ramfunc : {} LOAD = CMBANK0_SECTOR0,
                     RUN = C0RAM,
                     LOAD_START(RamfuncsLoadStart),
                     LOAD_SIZE(RamfuncsLoadSize),
                     LOAD_END(RamfuncsLoadEnd),
                     RUN_START(RamfuncsRunStart),
                     RUN_SIZE(RamfuncsRunSize),
                     RUN_END(RamfuncsRunEnd),
                     ALIGN(8)
}

/*
//===========================================================================
// End of file.
//===========================================================================
*/

The link command of the secondary application where the bootapp above is trying to jump to is like this,

MEMORY
{
   /* Flash sectors */
   CMBANK0_RESETISR10 : origin = 0x00270000, length = 0x00000008 /* Boot to Flash Entry Point */
   CMBANK0_SECTOR10_11 : origin = 0x00270008, length = 0x00007FF8
   CMBANK0_SECTOR12 : origin = 0x00278000, length = 0x00004000
   CMBANK0_SECTOR13 : origin = 0x0027C000, length = 0x00004000

   C1RAM            : origin = 0x1FFFC000, length = 0x00001FFF
   C0RAM            : origin = 0x1FFFE000, length = 0x00001FFF

   BOOT_RSVD        : origin = 0x20000000, length = 0x00000800 /* Part of S0, BOOT rom will use this for stack */
   S0RAM            : origin = 0x20000800, length = 0x000037FF
   S3RAM            : origin = 0x2000C000, length = 0x00003FFF
   S1_S3RAM			: origin = 0x20004000, length = 0x0000BFFF
   E0RAM            : origin = 0x20010000, length = 0x00003FFF

   CPU1TOCMMSGRAM0  : origin = 0x20080000, length = 0x00000400
   CPU1TOCMMSGRAM0_ECAT  : origin = 0x20080400, length = 0x00000400
   CPU1TOCMMSGRAM1  : origin = 0x20080800, length = 0x00000800

   CMTOCPU1MSGRAM0  : origin = 0x20082000, length = 0x00000400
   CMTOCPU1MSGRAM0_ECAT  : origin = 0x20082400, length = 0x00000400
   CMTOCPU1MSGRAM1  : origin = 0x20082800, length = 0x00000800

   CPU2TOCMMSGRAM0  : origin = 0x20084000, length = 0x00000800
   CPU2TOCMMSGRAM1  : origin = 0x20084800, length = 0x00000800
   CMTOCPU2MSGRAM0  : origin = 0x20086000, length = 0x00000800
   CMTOCPU2MSGRAM1  : origin = 0x20086800, length = 0x00000800
}

SECTIONS
{
   .resetisr        : > CMBANK0_RESETISR10, ALIGN(8)
   .vftable         : > CMBANK0_SECTOR10_11, ALIGN(8)   /* Application placed vector table in Flash*/
   .vtable          : > S0RAM             /* Application placed vector table in RAM*/
   .text            : >> CMBANK0_SECTOR10_11 | CMBANK0_SECTOR12, ALIGN(8)
   .cinit           : > CMBANK0_SECTOR10_11, ALIGN(8)
   .pinit           : > CMBANK0_SECTOR10_11, ALIGN(8)
   .switch          : > CMBANK0_SECTOR10_11, ALIGN(8)
   .sysmem          : > C1RAM

   .stack           : > C1RAM
   .ebss            : > C1RAM
   .econst          : > CMBANK0_SECTOR10_11, ALIGN(8)
   .esysmem         : > C1RAM
   .data            : >> C0RAM|C1RAM
   .bss             : > C0RAM
   .const           : > CMBANK0_SECTOR10_11, ALIGN(8)

    MSGRAM_CM_TO_CPU1 : > CMTOCPU1MSGRAM1, type=NOINIT
    MSGRAM_CM_TO_CPU1_ECAT : > CMTOCPU1MSGRAM0_ECAT, type=NOINIT
    MSGRAM_CM_TO_CPU2 : > CMTOCPU2MSGRAM0, type=NOINIT
    MSGRAM_CPU1_TO_CM : > CPU1TOCMMSGRAM0, type=NOINIT
    MSGRAM_CPU1_TO_CM_ECAT : > CPU1TOCMMSGRAM0_ECAT, type=NOINIT
    MSGRAM_CPU2_TO_CM : > CPU2TOCMMSGRAM0, type=NOINIT

    .TI.ramfunc : {} LOAD = CMBANK0_SECTOR10_11,
                           RUN = S1_S3RAM,
                           LOAD_START(RamfuncsLoadStart),
                           LOAD_SIZE(RamfuncsLoadSize),
                           LOAD_END(RamfuncsLoadEnd),
                           RUN_START(RamfuncsRunStart),
                           RUN_SIZE(RamfuncsRunSize),
                           RUN_END(RamfuncsRunEnd),
                           ALIGN(8)
}

/*
//===========================================================================
// End of file.
//===========================================================================
*/

I'm not sure why it doesn't works well although the locations of application are different.

I would really appreciate it if you could tell me how to do that correctrly.

  • the code looks fine to me. Can you do assembly code (in disassembly window) step in and see where it fails.

  • Hello, Baskaran

    I did it to see and check whether it fails and found that it got to be in faultISR().

    Additionally I modified the codes to jump into _c_int00_noargs of secondary application directly.

    //
    // Included Files
    //
    #include "driverlib_cm.h"
    #include "cm.h"
    
    #define APP_START_ADDRESS               0x002765E8U
    void exit(uint32_t address){
        //
        // Jump to entry address
        //
        __asm("   bx r0");
    }
    
    //
    // Main
    //
    void main(void)
    {
        CM_init();
        GPIO_writePin(120U,0);
        exit(APP_START_ADDRESS);
    }
    

    But It still go into faultISR().

    In map file of secondary application, the entry point is like below.

    0x002765E9

    I check the disassembly ot the endtry point of secondary application. I guess it looks fine.

    Actually I don't have any idea why there is difference between map file's address(0x2765E9) and the address below(0x2765E8) 

    Please check if there is anything I am misunderstanding.

    Thanks.

           

  • did it execute line 0x2003F8

  • Can you explain what you guide in more detail? I'm not sure what the difference is between 0x2003F8 and 0x2003F4.

    How can I run the code branching at certain address like 0x2003F8?

    Thanks,

  • referring to this image. I see that the line 2003F4 is executed (as it is highlighted). Next it should have executed 2003F8, but it is not highlighted.

    that's why i asked if it executed 2003F8.

  • Actually I don't have any idea why there is difference between map file's address(0x2765E9) and the address below(0x2765E8) 

    In a Cortex-M which only supports ARM Thumb mode the least significant bit in the address of a branch must be set to set Thumb mode.

    I.e. try changing to the following definition:

    #define APP_START_ADDRESS               0x002765E9U

    See TMS320F28384S: Code branch in CM4 for some more information.

  • hi, may be you need change  APP_START_ADDRESS  depend on xxx.map,  now I used 0x00208400  not  0x00208000

    because  in the debug situation,  you can check memory addr 0x00208400, the value  is stack address

    .resetisr
    * 0 00208000 00000006
    00208000 00000006 startup_cm.obj (.resetisr:resetISR)

    .vftable 0 00208400 00000140
    00208400 00000140 startup_cm.obj (.vftable:retain)

    .cinit 0 00208008 00000000 UNINITIALIZED

    .stack 0 1fffc000 00000200 UNINITIALIZED
    1fffc000 00000004 rtsv7M4_T_le_eabi.lib : boot_cortex_m.c.obj (.stack)
    1fffc004 000001fc --HOLE--

  • Hello, Chester,

    I intended that the first bootloader jump to .resetisr of the seconde apps, which is located at 0x270000 on flash memory like below.

    MEMORY
    {
       /* Flash sectors */
       CMBANK0_RESETISR10 : origin = 0x00270000, length = 0x00000008 /* Boot to Flash Entry Point */
       ...
    }
    
    SECTIONS
    {
       .resetisr        : > CMBANK0_RESETISR10, ALIGN(8)
       ...
    }

    In my code, it failed to execute the line(got into faultISR) when I configured the address to 0x270000 as memtioned above.

    Referring to the link you gave me, I modifed it as follows and it found that it worked well.

    #define APP_START_ADDRESS               0x00270001
     

    Thanks for your detaild advice.