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.

TMS570LS0714: Cannot get Flash & RAM MEM SWAP through Bus Matrix working..

Expert 2025 points
Part Number: TMS570LS0714

I'm essentially doing as per thread:

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/880641/tms570lc4357-flash-ram-swap

..except my controller note 0714

My code 

        if ( 0x5 !=  systemREG1->BMMCR1) {
            // extern tgt size, addr
            memcpy( (void*)addr, APP_START_ADDRESS,  size);
            systemREG1->BMMCR1 = 0x5;
            systemREG1->CPURSTCR = ~(systemREG1->CPURSTCR); //bye bye
            while(1);
           }
           
           //resets & shouldnt be here

Through debugger, I verify that my app _does_ get copied to where I need ( i saw all assembly statements in RAM, from 0x08000000),  the BMMCR1 gets swapped from 0xA to 0x5.

As soon as CPU resets, however, it's back to where it started as I see - same interrupt vector from Flash, not RAM.   The BMMCR1 value is correct - swapped / 0x5 - after reset, yet,  looking at the start of both - 0x00000000 , which is now suppose to be RAM, or 0x08000000 which is now suppose to be FLASH  - I only see the old code / old reset vector.  As if my copying never happened. 

This code has No MPU or ECC on RAM enabled at all. 

Any ideas?  (Help !)

  • Hello,

    The main purpose of swapping SRAM and flash is for faster debugging.

    Please try the script options in CCS

    1. Memory Switch: RAM memory 0x00

    2. Memory map setup: RAM 0x00

  • I have seen it, and it in fact does the same.

    It does not work as the issue is the same - i see no swap. Anything else to try?

  • The user guide does not say it's limited to when debugger is connected. So , should it not work changing runtime these ?

  • The swap feature should not be used in the mass production. This feature is developed to ease the code debugging by running code from SRAM (Flash swapped).

    The memory can be swapped at runtime.

  • Can I ask you to clarify please, for my understanding of the feature.

    After the swap is triggered and the memory is swapped as far as the executing CPU sees it, does it mean that all code & vars have to also be at different locations - i.e,   does this require code to be assembled & linked as if flash is from 0x08000000 and ram from 0 ?
    Or there is some other translation in hw happens which allows you to keep your code as is?   And then ECC for RAM range has to be changed too 

    I'm not catching on how debugger / emulator uses it if the code is linked as normal

  • I will develop a example project to swap the memory and run the code from SRAM. 

  • Attached is my example to execute the code from RAM using memory swap:

    TMS570LS12x_GIOB1_run_from_RAM.zip

  • In TMS570, the FLASH is mapped to 0x00 as default, and RAM is mapped to 0x0800 0000. We can swap Flash and SRAM in CCS10 easily. Two steps to load and execute your code in RAM instead of Flash:

    1. Connect your target to CCS10. The "Scripts" menu becomes active. Select "Target_RAM_to_0x0", and "Memory Map Setup for RAM @ Address 0x0" under "Scripts".

     open "Memory Map" (under "Target") to make sure RAM is mapped to 0x00

    You may need to run the script couple times.

    2. Open "sys_core.asm" in CCS10, change "008000000" to "0x00010000" in stackpointer definition (stack defined in linker cmd file)

    3. change the memory map in linker cmd file:


    MEMORY
    {
    /* USER CODE BEGIN (2) */
        VECTORS (RW) : origin=0x00000000 length=0x00000020
        RAM (RW) : origin=0x00000020 length=0x0000FFE0
        STACKS (RW) : origin=0x00010000 length=0x00001500
    /* USER CODE END */
    }

    /* USER CODE BEGIN (3) */
    /* USER CODE END */

    /*----------------------------------------------------------------------------*/
    /* Section Configuration */

    SECTIONS
    {
    /* USER CODE BEGIN (4) */
       .intvecs : {} > VECTORS
       .text : align(8) {} > RAM
       .const : align(8) {} > RAM
       .cinit : align(8) {} > RAM
       .pinit : align(8) {} > RAM
       .bss : {} palign=8 > RAM
       .data : {} palign=8 > RAM
       .sysmem : {} palign=8 > RAM
    /* USER CODE END */
    }

    The example project is to turn on/off the one USER LED on LS1224 Launchpad

  • The project was tested on my launchpad, and works as expected.

  • Ok, so you have changed in your linker where RAM starts, it's swapped now, to use the feature - i.e, you _have_ to change this and build special executable.

  • Yes, some changes should be make to linker cmd file and sys_core.asm (stack init).