본문 바로가기
DSP, MCU/TMS320F2838x (C28x)

CCS ] 링커 커맨드(.cmd) 파일에 ALIGN(x) directive를 넣는 이유

by eteo 2022. 12. 1.

Why do you use align directive (ALIGN(x)) in the linker cmd files provided in the C2000Ware examples?

 

Answer. Fapi_AutoEccGeneration mode (one of the Flash API programming modes) programs the supplied data portion in Flash along with automatically generated ECC. The ECC is calculated for 64-bit aligned address and the corresponding 64-bit data. Any data not supplied (within a given 64-bit aligned memory) is treated as 0xFFFF. Note that there are practical implications of this when writing a custom programming utility that streams in the output file of a code project and programs the individual sections one at a time into flash. If a 64-bit word spans more than one section (that is, contains the end of one section, and the start of another), values of 0xFFFF cannot be assumed for the missing data in the 64-bit word, when programming the first section. When you go to program the second section, you will not be able to program the ECC for the first 64-bit word since it was already (incorrectly) computed and programmed using assumed 0xFFFF for the missing values. One way to avoid this problem is to align all sections linked to flash on a 64-bit boundary (preferable is 128-bit alignment since most of the flash programmers program 128-bits at-a-time) in the linker command file for your code project.


Here is an example for C28x (For ARM, ALIGN(16) should be used):


SECTIONS

{

.text : > FLASH, PAGE= 0, ALIGN(8) /* Here ALIGN(8) makes sure that .text section starts on a 128-bit aligned memory address*/

.cinit: > FLASH, PAGE = 0, ALIGN(8)

.const: > FLASH, PAGE = 0, ALIGN(8)

.econst: > FLASH, PAGE = 0, ALIGN(8)

.pinit: > FLASH, PAGE= 0, ALIGN(8)

.switch: > FLASH, PAGE= 0, ALIGN(8)

}

If you do not align the sections in flash, you would need to track incomplete 64-bit words in a section and combine them with the words in other sections that complete the 64-bit word. This will be difficult to do. So it is recommended to align your sections on 64-bit boundaries (128-bit alignment is preferable since most of the programmers program 128-bits at-a-time).

 

출처 : https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/951658/faq-faq-for-flash-ecc-usage-in-c2000-devices---includes-ecc-test-mode-linker-ecc-options