Skip to main content
PHolt.1
Senior
May 1, 2023
Question

Does Cube MX build the libc.a printf/canf/heap/etc library?

  • May 1, 2023
  • 11 replies
  • 4018 views

Yesterday's post here

https://community.st.com/s/question/0D53W00002F4MHrSAN/is-there-a-bug-in-the-newlib-heap-on-the-32f417-cube-ide-library?t=1682872893044

refers.

This article

https://nadler.com/embedded/newlibAndFreeRTOS.html

suggests that the freertosconfig.h file can contain configUSE_NEWLIB_REENTRANT =1 and this causes MX to build libc.a with the proper mutex calls.

That suggests MX has the sources. But I have Cube IDE installed (been using it for a couple of years, but have never used MX) and there are no sources there for this stuff.

I find this amazing because I have never seen ST supply any sources for these parts of stdlib. And the many supplied versions of libc.a (which can be found in c:\ST - there are 66 of these) come only in a compiled form, and not "weak" so the mutex calls, which are dummy functions, cannot be fixed by making use of the "weak" override mechanism. I had to weaken the whole libc.a and then I could do it.

This topic has been closed for replies.

11 replies

PHolt.1
PHolt.1Author
Senior
May 7, 2023

I am happy that somebody agrees with me and doesn't call me an id1iot : - )

It is fairly easy to locate the sources (newlib libc.a dates to 1990, nano 1998, afaict) and I did that when fixing the heap mutexes.

So why didn't ST include the sources? They give you the libs in src form for everything else. This just causes grief. All those people who are posting stuff like "my malloc keeps crashing" will never find out why. AFAICT ST did sod-all with the sources. They just built them with some build options, chosen, undocumented...