-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Describe the bug
There is a conflict between the picolibc
implementation of fdopen()
and Zephyr's implementation in zephyr/lib/posix/options/device_io.c
. The fopen()
function from picolibc
uses its own fdopen()
implementation, but instead of using picolibc
's fdopen()
, Zephyr’s fdopen()
from device_io.c
is being used. This causes issues with file stream flags and the behavior of functions like fgetc()
.
This issue arises from the changes introduced in PR #76352.
Steps to Reproduce:
- Enable the
POSIX_API
in Zephyr by setting the appropriate configuration. - Build the project with
picolibc
(precompiled in toolchain or usingCONFIG_PICOLIBC_USE_MODULE=y
it doesn't matter). - Attempt to use
fgetc()
or other file I/O operations. - Observe that
__SRD
flag is not set, causing functions likefgetc()
to fail.
You can add a breakpoint for fdopen
and see that it is using the implementation from zephyr/lib/posix/options/device_io.c
.
Expected Behavior:
The fdopen()
function from picolibc
should be used, ensuring proper handling of file stream flags and correct behavior of file-related functions like fgetc()
and fileno()
.
Actual Behavior:
The fdopen()
function from zephyr/lib/posix/options/device_io.c
is used instead, causing stream flag issues that prevent proper file I/O behavior, affecting functions such as fgetc()
and equivalent.
Affected Versions:
Zephyr 4.0.0 and later (introduced by PR #76352).
Impact
This issue prevents proper file I/O behavior when using picolib and POSIX API.
Environment:
- OS: Windows (WSL)
- Toolchain: Zephyr SDK 0.17
- Version used: Zephyr >= 4.0.0
Additional context
I'm not sure exactly where this issue should be reported—whether in the main Zephyr repository or in the picolibc repository. However, it seems like it might be something that needs to be addressed on the picolibc side (or in my project configuration).