public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: "onkel.jack@t-online.de" <onkel.jack@t-online.de>
To: "strohbeck@gmx.net" <strohbeck@gmx.net>
Cc: newlib mailing list <newlib@sourceware.org>
Subject: RE: Hard faults using sprintf() and float
Date: Mon, 03 Apr 2017 18:57:00 -0000	[thread overview]
Message-ID: <1491245845208.623385.991cf283b8dee5c28cb9611c604799844fc216c4@spica.telekom.de> (raw)
In-Reply-To: <63c8d131-9ce8-ffbd-28e7-67d122a61b78@strohbeck.net>

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 ?


      reply	other threads:[~2017-04-03 18:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24  8:31 Jochen Strohbeck
2017-03-24  9:38 ` Sebastian Huber
2017-03-24 11:46   ` Jochen Strohbeck
2017-03-24 13:41     ` Richard Earnshaw (lists)
2017-03-27  8:48       ` Jochen Strohbeck
2017-04-03 13:19         ` Jochen Strohbeck
2017-04-03 18:57           ` onkel.jack [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1491245845208.623385.991cf283b8dee5c28cb9611c604799844fc216c4@spica.telekom.de \
    --to=onkel.jack@t-online.de \
    --cc=newlib@sourceware.org \
    --cc=strohbeck@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).