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.

TMS320F28377D-EP: DATA_ALIGN on freertos tasks

Part Number: TMS320F28377D-EP
Other Parts Discussed in Thread: SYSCONFIG

Hi all,

I try to integrate Freertos into my project using sysconfig. (c2000device)

When I create a task the following code is created too:

StaticTask_t TaskTCBBuffer;
StackType_t TaskStackBuffer[redTask_STACK_SIZE];
#pragma DATA_SECTION(TaskStackBuffer, ".freertosStaticStack")
#pragma DATA_ALIGN ( TaskStackBuffer , portBYTE_ALIGNMENT )

does anyone knows why '#pragma DATA_ALIGN' is needed?

I think I can omit '#pragma DATA_SECTION' but I am not sure about the data_align.

Thank you!

  • Hi,

    The portBYTE_ALIGNMENT is defined as 2. This is to ensure the stack address is an odd value.

    And we use DATA_SECTION to keep it in a separate section so that we can allocate this to an address in the range 0-0xFFFF. This is because the C28x Stack pointer is 16 bit and hence the stack memories should be within 0-0xFFFF range. Other data/bss sections can go to the addresses outside this region

    Is there any specific reason for your question. Were you facing any issues with the Sysconfig generated code?

    Regards,

    Veena

  • Hi Veena,

    I suppose you mean that the stack address should be even, right?

    What do you mean the C28x Stack pointer is 16 bit? I am a bit confused now.

    I do not have an issue with sysconfig generated code, it seems to work fine. I just want to know the logic behind this DATA_ALIGN/DATA_SECTION addition.
    (DATA_ALIGN looks logical for me now)

    Regarding DATA_SECTION addition, its just for the C28x CMU? Why it should be a dedicated section? Is it a freertos or CMU requirement?

    Thank you!

  • also I see in an example of 2838x CMU, in the linker (.cmd) this field exists:

    /* IMPORTANT: The FreeRTOS statically allocated stack should be allocated to this section only */
    .freertosStaticStack : >> RAMM1 | RAMM0 | RAMLSxDxGSx

    /* IMPORTANT: The FreeRTOS heap should be allocated to this section only as the C28x stack
    memory can be allocated in the lower 64k RAM memory only. */
    .freertosHeap : > RAMLSxDxGSx

    why these requirements exist? and what are the requirements for the 2837xD (the cmu that I use)? I can't find an example for this...

     

  • Yes, it is specific to C28x core. The C28x Stack pointer registers is 16 bit long. Hence stack memory should be in the range 0-0xFFFF. We ensure this by keeping the stack memories in a separate section and allocate them to this memory region in the linker cmd file

    Note that this is only in case data is accessed using stack pointer. The other data / bss section can reside in other memory ranges.

    Regards,

    veena

  • F2837x also uses the same C28x core. Hence this limitation exists for 2837xD as well.

  • Hi Veena,

    Thanks for the replies! 

    one last question, in the linker script of 2838x it says :

       /* IMPORTANT: The FreeRTOS statically allocated stack should be allocated to this section only */
       .freertosStaticStack  : >> RAMM1 | RAMM0 | RAMLSxDxGSx

    On 2837x linker that I have taken from an example I do not see any RAMLSxDxGSx section though. Should I add it in my linker or just remove it from freertosStaticStack available sections.

    Thanks!

  • RAMLSxDxGSx is nothing but a combination of LS, D and GS RAMs.

    You can very well remove it and add memory regions (or combined memory regions) as needed. You need to make sure that the region does not cross the 0xFFFF boundary.

    Regards,

    Veena