Part Number: TMS320F28388D
To the TI Support Team,
I am currently working on a project involving an external flash to store configurable parameters. To manage these parameters, I am using the #pragma DATA_SECTION directive to place variables into a specific named section (e.g., .TRIMSECTION), which is then mapped to a specific RAM range in my .cmd linker command file.
The Issue: I have noticed that the compiler/linker does not preserve the sequence of variables as they are declared in the .c source file. Instead, it appears to be reordering them based on data type (e.g., grouping uint16_t together before float or uint32_t).
This reordering is problematic because our external flash mapping relies on a consistent memory offset. When new parameters are added, the linker inserts them into the middle of the section based on their type, shifting the addresses of existing parameters and causing data mismatches after firmware updates.
Evidence: As shown in the attached map file screenshots:
-
Case A: Existing parameters like
gc_crank_engage_time_contwere followed bybattery_voltage_cal_value. -
Case B: After adding
amf_start_typeandCB_selection, these were automatically placed at addresses0x0001B013and0x0001B014(following the other 16-bit/8-bit types), which shifted the subsequentfloatvariables.
Question: Is there a specific compiler flag or linker attribute in the TI ARM/C2000 toolchain that forces the linker to maintain the source declaration order within a named section?
Constraint Note: We are aware that wrapping these parameters in a struct would enforce the order; however, due to strict memory constraints and the overhead involved in our current implementation, we would prefer a linker-level solution that allows us to keep individual variables while guaranteeing their sequence.
Environment:
-
Compiler: ti-cgt-c2000_22.6.1.LTS
-
IDE: Code Composer Studio [CCS]
-
Device: TMS320F28388D
Thank you for your assistance.


