Configuration?


Anders
 

Thank you all for sharing useful information!

/Anders


Stephanos Ioannidis
 

Hi,

After searching the internet I found out that when using CONFIG_NEWLIB_LIBC=y I also have to add CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y to make things work as expected.
There are multiple "backends" for the [s]printf function in the Zephyr:

* minimal libc (cbprintf)
* newlib

In case of newlib, you need to enable CONFIG_NEWLIB_LIBC_FLOAT_PRINTF as you mentioned above.
In case of the minimal libc (cbprintf), you need to set CONFIG_CBPRINTF_FP_SUPPORT.

Please note that the newlib is not a prerequisite for making printf work with floats.

Where can I find this kind of information, e.g. dependencies, to avoid having to search the internet for answers in the future?
Usually, Kconfig is a good source of information for such dependencies (e.g. search for "float printf" in the menuconfig).

There is also a more comprehensive documentation about the formatted output support in general (though, it does not mention the newlib-related details):
https://docs.zephyrproject.org/latest/reference/misc/formatted_output.html

Regards,

Stephanos

-----Original Message-----
From: users@... <users@...> On Behalf Of Anders via lists.zephyrproject.org
Sent: Wednesday, November 24, 2021 6:24 PM
To: users@...
Subject: [Zephyr-users] Configuration?

Hi,

I have just started working with Zephyr and struggled the other day with getting sprintf working for floats.

After searching the internet I found out that when using CONFIG_NEWLIB_LIBC=y I also have to add CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y to make things work as expected.

Where can I find this kind of information, e.g. dependencies, to avoid having to search the internet for answers in the future?

Thx in advance,
Anders


Carles Cufi
 

Hi Dave,

 

Thread safety for newlib was implemented in Zephyr recently, there should not be any issues left with it. If there are, please open a GitHub issue:

 

https://github.com/zephyrproject-rtos/zephyr/pull/36201

https://github.com/zephyrproject-rtos/zephyr/pull/35227

 

Thanks,

 

Carles

 

 

From: users@... <users@...> On Behalf Of Dave Nadler via lists.zephyrproject.org
Sent: 24 November 2021 17:13
To: Anders <anders.thernstrom@...>; users@...
Subject: Re: [Zephyr-users] Configuration?

 

Careful Anders! Last I looked, newlib was not really supported properly in Zephyr.
Internally newlib sometimes uses free storage, and the OS needs to implement some hooks for thread-safety.
See for example FreeRTOS issues with the same:
https://nadler.com/embedded/NXP_newlibAndFreeRTOS.html

Hope that helps,
Best Regards, Dave

 

PS: Picolib is striving to avoid internal malloc-etc use.

 

On 11/24/2021 4:24 AM, Anders wrote:

Hi,
 
I have just started working with Zephyr and struggled the other day with getting sprintf working for floats.
 
After searching the internet I found out that when using CONFIG_NEWLIB_LIBC=y I also have to add CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
to make things work as expected.
 
Where can I find this kind of information, e.g. dependencies, to avoid having to search the internet for answers in the future?
 
Thx in advance,
Anders
 
 

 

-- 
Dave Nadler, USA East Coast voice (978) 263-0097, drn@..., Skype 
 Dave.Nadler1


Dave Nadler
 

Careful Anders! Last I looked, newlib was not really supported properly in Zephyr.
Internally newlib sometimes uses free storage, and the OS needs to implement some hooks for thread-safety.
See for example FreeRTOS issues with the same:
https://nadler.com/embedded/NXP_newlibAndFreeRTOS.html

Hope that helps,
Best Regards, Dave

PS: Picolib is striving to avoid internal malloc-etc use.

On 11/24/2021 4:24 AM, Anders wrote:
Hi,

I have just started working with Zephyr and struggled the other day with getting sprintf working for floats.

After searching the internet I found out that when using CONFIG_NEWLIB_LIBC=y I also have to add CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
to make things work as expected.

Where can I find this kind of information, e.g. dependencies, to avoid having to search the internet for answers in the future?

Thx in advance,
Anders



-- 
Dave Nadler, USA East Coast voice (978) 263-0097, drn@..., Skype 
 Dave.Nadler1


Anders
 

Hi,

I have just started working with Zephyr and struggled the other day with getting sprintf working for floats.

After searching the internet I found out that when using CONFIG_NEWLIB_LIBC=y I also have to add CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
to make things work as expected.

Where can I find this kind of information, e.g. dependencies, to avoid having to search the internet for answers in the future?

Thx in advance,
Anders