Porting newlib to new target using libgloss

Hard Maker hardmaker@gmail.com
Wed Jun 29 15:33:00 GMT 2011

Thank's a lot  David.
With this I have more information to continue my work.

El 28/06/2011 12:44 p.m., David Paterson escribió:
> On Tue, Jun 28, 2011 at 1:26 AM, Hard Maker<hardmaker@gmail.com>  wrote:
>> Hi list,
>> I'm trying to port newlib for use in a development kit. This use a Cortex
>> M3, so I need to port only the specific system calls to work with the
>> asociated  hardware.
>> There are some "guide" to do this? I'm googling from a week's and I can make
>> the port using a custom CRT0, but I don't know how to reuse the startup code
>> from libgloss for Cortex and add my code for the peripherical hardware.
>> Other question, when use newlib witch gcc, in C and C++ lenguage: ¿where can
>> I read about the definitions needed in the linker script? I'm test with a
>> linker script finded in internet but I know are some linkers script builded
>> with the source, but I don't know how and which I need use (hosted or
>> semihosted). Again, I'm using a cortex m3.
>> Thank's a lot.
>> Sergio
> Hi Sergio,
> I've been working on something similar, so might be able to help -
> although my port
> is to Sparc Leon, so there will be some differences.  I can perhaps
> point you to some
> useful resources however.
> Three documents I found helpful were Jeremy Bennett's "Simple Guide" :-
> http://www.embecosm.com/download/ean9.html
> Bill Gatliff's "Porting and Using Newlib" (see section 6 on porting) :-
> http://neptune.billgatliff.com/newlib.html
> and (even though it's quite old and probably could do with an update) :-
> http://sca.uwaterloo.ca/coldfire/gcc-doc/docs/porting_toc.html
> and there are lots of other bits of info around the net, as I'm sure
> you've found...
> There are 18 functions which you need to implement, although most of them will
> just be stubs returning an error code.
> In my case the only things I needed were "sbrk" for malloc support, and simple
> character I/O for printf debugging.  If you're not supporting a file system, or
> processes, then you probably won't need much more.
> I looked at the crt0 and linker scripts in the Newlib download, but
> ended up writing
> my own in both cases, so I could get exactly what I wanted.  Like you
> I wanted to
> add special hardware initialisation, so I put that into the startup
> sequence in crt0.
> For my linker script I used similar ideas to those in Newlib, and
> added additional
> symbols which crt0 could check to control initialisation.  You can
> create any symbols
> you like in the script, and refer to them in crt0, or in your own
> libraries.  This can be
> quite useful - for example I can pass a "_debugging" flag to the
> linker which enables
> the character I/O, allocates buffers etc. for debug builds only.
> To simplify the command line for linking, I added a couple of references in the
> script file as well :-
> ENTRY(_start)
> STARTUP(leon-crt0.o)
> INPUT(crti.o crtbegin.o crtend.o crtn.o)
> GROUP(-lleon -lc -lstdc++ -lgcc)
> I hope this is of some help to you, and if there's anything I can help
> with please
> ask, although I probably can't help too much on Cortex-specific issues.
> Regards,
> David P.

More information about the Newlib mailing list