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.

downloading and running you app from RAM on the Hercules TMS570 USB stick

Other Parts Discussed in Thread: TMS570LS3137, HALCOGEN, TMS570LS20216

 

i have a Hercules TMS570 USB stick which i am using to develop a test my application. I am using CCS v4.2.4 for this development and building the application using command line interface to the CCS compiler/linker tool chain commands. When i create a target configuration file to connect to the TMS570 USB stick i can specify the target device, which in this case is the TMS570LS3137, as well as Flash settings and Erase options as well as other General Debugger Options. I now connect to the target and load the executable and get the expected results but it takes minutes to Erase and reprogram the flash. I have already set the Flash option to only erase the Necessary sectors to try to speed things up a bit as well as specifying Fast verification, but it is still extremely slow.

So my question is how can i configure the target connection to download and run out of RAM instead of flash, in hopes of speeding up by debugging and development time.

 

Thanks

Rob

 

  • Hi Rob,

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

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

        If any error window pop-up, please cancel it.

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

    2. Open "sys_core.asm" in CCS4, change "00800 0000" to "0x0000 0000" in stackpointer definition

         userSp:   .word 0x08000000+0x00000200

         svcSp:    .word 0x08000000+0x00000200+0x00002000

         fiqSp:    .word 0x08000000+0x00000200+0x00002000+0x00000200

         irqSp:    .word 0x08000000+0x00000200+0x00002000+0x00000200+0x00000200

         abortSp:  .word 0x08000000+0x00000200+0x00002000+0x00000200+0x00000200+0x00000100

         undefSp:  .word 0x08000000+0x00000200+0x00002000+0x00000200+0x00000200+0x00000100+0x00000100

     

    Then compile the project. The code will be loaded to RAM.

    Regards,

    QJ

  • Some things to be careful about when doing the steps that QJ outlined:

    • When you load the program using CCS, the code will be downloaded into the RAM starting at address 0x00000000. So please map your stack pointers to some addresses in RAM not occupied by code (look at your map file to see how much memory is used up by your code).
    • When going through the initialization of the microcontroller, be careful with steps such as CPU RAM auto-initialization or CPU RAM self-test using PBIST. These must be disabled for the CPU RAM, else they will cause the application to crash (run NOPs).
    • The flash and RAM swap gets reset back to the flash being at 0x00000000 and RAM at 0x08000000 upon any system reset condition. Therefore, you have to exclude any situation in your code that causes an intentional reset.

    Regards, Sunil

  • i tried manually modifying the sys_core.asm file to redefine the stack addresses as indicated and then rebuilt the app, then after connecting to the target, i ran the script to Select "Target_RAM_to_0x0", then selected Load Program which appears to load the app at 0x0xxxxxxx instead of 0x8xxxxxxx. so far so good...However, when i run the app it seems to be getting some exception failure that cause it to end up at PC  address 0x0000000c (irpt vector for  prefetchEntry:) after that is seems like RAM is getting cleared to 0 and i need to reload. i'm thinking that although the program seems to being loaded to RAM by virtue of the memory map swap we do with flash and RAM, the .bss and data sections might now be getting linked to adrs 0x8xxxxxxx range causing RW variables to get mapped to Flash? so in trying to debug this further i come up with the following subsequent observations/questions ...

    i'm using Halcogen to generate the startup code for the TMS570LS3137, which includes generating the sys_core.asm and the sys_link.cmd files.

    Should i be using Halcogen to configure RAM at 0x00000000 and Flash at 0x80000000 ? You can select the Memory Map, RAM, and Flash tabs inside Halcogen but it doesn't appear as though you can edit the base address: for either RAM or Flash. Also the generated sys_link.cmd file contains the memory map and sections define shown below. should the memory map and sections get changed to indicate RAM @ origin 0x00000000 and Flash @ origin 0x8000000 ? and should the .text .const  .cinit .pinit  sections now get mapped to : {} > RAM instead of FLASH0 | FLASH1  ?  Without these changes if you look at the map file produced after i build the app (outside of CCS) you can see the .text .const  .cinit .pinit sections are getting linked into the 0x0xxxxxxx memory range, and the .bss .sysmem and .data sections get mapped to 0x8xxxxxxx memory range.

    /*----------------------------------------------------------------------------*/
    /* Memory Map                                                                 */

    MEMORY
    {
        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=0x00026B00

    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    }

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


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

    SECTIONS
    {
        .intvecs : {} > VECTORS
        .text    : {} > FLASH0 | FLASH1
        .const   : {} > FLASH0 | FLASH1
        .cinit   : {} > FLASH0 | FLASH1
        .pinit   : {} > FLASH0 | FLASH1
        .bss     : {} > RAM
        .data    : {} > RAM

    /* USER CODE BEGIN (4) */
       .sysmem  : {} > RAM
    /* USER CODE END */
    }

     

  • For using the approach I mentioned, you also need to change the sys_link.cmd file to assign .bass and .data to FLASH0 or FLASH1.

     

    Another way to load/execute the code in RAM is to change the sys_link.cmd file. Using this way, you don't need to swap the memory map using the scripts and don't need to change the stack pointer in sys_core.asm. For example:

    MEMORY{

        VECTORS   (X)  : origin=0x08000000 length=0x00000020

        RAM0    (RX) : origin=0x08000020 length=0x00002000

        RAM1    (RX) : origin=0x08002040 length=0x0002DFE0

        SDRAM     (RW) : origin=0x80000020 length 0x007FFFE0

        RAM_ALIGN (RW) : origin=0x08031000 length=0x0000E000

    }

     

    SECTIONS{

        .intvecs : {} > VECTORS

        .text    : {} > RAM1

        .const   : {} > RAM1

        .cinit   : {} > RAM1

        .pinit   : {} > RAM1

        .bss     : {} > RAM1

        .data    : {} > RAM1

        .sysmem  : {} > RAM1

        .stack   : {} > RAM0

        FRAMEBUF_ALIGN256  : align(256) {} > RAM_ALIGN

        USB_SECT1_ALIGN256 : align(256) {} > RAM_ALIGN

        USB_SECT2_ALIGN256 : align(256) {} > RAM_ALIGN

        USB_SECT3_ALIGN256 : align(256) {} > RAM_ALIGN

        USB_SECT4_ALIGN256 : align(256) {} > RAM_ALIGN

    }

     

    Regards,

    QJ

  • Hello,

    Please don't use my 2nd approach. It will mess up the interrupts. The exception vector base address is always at 0x00000000. Sorry about that.

    Regards,

    QJ

  • I have the same question about  TMS570LS20216  USB development stick which i am using to develop an application.

    How can i configure the target connection to download and run out of RAM instead of flash , in hopes of speeding up by debugging and development time.

    Since the maximum program/erase cycles are 1000 according to the datasheet of the flash memory.

    Thanks,

    Gil Fine

  • Hello Gil,

    The same approach also works for the TMS57020x microcontrollers.

    Regards, Sunil

  • Hello Gil,

    One thing you may consider if you haven't already is to move to CCS5.1 where we see improved debug performance and programming times with the xds100v2 embedded emulator.

  • Hi Sunil,

    I succefully find how to Load Program to the RAM instead of Flash,

    I change the Link file and preform the Memory_Map(RAM) and Memory_Switch(RAM) scrips automaticaly in the GEL file when OnTargetConnect() is called.

    But now I have different problem, when I want to create a  variable in my main(), it still located in  >> 0x08000000 that in my case is the Flash.

    In this case the variable value is always 0xFFFFFFFF.

    How can I make the variable address alocation to be in RAM (Address 0x00000000 and above)?

     

    thanks alot

    Gil

  • Hi Gil,

    You need to ensure that no section is mapped to the memory starting at address 0x08000000. Each defined section must fall within the available RAM size, starting at address 0x00000000. Temporary variables are usually stored using the stack pointer for the particular mode that you are in. Notice that the stack pointers could be hard-coded in some assembly or C source file. You will need to manage these stack pointers to be in RAM (starting at 0x00000000) as well.

    Regards, Sunil

  • thanks, it work well now.

    I just manually change the stack pointers in the sys_core.asm

     

    Gil