Skip to content

Commit

Permalink
Merge branch 'bugfix/openthread_uart_vfs_register_v5_1' into 'release…
Browse files Browse the repository at this point in the history
…/v5.1'

fix(openthread): register uart vfs devices when they are not registered(v5.1)

See merge request espressif/esp-idf!31792
  • Loading branch information
jack0c committed Jul 4, 2024
2 parents 274a723 + 879e790 commit c6ef988
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions components/openthread/src/port/esp_openthread_uart.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -61,6 +61,16 @@ otError otPlatUartSend(const uint8_t *buf, uint16_t buf_length)

esp_err_t esp_openthread_uart_init_port(const esp_openthread_uart_config_t *config)
{
#ifndef CONFIG_ESP_CONSOLE_UART
// If UART console is used, UART vfs devices should be registered during startup.
// Otherwise we need to register them here.
DIR *uart_dir = opendir("/dev/uart");
if (!uart_dir) {
esp_vfs_dev_uart_register();
} else {
closedir(uart_dir);
}
#endif
ESP_RETURN_ON_ERROR(uart_param_config(config->port, &config->uart_config), OT_PLAT_LOG_TAG,
"uart_param_config failed");
ESP_RETURN_ON_ERROR(
Expand Down Expand Up @@ -90,7 +100,6 @@ esp_err_t esp_openthread_host_cli_usb_init(const esp_openthread_platform_config_

ret = usb_serial_jtag_driver_install((usb_serial_jtag_driver_config_t *)&config->host_config.host_usb_config);
esp_vfs_usb_serial_jtag_use_driver();
esp_vfs_dev_uart_register();
return ret;
}
#endif
Expand Down

0 comments on commit c6ef988

Please sign in to comment.