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]

RE: Hard faults using sprintf() and float


Just a hint:

I run into same problem for 2 reasons, but for a different operating system:
1. the malloc locks (using newlib malloc) did not work while I used multiple threads. this messed up the malloc chain.
2. I figured out, printf is quite hungry in respect of using stack. Depending on newlib config and version the stack usage of printf family counts up to around 1,5 Kb. So I would suggest as first check the size of your stack to have enough space to bear the need of printf. Especially in your case while printing float, this sounds shomehow familiar to me.

Good luck.
OJ



-----Original-Nachricht-----
Betreff: Re: Hard faults using sprintf() and float
Datum: 2017-04-03T15:20:14+0200
Von: "Jochen Strohbeck" <jochen@strohbeck.net>
An: "newlib@sourceware.org" <newlib@sourceware.org>

The hard fault and strange formatted output does not happen if a
semaphore is used to protect sprintf().

Again, this problem seems only to happen if floats are printed and this
behaviour has been observed and reported by other users in the past and
I wonder what happens here. I have implemented malloc_r() which is using
FreeRTOS own heap4 pvPortMalloc() and is called by newlib's sprintf(),
printf(), puts() etc. So memory allocation seems not to be the real
problem here. Are there other functions to be implemented which are
called by sprintf() in order to protect it ?

In this article www.billgatliff.com/newlib.html the compile switch
REENTRANT_SYSCALLS_PROVIDED is mentioned. I defined
configUSE_NEWLIB_REENTRANT but get an ASSERT() due to a corrupted task
descriptor in FreeRTOS if sprintf() is not guarded by my semaphore.

I downloaded and compiled newlib on Windows but it seems that the lib is
built for Intel not ARM (makefile refers to gcc not arm-none-eabi-gcc).
Any switch that must be passed to configure ?


> Can I check if the provided newlib library is ready for (Free)RTOS
> applications ?



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