Skip to content

Commit aa42423

Browse files
committed
Merge branch 'fix/fix_ot_uart_init_bug' into 'master'
fix(openthread): fix a bug of openthread uart init port Closes TZ-1564 See merge request espressif/esp-idf!37284
2 parents 70b474a + 76c2072 commit aa42423

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

components/openthread/src/port/esp_openthread_uart.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -66,12 +66,12 @@ esp_err_t esp_openthread_uart_init_port(const esp_openthread_uart_config_t *conf
6666
#ifndef CONFIG_ESP_CONSOLE_UART
6767
// If UART console is used, UART vfs devices should be registered during startup.
6868
// Otherwise we need to register them here.
69-
DIR *uart_dir = opendir("/dev/uart");
70-
if (!uart_dir) {
69+
char uart_path[16];
70+
snprintf(uart_path, sizeof(uart_path), "/dev/uart/%d", config->port);
71+
bool is_uart_registered = (access(uart_path, F_OK) == 0);
72+
if (!is_uart_registered) {
7173
// If UART vfs devices are registered, we will failed to open the directory
7274
uart_vfs_dev_register();
73-
} else {
74-
closedir(uart_dir);
7575
}
7676
#endif
7777
ESP_RETURN_ON_ERROR(uart_param_config(config->port, &config->uart_config), OT_PLAT_LOG_TAG,

0 commit comments

Comments
 (0)