iprintf on the STM32 Microcontroller
James McGill
plexer@gmail.com
Tue Oct 13 14:29:00 GMT 2009
Hi,
I am trying to get newlib (as provided with the codesourcery-g++
toolchain) working. I have provided the stubs for _write _sbrk and
_fstat. When including the line
iprintf("Test")
I observe that _sbrk is called twice - increasing the heap by 436
bytes - and _fstat is called once, but _write is never called. The
calls to _sbrk and and _fstat look fine - the file ID passed to _fstat
is 1, as expected. Is this the correct behaviour?
My implementations of _sbrk and _fstat are as follows:
int _fstat(int file, struct stat *st) {
st->st_mode = S_IFCHR;
return 0;
}
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;
}
Regards,
James
More information about the Newlib
mailing list