This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]