[ECOS] Error when write a uint32 with not aligned pointer.

Gary Thomas gary@mlbassoc.com
Mon Feb 12 12:13:00 GMT 2007


wang cui wrote:
> Hi, compiler and ARM experts:
>
> I am faceing a problem like below:
>
> Arch of my target is arm7tdmi(lpc2xxx), little endian.
>
> When I use a (cyg_uint32 *)ptr to write a 32bit value, it always error
> if the ptr is not 4-byte aligned.
>
> For example:
> ptr = 0x8106409a;
> *ptr = 0x00000001;
>
> The result is not like:
> 0x81064098: 0xXX - shouldn't be modified
> 0x81064099: 0xXX - shouldn't be modified
> 0x8106409a: 0x01
> 0x8106409b: 0x00
> 0x8106409c: 0x00
> 0x8106409d: 0x00
> but
> 0x81064098: 0x01
> 0x81064099: 0x00
> 0x8106409a: 0x00
> 0x8106409b: 0x00
> 0x8106409c: 0xXX - should be modified
> 0x8106409d: 0xXX - should be modified
>
> It always cause problem when I use tcpip stack.(not cause problem for
> other packages with luck)

How so? The TCP/IP stacks should take care to never try this.

>
> So how to solve it? Should I modify some compiling options?

This is a well known problem on ARM; such operations are undefined (some
chips/cores
may throw an exception, but in general they just quietly do the wrong
thing). The only
real solution is to just not try to perform unaligned operations of this
sort.

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list