From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Larmour To: james chen Cc: ecos-discuss@sources.redhat.com Subject: Re: [ECOS] Acess unaligned address Date: Tue, 10 Apr 2001 13:18:00 -0000 Message-id: <3AD36AA0.124120D4@redhat.com> References: <000701c0c17e$f41c2860$c408aa0a@inc.inventec> X-SW-Source: 2001-04/msg00087.html james chen wrote: > > Hello, When I debug example on my test board ( based on ARM7TDI), run into > __unpack_f function. it will stop at the instruction "ldr r3, [r0, > 2]"( r0's value is word aligned ) and report bus error. I think that CPU has > access unaligned adress(see below document, get it from web page). so what > can I do to avoid it. >From the gcc manual: `-malignment-traps' Generate code that will not trap if the MMU has alignment traps enabled. On ARM architectures prior to ARMv4, there were no instructions to access half-word objects stored in memory. However, when reading from memory a feature of the ARM architecture allows a word load to be used, even if the address is unaligned, and the processor core will rotate the data as it is being loaded. This option tells the compiler that such misaligned accesses will cause a MMU trap and that it should instead synthesise the access as a series of byte accesses. The compiler can still use word accesses to load half-word data if it knows that the address is aligned to a word boundary. This option is ignored when compiling for ARM architecture 4 or later, since these processors have instructions to directly access half-word objects in memory. IIRC what we do on all our ARM ports is disable MMU alignment traps. If you want to enable them, you will need to rebuild gcc, and edit gcc/config/t-arm-elf to add either a multilib for -malignment-traps, or if you don't mind making the tools completely this way, just add -malignment-traps to TARGET_LIBGCC2_CFLAGS One thing I'm slightly confused about is that libgcc _should_ have defaulted to bulding for the arm7tdmi, which is a V4 architecture I believe. Jifl -- Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062 Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine