_sbrk error , how to solve for STM32F4 ?

Guest #2947265
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
Guest #2949086
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

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.