EmbDev.net

Forum: ARM programming with GCC/GNU tools Attribute aligned


von Thomas F. (thomas_f)


Rate this post
useful
not useful
Hi ,

I am using ChanFat FS with code example from Martin Thomas.
1) There is an char array declared as
1
 BYTE Buff[16384] __attribute__ ((aligned (4))) ; /* Working buffer */.
Is there any reason to align this array to a divisible by 4 address ?
For example
1
char linebuf[120];      /* Console input buffer */
does not use the aligned attribute.

2)If someone can say whats the smallest ARM7/Cortex they have shoehorned 
this FAT system it would help me.
Buff[16384] has been conservatively sized ?It does takes a lot of RAM.


Thomas

von Andreas S. (andreas) (Admin)


Rate this post
useful
not useful
Thomas Fernando wrote:
> Is there any reason to align this array to a divisible by 4 address ?

The array is probably accessed with a 32 bit pointer somewhere; on some 
architectures (e.g., ARM) the array needs to be aligned to a 4 byte 
boundary for that to work.

von Thomas F. (thomas_f)


Rate this post
useful
not useful
Thanks Andreas.

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
(1) as Andreas mentioned. On some devices the adress of the buffer is 
used in the low-level drivers which may have restrictions i.e. on 
DMA-adresses. On other targets the aligment might not be needed but can 
do no harm (maybe even speeds things up a little bit)

(2) the buffer can be smaller the 16KiBytes are just used in the example 
for benchmarking. If you look further down you will find the sice of the 
buffer used for some copy-routines. See ChaN's API documentation to find 
out which minimal buffer-sizes are needed.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.