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

newlib printk float formatting not working #31219

Closed
gdf8gdn8 opened this issue Jan 11, 2021 · 5 comments
Closed

newlib printk float formatting not working #31219

gdf8gdn8 opened this issue Jan 11, 2021 · 5 comments
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@gdf8gdn8
Copy link

gdf8gdn8 commented Jan 11, 2021

Describe the bug
printk for foating point value not working.
printf format expected also in serveral drivers LPS25HB.

Code

float f= 123,456712356;
printk("%.6f\n",f);

Output

%.6f

Expected behavior

123,456712

Environment (please complete the following information):

  • OS: ArchLinux, Ubuntu 20.4
  • Toolchain
    -- zephyr-sdk-0.11.4
    -- west v0.8.0
    -- zephyr v2.3.0-2198
  • config: CONFIG_NEW_LIBC_FLOAT_PRINTF=y
@gdf8gdn8 gdf8gdn8 added the bug The issue is a bug, or the PR is fixing a bug label Jan 11, 2021
@ArseniSoitu
Copy link

Hello. May be the reason is #31168 bug? Struggled with it several days ago.

@pabigot
Copy link
Collaborator

pabigot commented Jan 11, 2021

printk uses a Zephyr-internal formatting utility now; you don't need to select newlib for that unless you're using standard C functions like printf(). See this documentation. You'll want CONFIG_CBPRINTF_FP_SUPPORT=y.

@pabigot pabigot self-assigned this Jan 11, 2021
@pabigot pabigot added the priority: low Low impact/importance bug label Jan 11, 2021
@pabigot
Copy link
Collaborator

pabigot commented Jan 11, 2021

Ah; I see you seem to be using a Zephyr version before 2.4.0 was released. printk didn't support FP back then. The solution I recommended is available in the current development version and will be in 2.5 in about a month.

@pabigot pabigot closed this as completed Jan 11, 2021
@pabigot pabigot reopened this Jan 11, 2021
@gdf8gdn8
Copy link
Author

Ah; I see you seem to be using a Zephyr version before 2.4.0 was released. printk didn't support FP back then. The solution I recommended is available in the current development version and will be in 2.5 in about a month.

It was fixed in v2.4.0. I updated to v2.4.0.

@pabigot
Copy link
Collaborator

pabigot commented Jan 12, 2021

Great; thanks for the update.

@pabigot pabigot closed this as completed Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

3 participants