Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBPRINTF_FP_SUPPORT does not work after NEWLIB_LIBC enabled #38764

Closed
kclauah opened this issue Sep 23, 2021 · 3 comments
Closed

CBPRINTF_FP_SUPPORT does not work after NEWLIB_LIBC enabled #38764

kclauah opened this issue Sep 23, 2021 · 3 comments

Comments

@kclauah
Copy link

kclauah commented Sep 23, 2021

Describe the bug
Terminal unable to print float value if these two config enabled.

CONFIG_NEWLIB_LIBC=y 
CONFIG_CBPRINTF_FP_SUPPORT=y

If CBPRINTF_FP_SUPPORT is set only, it can correctly print float to terminal.
I found out this issue when I testing samples/sensor/lsm6dso on nrf52dk_nrf528322.
I think this issue is related to #37777

To Reproduce
Steps to reproduce the behavior:

  1. Create a new project with these config.
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_NEWLIB_LIBC=y
  1. Add the following code.
float test_float = 1.23;
printf("float: %f\n",test_float);
  1. See the result on terminal

Expected behavior
Terminal print blank if CONFIG_NEWLIB_LIBC=y & CONFIG_CBPRINTF_FP_SUPPORT=y

float: 

It can correctly print float if remove CONFIG_NEWLIB_LIBC

float: 1.230000

Impact
I have to replaced all printf with printk in order to show float on terminal.

Logs and console output

Environment (please complete the following information):

  • OS: Windows 10 64-bit
  • Toolchain Zephyr SDK 2.6.0.rc-1

Additional context

@kclauah kclauah added the bug The issue is a bug, or the PR is fixing a bug label Sep 23, 2021
@stephanosio stephanosio added question and removed bug The issue is a bug, or the PR is fixing a bug labels Sep 23, 2021
@stephanosio
Copy link
Member

When newlib is enabled, printf is implemented by the newlib (and not by the cbprintf).

Please make sure that CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y.

@kclauah
Copy link
Author

kclauah commented Sep 23, 2021

Thank you, your solution works.
I just found out that newlib has its own implementation of printf and enabling newlib override cbprintf.
Sorry for the dumb question.

@stephanosio
Copy link
Member

No problem. This can be quite confusing to the people who are new to Zephyr.

Closing since the question has been answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants