mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
feat(esp_stdio): Revert breaking change
- also revert the modification in the singature of uninstall function in all the concerned esp_driver* components and esp_stdio. - added proper documentation of the feature in the programming guide
This commit is contained in:
@@ -50,9 +50,8 @@ esp_err_t uart_vfs_dev_port_init(const esp_console_dev_uart_config_t *config,
|
||||
* console backend.
|
||||
*
|
||||
* @param config Pointer to the UART VFS device configuration.
|
||||
* @return ESP_OK if deinitialization completes successfully, or an error code if it fails.
|
||||
*/
|
||||
esp_err_t uart_vfs_dev_port_deinit(const esp_console_dev_uart_config_t *config);
|
||||
void uart_vfs_dev_port_deinit(const esp_console_dev_uart_config_t *config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1163,7 +1163,6 @@ void uart_vfs_dev_use_driver(int uart_num)
|
||||
}
|
||||
|
||||
#if CONFIG_ESP_CONSOLE_UART
|
||||
|
||||
esp_err_t uart_vfs_dev_port_init(const esp_console_dev_uart_config_t *config,
|
||||
esp_line_endings_t rx_mode,
|
||||
esp_line_endings_t tx_mode)
|
||||
@@ -1219,11 +1218,10 @@ esp_err_t uart_vfs_dev_port_init(const esp_console_dev_uart_config_t *config,
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t uart_vfs_dev_port_deinit(const esp_console_dev_uart_config_t *config)
|
||||
void uart_vfs_dev_port_deinit(const esp_console_dev_uart_config_t *config)
|
||||
{
|
||||
uart_vfs_dev_use_nonblocking(config->channel);
|
||||
uart_driver_delete(config->channel);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
ESP_SYSTEM_INIT_FN(init_vfs_uart, CORE, BIT(0), 110)
|
||||
|
||||
+1
-2
@@ -51,9 +51,8 @@ esp_err_t usb_serial_jtag_vfs_dev_port_init(const esp_console_dev_usb_serial_jta
|
||||
* console backend.
|
||||
*
|
||||
* @param config Pointer to the USB Serial JTAG VFS device configuration.
|
||||
* @return ESP_OK if the driver was successfully uninstalled, or an error otherwise.
|
||||
*/
|
||||
esp_err_t usb_serial_jtag_vfs_dev_port_deinit(const esp_console_dev_usb_serial_jtag_config_t *config);
|
||||
void usb_serial_jtag_vfs_dev_port_deinit(const esp_console_dev_usb_serial_jtag_config_t *config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -704,12 +704,11 @@ esp_err_t usb_serial_jtag_vfs_dev_port_init(const esp_console_dev_usb_serial_jta
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t usb_serial_jtag_vfs_dev_port_deinit(const esp_console_dev_usb_serial_jtag_config_t *config)
|
||||
void usb_serial_jtag_vfs_dev_port_deinit(const esp_console_dev_usb_serial_jtag_config_t *config)
|
||||
{
|
||||
(void)config;
|
||||
usb_serial_jtag_vfs_use_nonblocking();
|
||||
usb_serial_jtag_driver_uninstall();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -14,6 +14,18 @@ extern "C" {
|
||||
|
||||
#define ESP_VFS_DEV_CONSOLE "/dev/console"
|
||||
|
||||
/**
|
||||
* @brief Register the default console VFS backend(s) selected in Kconfig.
|
||||
*
|
||||
* Sets up the primary (and any Kconfig-selected secondary) console sink and
|
||||
* mounts them under /dev/console. This function is automatically called from
|
||||
* startup code to enable serial output; applications normally do not need to
|
||||
* call it themselves.
|
||||
*
|
||||
* @return ESP_OK on success, or an error code from the underlying VFS registration.
|
||||
*/
|
||||
esp_err_t esp_stdio_register(void);
|
||||
|
||||
#if CONFIG_VFS_SUPPORT_IO
|
||||
|
||||
#include "esp_vfs_common.h"
|
||||
@@ -134,7 +146,7 @@ esp_err_t esp_stdio_install_io_driver(void);
|
||||
* If a user has taken over the primary console with esp_stdio_push_primary(),
|
||||
* this function is a no-op.
|
||||
*/
|
||||
esp_err_t esp_stdio_uninstall_io_driver(void);
|
||||
void esp_stdio_uninstall_io_driver(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -21,10 +21,9 @@ static void disable_raw_mode(void)
|
||||
assert(tcsetattr(STDIN_FILENO, TCSAFLUSH, &s_orig_termios) == 0);
|
||||
}
|
||||
|
||||
esp_err_t linux_vfs_dev_port_deinit(linux_port_config_t *config)
|
||||
void linux_vfs_dev_port_deinit(linux_port_config_t *config)
|
||||
{
|
||||
(void)config;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t linux_vfs_dev_port_init(linux_port_config_t *config)
|
||||
|
||||
@@ -43,9 +43,8 @@ esp_err_t linux_vfs_dev_port_init(linux_port_config_t *config);
|
||||
* switching to another console interface.
|
||||
*
|
||||
* @param config Pointer to the Linux console port configuration.
|
||||
* @return ESP_OK if the driver was successfully uninstalled, or an error otherwise.
|
||||
*/
|
||||
esp_err_t linux_vfs_dev_port_deinit(linux_port_config_t *config);
|
||||
void linux_vfs_dev_port_deinit(linux_port_config_t *config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -73,30 +73,28 @@ esp_err_t esp_stdio_install_io_driver(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_stdio_uninstall_io_driver(void)
|
||||
void esp_stdio_uninstall_io_driver(void)
|
||||
{
|
||||
#if CONFIG_VFS_SUPPORT_IO
|
||||
/* If a user primary is registered, deinit is the caller's responsibility. */
|
||||
if (esp_stdio_has_user_primary()) {
|
||||
return ESP_OK;
|
||||
return;
|
||||
}
|
||||
#endif // CONFIG_VFS_SUPPORT_IO
|
||||
|
||||
esp_err_t ret = ESP_FAIL;
|
||||
#if CONFIG_IDF_TARGET_LINUX
|
||||
linux_port_config_t config = ESP_CONSOLE_DEV_LINUX_CONFIG_DEFAULT();
|
||||
ret = linux_vfs_dev_port_deinit(&config);
|
||||
linux_vfs_dev_port_deinit(&config);
|
||||
#elif CONFIG_VFS_SUPPORT_IO
|
||||
#if CONFIG_ESP_CONSOLE_UART
|
||||
esp_console_dev_uart_config_t config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT();
|
||||
ret = uart_vfs_dev_port_deinit(&config);
|
||||
uart_vfs_dev_port_deinit(&config);
|
||||
#elif CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
|
||||
esp_console_dev_usb_serial_jtag_config_t config = ESP_CONSOLE_DEV_USB_SERIAL_JTAG_CONFIG_DEFAULT();
|
||||
ret = usb_serial_jtag_vfs_dev_port_deinit(&config);
|
||||
usb_serial_jtag_vfs_dev_port_deinit(&config);
|
||||
#elif CONFIG_ESP_CONSOLE_USB_CDC
|
||||
esp_console_dev_usb_cdc_config_t config = ESP_CONSOLE_DEV_CDC_CONFIG_DEFAULT();
|
||||
ret = cdcacm_vfs_dev_port_deinit(&config);
|
||||
cdcacm_vfs_dev_port_deinit(&config);
|
||||
#endif
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ static const esp_vfs_fs_ops_t s_vfs_console = {
|
||||
#endif
|
||||
};
|
||||
|
||||
static esp_err_t esp_stdio_register(void)
|
||||
esp_err_t esp_stdio_register(void)
|
||||
{
|
||||
_lock_init(&s_lock);
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ TEST_CASE("install/uninstall are no-ops with user primary", "[esp_stdio]")
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_stdio_push_primary(h));
|
||||
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_stdio_install_io_driver());
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_stdio_uninstall_io_driver());
|
||||
esp_stdio_uninstall_io_driver();
|
||||
TEST_ASSERT_EQUAL(0, mock_a.open_count); /* driver not initialised by install */
|
||||
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_stdio_pop_primary(NULL));
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ from pytest_embedded_idf.utils import soc_filtered_targets
|
||||
)
|
||||
def test_esp_system(dut: Dut) -> None:
|
||||
# esp32p4 32MB PSRAM initialize in startup takes more than 30 sec
|
||||
dut.run_all_single_board_cases(timeout=120)
|
||||
dut.run_all_single_board_cases(timeout=60)
|
||||
|
||||
|
||||
def esp_reset_and_wait_ready(dut: Dut) -> None:
|
||||
|
||||
@@ -49,9 +49,8 @@ esp_err_t cdcacm_vfs_dev_port_init(const esp_console_dev_usb_cdc_config_t *confi
|
||||
* another console backend.
|
||||
*
|
||||
* @param config Pointer to the USB CDC-ACM VFS device configuration.
|
||||
* @return ESP_OK if deinitialization completes successfully, or an error code if it fails.
|
||||
*/
|
||||
esp_err_t cdcacm_vfs_dev_port_deinit(const esp_console_dev_usb_cdc_config_t *config);
|
||||
void cdcacm_vfs_dev_port_deinit(const esp_console_dev_usb_cdc_config_t *config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -547,10 +547,9 @@ esp_err_t cdcacm_vfs_dev_port_init(const esp_console_dev_usb_cdc_config_t *confi
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t cdcacm_vfs_dev_port_deinit(const esp_console_dev_usb_cdc_config_t *config)
|
||||
void cdcacm_vfs_dev_port_deinit(const esp_console_dev_usb_cdc_config_t *config)
|
||||
{
|
||||
(void)config;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
CONFIG_IDF_TARGET="linux"
|
||||
CONFIG_VFS_SUPPORT_IO=y
|
||||
CONFIG_COMPILER_CXX_EXCEPTIONS=y
|
||||
CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n
|
||||
CONFIG_WL_SECTOR_SIZE=4096
|
||||
|
||||
Reference in New Issue
Block a user