[U-Boot] R: Re: Strange arm9 behaviour reading long(s) not aligned to 4 bytes boundary

Måns Rullgård mans at mansr.com
Sun Jan 25 20:33:19 CET 2009


"dibacco at libero.it" <dibacco at libero.it> writes:

>>> I have something like this on a 32 bit little endian arm9 board (SAM9L9260):
>>>
>>> char buffer[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
>>>
>>> long A = * ( (long*)  buffer );
>>> long B = * ( (long*) (buffer + 2) );
>>>
>>> printf("A: %08x  B: %08x", A, B);
>>>
>>> I would expect that A = 0x03020100 and B = 0x05040302
>>> instead I get the  right value for A but  B is 0x01000302 or 
>>> something like this but anyway not  what I expect. 
>>> Is there something  wrong on the board? It seems that only 4 
>>> bytes aligned long are read  correctly.
>>
>>ARM9 does not support unaligned load/store.  Yours is apparently
>
>>configured in the round-and-rotate mode.
>>
> Then my code is simply wrong, that is, not allowed? If I have to
> port code from a PPC (that handles unaligned accesses) to an ARM9 it
> is painful operation..., isn't it?

If your code relies on unaligned memory accesses, then yes, making it
run on an ARM9 might not be much fun.  I would suggest you set the
processor to trap on unaligned accesses (the manual will tell you how).
That should make it easier to find them all.

-- 
Måns Rullgård
mans at mansr.com


More information about the U-Boot mailing list