espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.77k stars 7.31k forks source link

uart_driver_install(1550): uart rx buffer length error (IDFGH-11584) #12703

Open RJSDevel opened 11 months ago

RJSDevel commented 11 months ago

Answers checklist.

IDF version.

v5.1.1 to v5.1.2

Espressif SoC revision.

ESP32-H2

Operating System used.

Windows

How did you build your project?

Eclipse IDE

If you are using Windows, please specify command line type.

None

Development Kit.

CUSTOM

Power Supply used.

USB

What is the expected behavior?

No this error

What is the actual behavior?

UART driver error

Steps to reproduce.

define PM1006K_BUFFER_LENGTH 20

uart_config_t uart_config = { .baud_rate = 9600, .data_bits = UART_DATA_8_BITS, .parity = UART_PARITY_DISABLE, .stop_bits = UART_STOP_BITS_1, .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, };

ESP_ERROR_CHECK(uart_driver_install(uart, PM1006K_BUFFER_LENGTH, PM1006K_BUFFER_LENGTH, 10, &uart_queue, 0));
ESP_ERROR_CHECK(uart_param_config(uart, &uart_config));
ESP_ERROR_CHECK(uart_set_pin(uart, pin_tx, pin_rx, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));

Debug Logs.

E (486) uart: uart_driver_install(1550): uart rx buffer length error
ESP_ERROR_CHECK failed: esp_err_t 0xffffffff (ESP_FAIL) at 0x420077ac

More Information.

If I just commit ESP_RETURN_ON_FALSE((rx_buffer_size > SOC_UART_FIFO_LEN), ESP_FAIL, UART_TAG, "uart rx buffer length error"); ESP_RETURN_ON_FALSE((tx_buffer_size > SOC_UART_FIFO_LEN) || (tx_buffer_size == 0), ESP_FAIL, UART_TAG, "uart tx buffer length error");

then everything is Ok

songruo commented 11 months ago

Hi @RJSDevel, please check our API reference (https://docs.espressif.com/projects/esp-idf/en/latest/esp32h2/api-reference/peripherals/uart.html#_CPPv419uart_driver_install11uart_port_tiiiP13QueueHandle_ti). We specify the requirements for tx_buffer_size and rx_buffer_size input parameters. UART_HW_FIFO_LEN is 128 on ESP32H2.