Re: [arm-gnu] Codesourcery Lite and Newlib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [arm-gnu] Codesourcery Lite and Newlib
- Subject: Re: [arm-gnu] Codesourcery Lite and Newlib
- From: James McGill <james.mcgill@xxxxxxxxxxxxxxxx>
- Date: Tue, 13 Oct 2009 20:25:28 +1000
I discovered a bug in my linking script which was causing newlib to
crash (global variables were all off by one byte).
However, now when I include the line:
iprintf("Hello, world");
Newlib calls my _sbrk implementation twice, followed by my _fstat
implementation - but never calls my _write implementation. I've tried
returning both 0 and -1 from fstat, and either setting st->st_mode =
S_IFCHR; or just leaving st untouched.
My _sbrk routine should be doing what it needs to:
caddr_t _sbrk(int incr) {
extern char _end;
static char *heap_end;
char *prev_heap_end;
if (heap_end == 0) {
heap_end = &_end;
}
prev_heap_end = heap_end;
heap_end += incr;
return (caddr_t) prev_heap_end;
}
The heap grows by about 436 bytes when iprintf is called. I have
verified that it does not overlap the stack, or anything in the .data
section.
Regards,
James
On Tue, Oct 13, 2009 at 5:00 PM, James <jamessteward@xxxxxxxxxxxxxxx> wrote:
> On Tue, 2009-10-13 at 07:23 +0200, Freddie Chopin wrote:
>> standard newlib's printf is usually too much of a bloat to be used for
>> microcontrollers, but - it's possible, I've tried recently to find out
>> why so many ppl have trouble with them. Stack...
>
> For development purposes, I grabbed a sprintf from u-boot source, that I
> think may have come from Linux kernel sources originally. I modified it
> to be a buffered printf.
>
> James.
>
>