ESP32-S3 Posix FILE SYSTEM APIs crashing regardless LIBC implementation #97734
Replies: 2 comments
-
|
@alespitfire will check. |
Beta Was this translation helpful? Give feedback.
-
|
@alespitfire Using your modified version of fs_sample, I reproduced the behavior you described and confirmed that the failure occurs when the fread() function is called. issue #66940 - libc: implement fread() was closed indicating that the implementation of As a workaround, I replaced the fopen() and fread() calls with calls to open() and read() in your modified version of fs_sample - along with the necessary additional changes - and I can confirm that open() and read() are working in Zephyr: #include <unistd.h>
#include <fcntl.h>
static void test_posix(const char *path)
{
char fname[MAX_PATH];
snprintk(fname, sizeof(fname), "%s/%s", path, SOME_FILE_NAME);
// FILE *fp = fopen(fname, "r");
// if (fp == NULL) {
int fd = open(fname, O_RDONLY);
if (fd < 0) {
printk("File %s open error\n", fname);
return;
}
char read_buf[26];
memset(read_buf, 0, sizeof(read_buf));
// size_t n = fread(read_buf, 1, sizeof(read_buf), fp);
// if (n > 0) {
// printk("Read %zu bytes from %s: '%s'\n", n, fname, read_buf);
// } else if (n >= sizeof("Hello World!")) {
// printk("Read buffer too small from %s\n", fname);
// } else {
// printk("Read error or zero bytes read from %s\n", fname);
// }
size_t n = read(fd, read_buf, sizeof(read_buf));
if (n > 0) {
read_buf[n] = '\0';
printk("Read %zu bytes from %s: '%s'\n", n, fname, read_buf);
} else {
printk("Read error or zero bytes read from %s\n", fname);
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am trying without any success to have POSIX library working with file system API.
In particular I need fopen, fread, fwrite and fstat.
I am working with the ESP32-S3 as mcu connected to an SD card.
I have no constraints about Zephyr version. I have no constraints about file system (but a preference for FATFS).
I have tried to readjust the fs_sample to use the posix functions to read from files but I fail, the system crashes.
(look at the attached file main.c function void test_posix(const char *path) L.125)
fs_sample.zip
I suspect the issue is in the libc or posix implementation as the fs_sample based on Zephyr File System works flawlessly.
In addition without expliciting which libc the compiler should use, the system does not crash; instead by adding
CONFIG_NEWLIB_LIBC=yorCONFIG_PICOLIBC_USE_MODULE=ythe system crashes.Can you help me to figure this out?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions