This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: Building for cortex-m3
- From: Simon Wright <simon at pushface dot org>
- To: Jon Beniston <jon at beniston dot com>, newlib at sourceware dot org
- Date: Mon, 18 Apr 2011 01:52:50 +0100
- Subject: Re: Building for cortex-m3
- References: <11A32281-D4EB-4089-AA6C-979348C4865A@pushface.org> <000201cbfd4a$42dcb980$c8962c80$@beniston.com>
Jon suggested I rebuild newlib with GCC. I withdraw my remarks about multilib and crt0.o (which may have been down to leaving -mthumb out of the ld command) but crt0.o is still miscompiled: objdump -D says
$ arm-none-eabi-objdump -D crt0.o
crt0.o: file format elf32-littlearm
Disassembly of section .text:
00000000 <_mainCRTStartup>:
0: e59f30d0 ldr r3, [pc, #208] ; d8 <change_back+0x8>
4: e3530000 cmp r3, #0
....
which is ARM code, isn't it?
--S
On 17 Apr 2011, at 22:56, Jon Beniston wrote:
> Try building newlib with GCC (copy newlib and libgloss subdirs into gcc
> source dir)
>
> http://wyper.ca/news/2009/05/building-gcc-for-arm-cortex-m3/
>
> Cheers,
> Jon
>
>> -----Original Message-----
>> From: newlib-owner@sourceware.org [mailto:newlib-
>> owner@sourceware.org] On Behalf Of Simon Wright
>> Sent: 17 April 2011 17:22
>> To: newlib@sourceware.org
>> Subject: Building for cortex-m3
>>
>> I'm a newbie at Newlib, so please pardon any stupidities.
>>
>> I've been trying to build newlib-1.19.0 with GCC-4.6.0 for use with a bare
>> cortex-m3 (under qemu at the moment).
>>
>> The configurations I've tried include as basis
>>
>> $ ../newlib-1.19.0/configure --target=arm-none-eabi --disable-newlib-
>> supplied-syscalls
>>
>> and with just this I see that libgloss/arm/crt0.S and
>> newlib/libc/sys/arm/crt0.S both compile _mainCRTStartup in ARM mode;
>> which (I think) isn't going to work on the M3. They define FUNC_START as
>>
>> #if defined(__thumb2__)
>> .syntax unified
>> .thumb
>> .macro FUNC_START name
>> .global \name
>> .thumb_func
>> \name:
>> .endm
>> #else
>> .code 32
>> .macro FUNC_START name
>> .global \name
>> \name:
>> .endm
>> #endif
>>
>> so what happens if just __thumb__ is defined? (actually, I'm not at all
> clear
>> whether it is or not; is it a GCC builtin?).
>>
>> I've gone to my build directory and compiled arm-none-
>> eabi/thumb/newlib/libc/sys/arm/crt0.o (which is suppressed in the
>> Makefile). I copied it to $prefix/arm-none-eabi//lib/thumb/crt0.o with no
>> effect, then to $prefix/arm-none-eabi//lib/crt0.o which was used in my
>> build. (The fact that I'm now getting a usage fault is, I think,
> progress!)
>> Shouldn't crt0.o be part of the multilib scheme?
>>
>> TIA for any suggestions/pointers/...
>>
>> --S
>