From richard.gibbs at calxeda.com Tue Mar 6 16:28:09 2012 From: richard.gibbs at calxeda.com (richard.gibbs at calxeda.com) Date: Tue, 6 Mar 2012 10:28:09 -0600 (CST) Subject: [arm-gnu] =?utf-8?q?arm-none-eabi-gcc_is_generating_code_with_ldm?= =?utf-8?q?_=28load_multiple=29_with_unaligned_accesses_on_ARMv7-M_=28m3?= =?utf-8?q?=29?= Message-ID: <1331051289.975522461@apps.rackspace.com> The above problem is causing a Hard Fault. I can get around it by forcing full-word alignment of the array causing the problem. arm-none-eabi-gcc --version reports: arm-none-eabi-gcc (Sourcery CodeBench Lite 2011.09-69) 4.6.1 I'm cross-compiling on windows for armv7-m (m3) with the following cflags: -mthumb -march=armv7-m -mfix-cortex-m3-ldrd -D__thumb -mno-thumb-interwork -mthumb -mcpu=cortex-m3 -Wall -Werr -Os -g -Wno-pointer-sign The following describes how I get the problm: 1) I have a structure (first_struct) that in the middle, has an array of "char" (c). Due to the preceeding fields in the structure, this array is on half-word alignment. I have a second structure (second_struct) that has two ints (32-bit) at the top. 2) I have a function (first_function) that takes a void pointer as an argument, immediately assigns that argument to a structure pointer (so that it can reference the buffer as a structure), and references the first two fields (both full-word types). For efficiency, the compiler generates an assembly instruction "ldi r0, {r4, r7}" to load the first two 32-bit values into registers. 3) A second_function passes a pointer to the array of "char" in first_struct to first_function. 4) When the LDM in step 2 (above) executes, I get a hard-fault, since the LDM requires full-word alignment of the address in (r0). Is there a compile flag that will prevent this alignment problem, either in the initial structure layout, or by not using the ldm in target function for this case? Example: struct first_struct { char a; char b; char c[100]; } struct second_struct { int x; int y; } void first_function(void *mystruct) { struct second_struct *zz = (struct second_struct *) mystruct; int aaa; int bbb; aaa = zz->x; bbb = zz->y; . . . } void second_function(void) { struct first_struct local; . . . memcpy (&local->c[0],SOME_ARRAY,sizeof(local->c)); first_function(&local->c[0]; } -------------- next part -------------- An HTML attachment was scrubbed... URL: From zzzh.2007 at qq.com Thu Mar 22 16:13:09 2012 From: zzzh.2007 at qq.com (zzzh.2007) Date: Fri, 23 Mar 2012 00:13:09 +0800 Subject: [arm-gnu] an long long problem Message-ID: <201203230013086258096@qq.com> Hi, all, I am using sourcery_g++_lite_for_arm_eabi ( version of arm-2008q3-66-arm-none-eabi) in Contiki to do some programming, and below is my code that have problem: ----------------------------------------------- short a,x; long long y; a = (short)rand(); x = (short)rand() *10000/66536; y = a*x*x; printf( "a and x are %d, %d \n", a, x); printf( " y is: %lld \n", y); ---------------------------------------------- The problem is: the y result is always wrong. I have no idea why this is happening, any help? Zhu 2012-03-22 -------------- next part -------------- An HTML attachment was scrubbed... URL: From Richard.Earnshaw at arm.com Fri Mar 23 09:56:06 2012 From: Richard.Earnshaw at arm.com (Richard Earnshaw) Date: Fri, 23 Mar 2012 09:56:06 +0000 Subject: [arm-gnu] an long long problem In-Reply-To: <201203230013086258096@qq.com> References: <201203230013086258096@qq.com> Message-ID: <4F6C48B6.9010301@arm.com> On 22/03/12 16:13, zzzh.2007 wrote: > Hi, all, > > I am using sourcery_g++_lite_for_arm_eabi ( version of > arm-2008q3-66-arm-none-eabi) in Contiki to do some programming, and > below is my code that have problem: > > ----------------------------------------------- > short a,x; > long long y; > > a = (short)rand(); > x = (short)rand() *10000/66536; > > y = a*x*x; > > printf( "a and x are %d, %d \n", a, x); > printf( " y is: %lld \n", y); > > ---------------------------------------------- > The problem is: the y result is always wrong. > > I have no idea why this is happening, any help? > > ------------------------------------------------------------------------ > Zhu > 2012-03-22 > > ATT00001..txt > > > _______________________________________________ > arm-gnu mailing list > arm-gnu at codesourcery.com > http://sourcerytools.com/cgi-bin/mailman/listinfo/arm-gnu The most likely reason is that your stack is not correctly aligned. Why that might be the case you'll have to look into in more detail, there could be more than one reason. It might be that your startup code is incorrect; or it might be that your code is running in an interrupt context in cortex-m3 and you haven't correctly arranged for the stack to be re-aligned either by the hardware or the software. R. -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. From laurent.desnogues at gmail.com Fri Mar 23 10:02:23 2012 From: laurent.desnogues at gmail.com (Laurent Desnogues) Date: Fri, 23 Mar 2012 11:02:23 +0100 Subject: [arm-gnu] an long long problem In-Reply-To: <201203230013086258096@qq.com> References: <201203230013086258096@qq.com> Message-ID: On Thu, Mar 22, 2012 at 5:13 PM, zzzh.2007 wrote: > Hi, all, > > I am using sourcery_g++_lite_for_arm_eabi ( version of > arm-2008q3-66-arm-none-eabi) in Contiki to do some programming, and below is > my code that have problem: > > ----------------------------------------------- > short a,x; > long long?y; > > a = (short)rand(); > x = (short)rand() *10000/66536; > > y = a*x*x; It's hard to say what you mean by wrong, but if you really want a 64-bit product you'll have to cast at least one of the terms. For instance: y = (long long)a*x*x; Laurent > printf( "a and x are %d, %d \n", a, x); > printf( " y is: %lld \n", y); > > ---------------------------------------------- > The problem is: the y result is always wrong. > > I have no idea why this is happening, any help? > > ________________________________ > Zhu > 2012-03-22 > > _______________________________________________ > arm-gnu mailing list > arm-gnu at codesourcery.com > http://sourcerytools.com/cgi-bin/mailman/listinfo/arm-gnu > From John.Ansell at CooperIndustries.com Fri Mar 23 10:16:25 2012 From: John.Ansell at CooperIndustries.com (Ansell, John) Date: Fri, 23 Mar 2012 11:16:25 +0100 Subject: [arm-gnu] an long long problem In-Reply-To: <4F6C48B6.9010301@arm.com> References: <201203230013086258096@qq.com> <4F6C48B6.9010301@arm.com> Message-ID: <561453779232B648829350EBCA189B2109051EDE@EUREVS1.eur.ci.root> > On 22/03/12 16:13, zzzh.2007 wrote: > Hi, all, > > I am using sourcery_g++_lite_for_arm_eabi ( version of > arm-2008q3-66-arm-none-eabi) in Contiki to do some programming, and > below is my code that have problem: > > ----------------------------------------------- > short a,x; > long long y; > > a = (short)rand(); > x = (short)rand() *10000/66536; > > y = a*x*x; > > printf( "a and x are %d, %d \n", a, x); > printf( " y is: %lld \n", y); > > ---------------------------------------------- > The problem is: the y result is always wrong. > > I have no idea why this is happening, any help? > > --------------------------------------------------------------------- --- > Zhu > 2012-03-22 > > ATT00001..txt > > > _______________________________________________ > arm-gnu mailing list > arm-gnu at codesourcery.com > http://sourcerytools.com/cgi-bin/mailman/listinfo/arm-gnu Depends what you mean by 'wrong'... The results look OK when I build it, albeit with a slightly older compiler (2007q1). If the results are a bit out for large values of x, maybe you meant to divide x by 65536? If they're miles out, it's something else :) Cheers From bruno.richard.fr at gmail.com Fri Mar 23 09:21:01 2012 From: bruno.richard.fr at gmail.com (Bruno Richard) Date: Fri, 23 Mar 2012 10:21:01 +0100 Subject: [arm-gnu] Some symbols computation does not work right in LD Message-ID: I found a problem in the ARM-EABI linker: In .ld files, when some symbols are computed, their results when computed by LD look invalid. This problem was not showing on GCC versions up to 4.5.2, and is present with 4.6.1. To show the problem, use the following command line: arm-none-eabi-ld.exe" -T test.ld main.o -o main.elf -Map main.map Here is an excerpt of the linker file that shows the problem: _eidata1 = (_sidata + _edata) - _sdata ; /* 0x08000004 in map file */ _eidata2 = _sidata + (_edata - _sdata); /* 0x08000004 in map file */ same = (_eidata1 == _eidata2) ? 0x1 : 0x0; /* 0x00000000 in map file !!!*/ The "same" Symbol should be 1, not 0. I attach a zip file containing the files necessary to reproduce the problem. -- Bruno Richard +33 (6) 03 60 66 95 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ARM_BUG_LD_operator.zip Type: application/zip Size: 3909 bytes Desc: not available URL: From LEH at rtx.dk Fri Mar 23 13:35:35 2012 From: LEH at rtx.dk (=?iso-8859-1?Q?Leo_Havm=F8ller?=) Date: Fri, 23 Mar 2012 06:35:35 -0700 Subject: [arm-gnu] .debug_type missing from elf output Message-ID: <3625CB86347ED04988A349ED2BF75B8901CDC9BD42@IE2RD2XVS871.red002.local> With arm-2011.09-69-arm-none-eabi, the entire .debug_types section is missing from the elf output (compiling with -gdwarf-4). OK with arm-2011.03-42-arm-none-eabi. Leo Havm?ller. -------------- next part -------------- An HTML attachment was scrubbed... URL: From i-love-spam at yandex.ru Mon Mar 26 00:57:09 2012 From: i-love-spam at yandex.ru (i-love-spam) Date: Mon, 26 Mar 2012 04:57:09 +0400 Subject: [arm-gnu] [BUG]: Error: bad instruction `strhne r3,[r0]' WTF? Message-ID: <633111332723429@web81.yandex.ru> ] X-pstn-settings: 4 (1.5000:1.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] I simply have no explanation. It's a bug. here's the code: strhne r3,[r0] arm-none-eabi-gcc.exe -marm -g -D__ELF__ -mcpu=cortex-a8 -mfpu=neon -c test.S -march=armv7-a -o test.S.o I use: gcc version 4.6.1 (Sourcery CodeBench Lite 2011.09-69) any idea what's wrong, maybe I can use some alternative name that GCC/binutils use for this opcode? Thanks From julian at codesourcery.com Mon Mar 26 15:37:34 2012 From: julian at codesourcery.com (Julian Brown) Date: Mon, 26 Mar 2012 16:37:34 +0100 Subject: [arm-gnu] [BUG]: Error: bad instruction `strhne r3,[r0]' WTF? In-Reply-To: <633111332723429@web81.yandex.ru> References: <633111332723429@web81.yandex.ru> Message-ID: <20120326163734.707dbff6@octopus> On Mon, 26 Mar 2012 04:57:09 +0400 i-love-spam wrote: > ] > X-pstn-settings: 4 (1.5000:1.5000) s cv gt3 gt2 gt1 r p m c > X-pstn-addresses: from [db-null] > > I simply have no explanation. It's a bug. > > here's the code: > > strhne r3,[r0] > > arm-none-eabi-gcc.exe -marm -g -D__ELF__ -mcpu=cortex-a8 -mfpu=neon > -c test.S -march=armv7-a -o test.S.o > > > I use: > gcc version 4.6.1 (Sourcery CodeBench Lite 2011.09-69) > > > any idea what's wrong, maybe I can use some alternative name that > GCC/binutils use for this opcode? Try using: .syntax unified at the top of your assembly file, or write the instruction using non-unified syntax as: strneh r3,[r0] HTH, Julian From bob.brusa at gmail.com Mon Mar 26 16:44:20 2012 From: bob.brusa at gmail.com (Bob Brusa) Date: Mon, 26 Mar 2012 16:44:20 +0000 Subject: [arm-gnu] using codesourcery light with eclipse indigo Message-ID: <4F709CE4.6080100@gmail.com> Hi I use Sourcery_CodeBench_Lite_for_ARM_EABI (4.6.1) to compile a c/c++ program that uses a library produced from eCos. My program compiles and works, but eclipse cannot resolve the types int32_t, uint32_t etc. that are defined in the this library. The previous version of eclipse (helios) did not have this problem. Does anyone out there have good advice on this? Thanks and best regards. Bob. PS: I know, this questions would equilly well fit into an eclipse or eCos forum - but somewhere one must start asking questions ;-) From carlos_odonell at mentor.com Mon Mar 26 18:57:25 2012 From: carlos_odonell at mentor.com (Carlos O'Donell) Date: Mon, 26 Mar 2012 14:57:25 -0400 Subject: [arm-gnu] using codesourcery light with eclipse indigo In-Reply-To: <4F709CE4.6080100@gmail.com> References: <4F709CE4.6080100@gmail.com> Message-ID: <4F70BC15.5000308@mentor.com> On 3/26/2012 12:44 PM, Bob Brusa wrote: > Hi I use Sourcery_CodeBench_Lite_for_ARM_EABI (4.6.1) to compile a > c/c++ program that uses a library produced from eCos. My program > compiles and works, but eclipse cannot resolve the types int32_t, > uint32_t etc. that are defined in the this library. The previous > version of eclipse (helios) did not have this problem. Does anyone > out there have good advice on this? Thanks and best regards. Bob. > > PS: I know, this questions would equilly well fit into an eclipse or > eCos forum - but somewhere one must start asking questions ;-) I'd start by asking in the upstream Eclipse/CDT mailing list. The default type resolvers for C/C++ are part of CDT. PS: Sourcery CodeBench Personal Edition[1] comes with the latest version of our commercial tools (also 4.6.1 based) and an already integrated Eclipse Indigo (3.7.1). [1] http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/platforms/arm-eabi Cheers, Carlos. -- Carlos O'Donell Mentor Graphics / CodeSourcery carlos_odonell at mentor.com carlos at codesourcery.com +1 (613) 963 1026 From i-love-spam at yandex.ru Wed Mar 28 03:11:26 2012 From: i-love-spam at yandex.ru (pps) Date: Tue, 27 Mar 2012 23:11:26 -0400 Subject: [arm-gnu] [BUG]: Error: bad instruction `strhne r3,[r0]' WTF? In-Reply-To: <20120326163734.707dbff6@octopus> References: <633111332723429@web81.yandex.ru> <20120326163734.707dbff6@octopus> Message-ID: <4F72815E.6020301@yandex.ru> ] X-pstn-settings: 4 (1.5000:1.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] On 26-Mar-12 11:37, Julian Brown wrote: > On Mon, 26 Mar 2012 04:57:09 +0400 > i-love-spam wrote: > >> ] >> X-pstn-settings: 4 (1.5000:1.5000) s cv gt3 gt2 gt1 r p m c >> X-pstn-addresses: from [db-null] >> >> I simply have no explanation. It's a bug. >> >> here's the code: >> >> strhne r3,[r0] >> >> arm-none-eabi-gcc.exe -marm -g -D__ELF__ -mcpu=cortex-a8 -mfpu=neon >> -c test.S -march=armv7-a -o test.S.o >> >> >> I use: >> gcc version 4.6.1 (Sourcery CodeBench Lite 2011.09-69) >> >> >> any idea what's wrong, maybe I can use some alternative name that >> GCC/binutils use for this opcode? > > Try using: > > .syntax unified > > at the top of your assembly file, or write the instruction using > non-unified syntax as: > > strneh r3,[r0] > Hello Julian, I'll try .syntax unified By random luck after hours searching, I decided to try to rewrite asm and tried strneh instead of strhne and it worked. That's quite surprising that gnu assembler simply doesn't support opcode names listed in arm docs. At some point I also wasted some time with SAX and ASX, which I had to rename as addsubx and subaddx