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.

TMS320F28P550SJ: How to handle CLA codes on LS8/LS9 in Sysconfig.

Part Number: TMS320F28P550SJ
Other Parts Discussed in Thread: SYSCONFIG, C2000WARE

Tool/software:

Hi champs, 

I am asking this for our customer.

The user wants to use LS8/LS9 for CLA program in Sysconfig below.

However, the code for memory-copy generated by Sysconfig below is not correct.

They are supposed to be like below because LS8 is on 0x14000 rather than 0x4000 from CPU perspective.

memcpy((uint32_t *)((uint32_t)&Cla1ProgRunStart + (0x10000U)), (uint32_t *)&Cla1ProgLoadStart,
(uint32_t)&Cla1ProgLoadSize);

Therefore, we found the CLA could not run if the code is generated from Sysconfig.

1. Is this a Sysconfig bug?

If not, would you please show us how to do it in Sysconfig?

2. What if the CLA program code is larger than LS8+LS9 (32KB)?

That is, how does the user move codes when the user's code needs to move onto RAM from LS8 to LS0?

memcpy((uint32_t *)((uint32_t)&Cla1ProgRunStart + (0x10000U)), (uint32_t *)&Cla1ProgLoadStart,
(uint32_t)&Cla1ProgLoadSize);

That is, from CPU 0x14000/CLA 0x4000 to CPU 0x8000 (LS0).

