forked from espressif/esp-idf
newlib: implement fsync for the case of CONFIG_VFS_SUPPORT_IO=0
This feature allows calling fsync even if the vfs component is not used. The second part of the commit adds an fsync call in the panic test app enabling it to be used over usb-serial-jtag.
This commit is contained in:
@@ -73,6 +73,22 @@ static ssize_t _fstat_r_console(struct _reent *r, int fd, struct stat * st)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int _fsync_console(int fd)
|
||||
{
|
||||
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
|
||||
#ifdef CONFIG_ESP_CONSOLE_UART
|
||||
esp_rom_uart_flush_tx(CONFIG_ESP_CONSOLE_UART_NUM);
|
||||
#elif defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG)
|
||||
esp_rom_uart_flush_tx(CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM);
|
||||
#elif defined(CONFIG_ESP_CONSOLE_USB_CDC)
|
||||
esp_rom_uart_flush_tx(CONFIG_ESP_ROM_USB_OTG_NUM);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* The following weak definitions of syscalls will be used unless
|
||||
* another definition is provided. That definition may come from
|
||||
@@ -84,6 +100,8 @@ ssize_t _write_r(struct _reent *r, int fd, const void * data, size_t size)
|
||||
__attribute__((weak,alias("_write_r_console")));
|
||||
int _fstat_r (struct _reent *r, int fd, struct stat *st)
|
||||
__attribute__((weak,alias("_fstat_r_console")));
|
||||
int fsync(int fd)
|
||||
__attribute__((weak,alias("_fsync_console")));
|
||||
|
||||
|
||||
/* The aliases below are to "syscall_not_implemented", which
|
||||
|
@@ -27,6 +27,7 @@ void die(const char* msg)
|
||||
{
|
||||
printf("Test error: %s\n\n", msg);
|
||||
fflush(stdout);
|
||||
fsync(fileno(stdout));
|
||||
usleep(1000);
|
||||
/* Don't use abort here as it would enter the panic handler */
|
||||
esp_restart_noos();
|
||||
|
Reference in New Issue
Block a user