Skip to content

Extra carrige return when using printf and newlib #86908

Closed as not planned
Closed as not planned
@runsiv

Description

@runsiv

Describe the bug

When using printf together with newlib.c the z_impl_zephyr_write_stdout from lib-hooks.c add an extra carriage return from

int z_impl_zephyr_write_stdout(const void *buffer, int nbytes)
in addition to the uart_console.c which prepend every line feed (\n)

To Reproduce

  1. Open a hello world sample
  2. Add CONFIG_NEWLIB_LIBC=y in prj.conf
  3. add printk("printk 0d0a:\n");
  4. add printf("printf 0d0d0a:\n");
  5. compile
  6. observe print in hex format

Expected behavior
Both print should have the same number of carriage return
Impact

Logs and console output

Environment (please complete the following information):

  • OS: (Ubuntu 24.04 and windows 11)
  • Toolchain (NCS 2.9, but the functions are the same in zephyr main)
  • Commit SHA or Version used

Image

Additional context

Metadata

Metadata

Assignees

Labels

Stalearea: C LibraryC Standard LibrarybugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions