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.

TMS570LS3137: Jump to an specific Flash position

Part Number: TMS570LS3137
Other Parts Discussed in Thread: UNIFLASH

Hello, 

I wanted to know how I can make jumps in flash memory. It turns out that I am updating a program that is saved in FLASH1 (from position 0x00180000) through the CAN protocol. However, the jump takes me to sys_intvecs.asm (more specifically in prefetchEntry) and it does not executes the program.

The instruction I am using is the following:

#define direction_APP 0x00180000

int main(void)
{
...
...
...
//Jump to Flash BANK 1
application = (uint32_t)direction_APP;
((void(*)(void))application)();
...
...
...
}

I have verified that the data is successfully saved using UniFlash.

Thanks a lot and regards,

Leandro

  • ((void(*)(void))application)(); should work. 

    When you load the code to 0x18000 using uniflash or CCS, do you enable the "ECC generation"? 

  • Hello QJ,

    I changed that configuration enabling Auto ECC Generation but it still does not run.

    I am trying to flash into the first position of bank 1 (0x180000). Could it be that bl_link.cmd is not configured correctly? Or that position is inaccessible using this command: ((void(*)(void))application)();?

    bl_link.cmd:

    /*----------------------------------------------------------------------------*/
    /* Linker Settings                                                            */
    --retain="*(.intvecs)"
    
    /* USER CODE BEGIN (1) */
    
    /* USER CODE END */
    
    /*----------------------------------------------------------------------------*/
    /* Memory Map                                                                 */
    
    MEMORY
    {
    
        VECTORS (X)  : origin=0x00000000 length=0x00000020	vfill = 0xffffffff
        FLASH0  (RX) : origin=0x00000020 length=0x0017FFE0	vfill = 0xffffffff
        FLASH1  (RX) : origin=0x00180000 length=0x0180000	vfill = 0xffffffff
        SRAM  (RW) : origin=0x08002000 length=0x00002000
        STACK   (RW) : origin=0x08004000 length=0x00002000
    
    /* USER CODE BEGIN (2) */
    #if 1
        ECC_VEC  (R) : origin=(0xf0400000 + (start(VECTORS) >> 3))
                       length=(size(VECTORS) >> 3)
                       ECC={algorithm=algoL2R5F021, input_range=VECTORS}
    
        ECC_FLA0 (R) : origin=(0xf0400000 + (start(FLASH0)  >> 3))
                       length=(size(FLASH0)  >> 3)
                       ECC={algorithm=algoL2R5F021, input_range=FLASH0 }
    
        ECC_FLA1 (R) : origin=(0xf0400000 + (start(FLASH1)  >> 3))
                       length=(size(FLASH1)  >> 3)
                       ECC={algorithm=algoL2R5F021, input_range=FLASH1 }
    #endif
    /* USER CODE END */
    
    }
    
    /* USER CODE BEGIN (3) */
    ECC
    {
        algoL2R5F021 : address_mask = 0xfffffff8 /* Address Bits 31:3 */
                       hamming_mask = R4         /* Use R4/R5 build in Mask */
                       parity_mask  = 0x0c       /* Set which ECC bits are Even and Odd parity */
                       mirroring    = F021       /* RM57Lx and TMS570LCx are build in F021 */
    }
    /* USER CODE END */
    
    
    /*----------------------------------------------------------------------------*/
    /* Section Configuration                                                      */
    
    SECTIONS
    {
       .intvecs : {} > VECTORS
    
       flashAPI:
       {
         .\source\Fapi_UserDefinedFunctions.obj (.text)
         .\source\bl_flash.obj (.text)
         --library="F021_API_CortexR4_BE_V3D16.lib"  (.text)
       } palign=8 load = FLASH0, run = FLASH0, LOAD_START(apiLoadStart), RUN_START(apiRunStart), SIZE(apiLoadSize)
    
       .text  : {} > FLASH0 /*Initialized executable code and constants*/
    
    	.const : {} > FLASH0 | FLASH1
        .cinit   : {} > FLASH0 | FLASH1
        .pinit   : {} > FLASH0 | FLASH1
        .bss     : {} > SRAM
        .data    : {} > SRAM
    	.sysmem  : {} > SRAM
    /* USER CODE BEGIN (4) */
    /* USER CODE END */
    }
    
    /* USER CODE BEGIN (5) */
    /* USER CODE END */
    
    
    /*----------------------------------------------------------------------------*/
    /* Misc                                                                       */
    
    /* USER CODE BEGIN (6) */
    /* USER CODE END */
    /*----------------------------------------------------------------------------*/
    

    Thanks a lot and regards,

    Leandro

  • Hello,

    I modified the .cmd as follows and it works as well (it only stores the binary data into the FLASH1 but it does not run the application program).

                                                                                */
    /*----------------------------------------------------------------------------*/
    /* Linker Settings                                                            */
    --retain="*(.intvecs)"
    
    /* USER CODE BEGIN (1) */
    
    /* USER CODE END */
    
    /*----------------------------------------------------------------------------*/
    /* Memory Map                                                                 */
    
    MEMORY
    {
    
        VECTORS (X)  : origin=0x00000000 length=0x00000020	vfill = 0xffffffff
        FLASH0  (RX) : origin=0x00000020 length=0x0017FFE0	vfill = 0xffffffff
        FLASH1  (RX) : origin=0x00180000 length=0x0180000	vfill = 0xffffffff
        SRAM  (RW) : origin=0x08002000 length=0x00002000
        STACK   (RW) : origin=0x08004000 length=0x00002000
    
    /* USER CODE BEGIN (2) */
    #if 1
        ECC_VEC  (R) : origin=(0xf0400000 + (start(VECTORS) >> 3))
                       length=(size(VECTORS) >> 3)
                       ECC={algorithm=algoL2R5F021, input_range=VECTORS}
    
        ECC_FLA0 (R) : origin=(0xf0400000 + (start(FLASH0)  >> 3))
                       length=(size(FLASH0)  >> 3)
                       ECC={algorithm=algoL2R5F021, input_range=FLASH0 }
    
        ECC_FLA1 (R) : origin=(0xf0400000 + (start(FLASH1)  >> 3))
                       length=(size(FLASH1)  >> 3)
                       ECC={algorithm=algoL2R5F021, input_range=FLASH1 }
    #endif
    /* USER CODE END */
    
    }
    
    /* USER CODE BEGIN (3) */
    ECC
    {
        algoL2R5F021 : address_mask = 0xfffffff8 /* Address Bits 31:3 */
                       hamming_mask = R4         /* Use R4/R5 build in Mask */
                       parity_mask  = 0x0c       /* Set which ECC bits are Even and Odd parity */
                       mirroring    = F021       /* RM57Lx and TMS570LCx are build in F021 */
    }
    /* USER CODE END */
    
    
    /*----------------------------------------------------------------------------*/
    /* Section Configuration                                                      */
    
    SECTIONS
    {
       .intvecs : {} > VECTORS
    
    	.const : {} > FLASH0 | FLASH1
        .cinit   : {} > FLASH0 | FLASH1
        .pinit   : {} > FLASH0 | FLASH1
        .bss     : {} > SRAM
        .data    : {} > SRAM
    	.sysmem  : {} > SRAM
    /* USER CODE BEGIN (4) */
    /* USER CODE END */
    }
    

    I tried to jump to the position 0x180020 (jumping vectors) but it ignores this instruction.

    May be the .cmd of the binary is not well configured? I atach it below:

    /*----------------------------------------------------------------------------*/
    /* Linker Settings                                                            */
    
    --retain="*(.intvecs)"
    
    /* USER CODE BEGIN (1) */
    /* USER CODE END */
    
    /*----------------------------------------------------------------------------*/
    /* Memory Map                                                                 */
    
    MEMORY
    {
    
        VECTORS (X)  : origin=0x00180000 length=0x00000020
        FLASH0  (RX) : origin=0x00180020 length=0x0017FFE0
      //  FLASH1  (RX) : origin=0x002FFFE0 length=0x00180000
        STACKS  (RW) : origin=0x08000000 length=0x00001500
        RAM     (RW) : origin=0x08001500 length=0x0003EB00
    
    /*
        VECTORS (X)  : origin=0x00180000 length=0x00000020
        FLASH0  (RX) : origin=0x00180020 length=0x0017FFE0
        FLASH1  (RX) : origin=0x002FFFE0 length=0x00180000
        STACKS  (RW) : origin=0x08000000 length=0x00001500
        RAM     (RW) : origin=0x08001500 length=0x0003EB00
    */
    
    
    /*
        VECTORS (X)  : origin=0x00000000 length=0x00000020
        FLASH0  (RX) : origin=0x00000020 length=0x0017FFE0
        FLASH1  (RX) : origin=0x00180000 length=0x00180000
        STACKS  (RW) : origin=0x08000000 length=0x00001500
        RAM     (RW) : origin=0x08001500 length=0x0003EB00
        */
    
    /*----------------------------------------------------------------------------*/
    /* Section Configuration                                                      */
    
    SECTIONS
    {
        .intvecs : {} > VECTORS
        .text    : {} > FLASH0
        .const   : {} > FLASH0
        .cinit   : {} > FLASH0
        .pinit   : {} > FLASH0
        .bss     : {} > RAM
        .data    : {} > RAM
    	.sysmem  : {} > RAM
    	
    
    /* USER CODE BEGIN (4) */
    /* USER CODE END */
    }

    Thanks a lot and regards,

    Leandro

  • Hi Leandro,

    1. You can program the bootloader with ECC either generated by CCS ECC auto generation, or ECC generated by linker command, but not both.

    2. The ECC for application should be generated by F021 flash APIs. Please don't use Linker cmd file to generated ECC for application. 

    3. If you use linker to generate ECC for your bootloader, it is necessary to change the CCS loader settings so that the loader doesn't also try to generate ECC. Also verification during programming needs to be skipped because the data areas and ECC areas will now be programmed in separate steps.
    In CCS "Flash Settings", please check the following items:

    1. System Reset on Connect is checked
    2. Auto ECC Generation is unchecked
    3. Align program segments to 64-bit memory regions is checked
    4. Flash Verification Settings should be 'None'
    5. Perform Blank Check before Program Load must be unchecked