This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RE: iprintf on the STM32 Microcontroller
- From: "Howland Craig D (Craig)" <howland at LGSInnovations dot com>
- To: "James McGill" <plexer at gmail dot com>
- Cc: <newlib at sourceware dot org>
- Date: Tue, 13 Oct 2009 10:28:50 -0400
- Subject: RE: iprintf on the STM32 Microcontroller
- References: <9272038d0910130350gb38b5a7j2355bc7ac92dd7e5@mail.gmail.com>
James:
This sounds reasonable. If you add a newline (i.e.
iprintf("Test\n");), write should be called, as line buffering is the
normal default.
Craig
-----Original Message-----
From: newlib-owner@sourceware.org [mailto:newlib-owner@sourceware.org]
On Behalf Of James McGill
Sent: Tuesday, October 13, 2009 6:50 AM
To: newlib@sourceware.org
Subject: iprintf on the STM32 Microcontroller
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