EmbDev.net

Forum: ARM programming with GCC/GNU tools Attribute aligned


Author: Thomas Fernando (thomas_f)
Posted on:

Rate this post
0 useful
not useful
Hi ,

I am using ChanFat FS with code example from Martin Thomas.
1) There is an char array declared as
 BYTE Buff[16384] __attribute__ ((aligned (4))) ; /* Working buffer */. 
Is there any reason to align this array to a divisible by 4 address ?
For example
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

Author: Andreas Schwarz (andreas) (Admin) Flattr this
Posted on:

Rate this post
0 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.

Author: Thomas Fernando (thomas_f)
Posted on:

Rate this post
0 useful
not useful
Thanks Andreas.

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 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.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.