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).
즉, 플래시 메모리에 비트 경계를 맞춰야 하는 이유는 ECC(Error Generation Code) 생성과 관련되며 C28x의 경우 링커가 모든 섹션을 64비트 경계에 맞추도록 ALIGN(8)을 사용하고 ARM의 경우 링커가 모든 섹션을 128비트 경계에 맞추도록 ALIGN(16)을 사용한다.
'임베디드 개발 > TMS320F2838x (C28x)' 카테고리의 다른 글
TMS320F28388D ] Watchdog Timer 사용하기 (1) | 2022.12.03 |
---|---|
TMS320F28388D ] FLASH Build 와 RAM Build 같이 사용하는 .cmd 파일 만들기 (3) | 2022.12.01 |
TMS320F28388D ] printf 사용하기 위한 설정 (0) | 2022.11.30 |
CCS, Code Composer Studio ] 재사용 용이한 Portable Project 만들기 (device_support 와 driverlib 모두 사용) (2) | 2022.11.27 |
TMS320F28388D ] SD카드 읽기/쓰기 (0) | 2022.11.24 |