EmbDev.net

Forum: ARM programming with GCC/GNU tools _sbrk error , how to solve for STM32F4 ?


von magnetron (Guest)


Rate this post
useful
not useful
I am trying to compile a C program for STM32F4 microcontroller
with yagarto

I have run into following error
1
c:/olimexods/yagarto/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/lib\libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
2
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.18.0/newlib/libc/reent/sbrkr.c:60: undefined reference to `_sbrk'

I have been told to implement this sbrk by myself
however first I decided to ask in the forum if somebody
faced this error before ?

now my question

did anybody face this error before ?
how did you solve it ?
or could you solve it ?

thanks

von Oliver (Guest)


Rate this post
useful
not useful
google finds 33.600 entries for "undefined _sbrk"

No, you are not the first one who did not read the documentation and 
checked for a solution using google...

You should read the newlib documentation, to understand the reason and 
possible solution.

After carefully reading this you might look ath this:
http://www.yagarto.de/download/yagarto/syscalls.c

Oliver

von magnetron (Guest)


Rate this post
useful
not useful
hello forum,

I tried to copy a syscall.c from the
newlib documents --> http://sourceware.org/newlib/

          caddr_t sbrk(int incr) {
            extern char _end;    /* Defined by the linker */
            static char *heap_end;
            char *prev_heap_end;

            if (heap_end == 0) {
              heap_end = &_end;
            }
            prev_heap_end = heap_end;
            if (heap_end + incr > stack_ptr) {
              write (1, "Heap and stack collision\n", 25);
              abort ();
            }

            heap_end += incr;
            return (caddr_t) prev_heap_end;
          }

my question
what does the micro do when abort() is called ?
does the micro stop running or does the program crash ?

I dont want my micro board fry - its 50.- US$
once my another program crashed and my micro fried indeed

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.