mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-03 14:01:53 +00:00
When CONFIG_VFS_SUPPORT_IO is disabled, _read_r and _write_r implementations in syscalls.c are used to provide console I/O via esp_rom_uart_tx_one_char/esp_rom_uart_rx_one_char. When newlib opens a (FILE*) stream, it calls fstat to check if the underlying file is character-oriented. In this case, it configures the stream to use line buffering. Otherwise (or if fstat fails) the stream is opened as block buffered. Since fstat wasn't provided, stdin/stdout/stderr streams got opened in block buffered mode. For console, we need line buffered output so that the stream buffer is flushed each time a complete line (ending with '\n') is sent to stdout or stderr. Fix by implementing _fstat_r stub, setting st->st_mdoe=S_IFCHR.