There is such a discontinuity from CPU perspective at end of LS9 (0x17FFF) and start of LS0 (0x8000). 

 

  • Hi champs,

    One more question,

    For dedicated CPU use (0x14000-0x17FFF), LS8/LS9 can be allocated for either CPU code or data usage. Is it right?

    For CLA use (0x4000-0x7FFF), can LS8/LS9 be allocated for either CLA program or data (CPU/CLA shared data) usage? OR they can only be used for CLA program but cannot be used as CLA data?

  • Hi Wayne,

    This does look to be a bug in the Sysonfig generated code, the support for this specific use case hasn't been added. For this case, it is best to follow the C2000ware example code (cla_asin_ls8_9) and do these initializations in the main file. I will make sure this gets added in a future C2000ware version. 

    LS8 & LS9 only have the option to be configured as CLA program memory, not CLA data memory, see the memory map access:

    If the CLA code is larger than can fit in LS8 & LS9, the program needs to be assigned to a non-continuous portion of memory. Here is an example of this:

    • .cmd file

    RAMLS8_LS9 : origin = 0x004000, length = 0x004000 // LS8~LS9 for CLA_PROGRAM

    RAMLS0_LS1 : origin = 0x008000, length = 0x001000 // LS0~LS1 for CLA_PROGRAM

    Cla1Prog : LOAD = FLASH_BANK0,
    RUN = RAMLS8_LS9,
    LOAD_START(Cla1ProgLoadStart_LS8_9),
    RUN_START(Cla1ProgRunStart_LS8_9),
    LOAD_SIZE(Cla1ProgLoadSize_LS8_9),
    ALIGN(4)

    Cla1Prog : LOAD = FLASH_BANK0,
    RUN = RAMLS0_LS1,
    LOAD_START(Cla1ProgLoadStart_LS0_1),
    RUN_START(Cla1ProgRunStart_LS0_1),
    LOAD_SIZE(Cla1ProgLoadSize_LS0_1),
    ALIGN(4)

    • .c file to do memcpy

    memcpy((uint32_t *)&Cla1ProgRunStart_LS0_1, (uint32_t *)&Cla1ProgLoadStart_LS0_1,
    (uint32_t)&Cla1ProgLoadSize_LS0_1);

    memcpy((uint32_t *)((uint32_t)&Cla1ProgRunStart_LS8_9 + (0x1E000U)), (uint32_t *)&Cla1ProgLoadStart_LS8_9,
    (uint32_t)&Cla1ProgLoadSize_LS8_9);

    Please upvote this response if it answers all of the customers questions. Slight smile

    Best Regards,

    Delaney

  • Hi Delaney,

    1. From below, if the user only uses CLA task1 with one function itself and larger than 32KB, will this CLA task1 function be placed starting on LS8 (0x4000) and then located across 0x7FFF/0x8000? Would you please confirm that the compiler/linker can place the same function across two RAM declared below?

    BTW, we usually uses ALIGN (8), here you use ALIGN (4) on purpose? Or ALIGN(8) is OK too?

    Cla1Prog : LOAD = FLASH_BANK0,
    RUN = RAMLS8_LS9,
    LOAD_START(Cla1ProgLoadStart_LS8_9),
    RUN_START(Cla1ProgRunStart_LS8_9),
    LOAD_SIZE(Cla1ProgLoadSize_LS8_9),
    ALIGN(4)

    Cla1Prog : LOAD = FLASH_BANK0,
    RUN = RAMLS0_LS1,
    LOAD_START(Cla1ProgLoadStart_LS0_1),
    RUN_START(Cla1ProgRunStart_LS0_1),
    LOAD_SIZE(Cla1ProgLoadSize_LS0_1),
    ALIGN(4)

    2. From below, the offset for LS8_9 is 0x1E000 rather than 0x10000?

    memcpy((uint32_t *)((uint32_t)&Cla1ProgRunStart_LS8_9 + (0x1E000U)), (uint32_t *)&Cla1ProgLoadStart_LS8_9,
    (uint32_t)&Cla1ProgLoadSize_LS8_9);

    3. Is .const_cla viewed as CLA program or CLA data? Can .const_cla be placed on LS8/LS9? We are asking this because it requires memory copy. We are confused if .const_cla follows the same way as Cla1Prog if they are placed on LS8/LS9?

  • Hi Wayne,

    I will get back to you with a response tomorrow.

    Best Regards,

    Delaney

  • Hi Wayne,

    I apologize for the delay. 

    From below, if the user only uses CLA task1 with one function itself and larger than 32KB, will this CLA task1 function be placed starting on LS8 (0x4000) and then located across 0x7FFF/0x8000? Would you please confirm that the compiler/linker can place the same function across two RAM declared below?

    Yes, if you combine LS8 and LS9 into one range in MEMORY{} like is shown in the example, you can allocate a task larger than 32KB to the memory range.

    In this case though, I would suggest splitting up the code into different tasks if possible if the others are unused. You can manually trigger a task from the software in another task (see more information here: 4. Frequently Asked Questions — C2000Tm CLA Software Guide ) for this.

    BTW, we usually uses ALIGN (8), here you use ALIGN (4) on purpose? Or ALIGN(8) is OK too?

    I don't know too much about how the linker uses the ALIGN attribute, there should be more information in the Assembly Language Tools Guide. The example linker cmd files for CLA in C2000ware use ALIGN(4) however, so I would recommend matching this to be safe.

    2. From below, the offset for LS8_9 is 0x1E000 rather than 0x10000?

    My apologies, I should have mentioned the example I provided is for F28P65x specifically (which needs offset of 0x1E000 due to the memory map). For F28P55x, you can change this value to 0x10000 like in the C2000ware example.

    3. Is .const_cla viewed as CLA program or CLA data? Can .const_cla be placed on LS8/LS9? We are asking this because it requires memory copy. We are confused if .const_cla follows the same way as Cla1Prog if they are placed on LS8/LS9?

    const_cla is considered data memory of the CLA. Every CLA allocation in the linker cmd except Cla1Prog is data memory. For this reason, no, const_cla cannot be placed in LS8 / LS9 because those can't be assigned as CLA data memory. It would need to be placed in LS0-LS7 and use the memcpy that doesn't require any offset.

    Best Regards,

    Delaney

  • Hi Delaney,

    "In this case though, I would suggest splitting up the code into different tasks if possible if the others are unused."

    You mean the user can separate a long task1 into task1 and task1 by software calling task2 and the end of task1?

    The reason is that the compiler can separate them and put them separately, right?

    Or any reason else?

  • Hi Wayne,

    Yes, in that case there would be two different symbols made by the compiler so the linker has some more flexibility with how it allocates the memory. It's also just more modular, so a better coding practice.

    Best Regards,

    Delaney