[U-Boot-Users] 32 bit alignment

Marius Groeger mag at sysgo.de
Tue Feb 4 15:18:41 CET 2003

On Tue, 4 Feb 2003, Robert Schwebel wrote:

> The DHCP payload starts at the marked address, which is not 32 bit
> aligned. Now I want to access the 32 bit value at the marked address and
> the following one by using a pointer (u32*)bp which points to the marked
> address. The result is that I get the value from the address _before_
> the marked address (which belongs to the same 32 bit aligned dword).
> This makes the whole network code break which assumes that it can lay
> arbitrary data structures over the piece of memory.

This is standard behaviour on ARMs, if the alignment exception is
configured to be ignored. The EA is internally simply anded with ~3.
There are 2 ways to handle this:

1) Implement an alignment exception handler (have fun)
2) Don't access unaligned data. Use byte accesses instead.


Marius Groeger           SYSGO Real-Time Solutions AG       mgroeger at sysgo.de
Software Engineering     Embedded and Real-Time Software    www.sysgo.de
Voice: +49-6136-9948-0   Am Pfaffenstein 14                 www.osek.de
FAX:   +49-6136-9948-10  55270 Klein-Winternheim, Germany   www.elinos.com

More information about the U-Boot mailing list