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.

TMDS570LS31HDK: .text file from Flash to RAM

Part Number: TMDS570LS31HDK

Tool/software:

Hello E2E Experts,

Good day.

Is there a guide on how to copy .text from flash to RAM?

I use TMS570LS31371HDK and I want to copy .text from flash to ram because RAM works very fast.

I checked the E2E thread below.

CCS/TMS570LS3137: Copy code from flash to ram

However, it does not work. 

My code stop is undefEntry. 
My linker file;
MEMORY
{
    VECTORS (X)  : origin=0x00000000 length=0x00000100
    FLASH0  (RX) : origin=0x00000100 length=0x0017FF00
    FLASH1  (RX) : origin=0x00180000 length=0x00180000
    STACKS  (RW) : origin=0x08000000 length=0x00001500
    RAM     (XRW) : origin=0x08001500 length=0x0003EB00
/* USER CODE BEGIN (2) */
/* USER CODE END */
}
/* USER CODE BEGIN (3) */
/* USER CODE END */
/*----------------------------------------------------------------------------*/
/* Section Configuration                                                      */
SECTIONS
{
    .intvecs : {} > VECTORS
    .text    : RUN = RAM, LOAD = FLASH0 | FLASH1
                 LOAD_START(flashStart), LOAD_END(flashEnd), LOAD_SIZE(flashSize),
                 RUN_START(ramStartAddr), RUN_END(ramEndAddr)
    //{} > RAM
    .const   : {} > FLASH0 | FLASH1
    .cinit   : {} > FLASH0 | FLASH1
    .pinit   : {} > FLASH0 | FLASH1
    .bss     : {} > RAM
    .data    : {} > RAM
      .sysmem  : {} > RAM
/* USER CODE BEGIN (4) */
 
/* USER CODE END */
}
And I copy from flash to ram in main() ;
 memcpy(&ramStartAddr,&flashStart, (uint32)&flashSize);
Regards,
TI-CSC
  • Hi TI-CSC,

    As per my understanding, it is not possible to keep entire text section into the RAM because somewhere we should need to call the routine to copy the flash text data into the RAM right, this copy routine should need to be in flash because how the code will be in RAM without calling this routine.

    So, my idea is that we should keep the .text section till this copy to RAM routine should be in flash only, so after this we can copy the code into the RAM from flash.

    I created one example project for this:

    TEXT_Section_Executing_RAM_LS3137.zip

    I will explain what i am doing in this project:

    1. Here i am creating one new section called main_code_section,

    2. The idea is to keep my all the main code into this section, and all the code before the main will be present in .text section only like as before.

    3. Now just before calling the main routine i will copy the main routine code from flash to RAM like below.

    4. Once we copy the data into the RAM from flash, now we can call the main routine to execute the remaining code into the RAM instead of flash.

    Note:
    If we try put entire .text into the RAM then we will get abort exceptions because after POR the RAM will be empty, there will be no code in the RAM until we copy the data manually. So if we try to run the .text section from RAM before the copy obviously some invalid instructions will be present, and this will lead to the exceptions.

    --
    Thanks & regards,
    Jagadish.

  • Hello Jagadish,

    Good day.

    My code works fine now and everything is OK.

    I start debug, my program starts but I cannot stop it in any way. My code does its job very well, I have no problem with it, my only problem is that I cannot stop it while in debug.

    What could be the issue?

    Regards,

    TI-CSC

  • Hi TI-CSC,

    Can you try the below steps:

    1. You are correct; after entering into the debug, you cannot see the pause option and also the code will not stop at starting of the main.c.

    This might be because we are moving the entire code into the RAM instead of flash. This might prevent it, but we can do one simple thing:

    2. Just go to the Debug tab and there select the "Texas Instruments XDS1xx USB Debug Probe"

    3. Once you select it, it should enable the pause option

    4. Now if you pause the code, you can see where execution is going:

    5. If you want to debug the project from starting onwards again, then click on "System Reset" option as shown below:

    6. This will bring the code to the reset entry

    From there you can execute the code normally again

    --
    Thanks & regards,
    Jagadish.