# FreeRTOS and newlib

**URL:** <https://forums.freertos.org/t/freertos-and-newlib/58>\
**Category:** Kernel\
**Created:** [March 31, 2006, 8:46am UTC](https://forums.freertos.org/t/freertos-and-newlib/58 "2006-03-31T08:46:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 31, 2006, 8:46am UTC](https://forums.freertos.org/t/freertos-and-newlib/58/1 "2006-03-31T08:46:18Z")

</div>

**nobody** wrote on [Friday, March 31, 2006](https://sourceforge.net/p/freertos/discussion/382005/thread/057b3b30/#e64d):

Hi,

If you want to use newlib for your FreeRTOS/ARM project, you should have a look at the sbrk function  
in syscalls.c.  
There is a range check like:  
if (heap\_end + incr \> stack\_ptr) return error;  
and  
heap\_end = & end;

Depending on your FreeRTOS heap version the stack pointer shows in your global memory section, normaly the lower RAM.  
Wheras .end points at the end of your stack, normaly at the end of RAM.  
So end is alway greater than stack pointer and the memory allocation of newlib fails.  
So if your printf doesn’t work you maybe look at this one.  
syscalls.c should be part of your project files.  
Greets,  
Joerg

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 31, 2006, 9:05am UTC](https://forums.freertos.org/t/freertos-and-newlib/58/2 "2006-03-31T09:05:36Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, March 31, 2006](https://sourceforge.net/p/freertos/discussion/382005/thread/057b3b30/#e64d/756d):

So the heap\_3.c allocation would presumably fail?&nbsp; Thanks for the information.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 31, 2006, 2:18pm UTC](https://forums.freertos.org/t/freertos-and-newlib/58/3 "2006-03-31T14:18:00Z")

</div>

**nobody** wrote on [Friday, March 31, 2006](https://sourceforge.net/p/freertos/discussion/382005/thread/057b3b30/#e64d/3978):

Yes I think so, as malloc calls presumably sbrk.  
I don’t now for sure cause I still use heap\_1.  
Regards
