esp-idf: UART READ BYTES ERROR (IDFGH-1839)
-
Development Kit: [ESP32-DevKitC]
-
Kit version (DevKitC): [v1]
-
Module or chip used: [ESP32-WROOM-32D]
-
IDF version (run
git describe --tags
to find it): v4.1-dev-58-g02c7c3885 -
Build System: [Make|CMake]
-
Compiler version (run
xtensa-esp32-elf-gcc --version
to find it): 8.2.0 -
Operating System: [ LINUX]
-
Power Supply: [USB]
Problem Description
I had used UART_NUM_2 event type on esp32 before for reading data of less than 250 bytes and works fine. But there is a problem in getting exact data of more than 330 bytes and the board started rebooting again and again after reading data.
Expected Behavior
All the data should be copied and the board should not reboot.
Actual Behavior
Problem in getting exact data of more than 330 bytes and the board started rebooting again and again after reading data.
Steps to reproduce
- build 2.flash
// It helps if you attach a picture of your setup/wiring here.
Code to reproduce this issue
// the code should be wrapped in the ```cpp tag so that it will be displayed better.
#include "esp_log.h"
#definr BUF_SIZE 1024
uint8_t UART_event_data[350];
void uart_init(void)
{
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,
};
uart_param_config(UART_NUM_2, &uart_config);
uart_set_pin(UART_NUM_2, 17, 16, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(UART_NUM_2, BUF_SIZE * 3, BUF_SIZE * 3, 3072, &uart2_queue, 0);
}
static void uart_2_event_task(void *pvParameters)
{
if(DEBUG) printf("UART EVENT +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
uart_event_t event;
uint8_t UART_data[2] = {0, 0};
for(;;)
{
uart_flush(UART_NUM_2);
if(xQueueReceive(uart2_queue, (void * )&event, (portTickType)portMAX_DELAY))
{
uint8_t data = 0;
switch(event.type)
{
case UART_DATA:
uart_read_bytes(UART_NUM_2, &UART_event_data, 334, portMAX_DELAY);
if(DEBUG) printf("Received data from is ........... \n %s\n", UART_event_data);
break;
case UART_FIFO_OVF:
ESP_LOGI(TAG, "H/W fifo overflow");
uart_flush_input(UART_NUM_2);
xQueueReset(uart2_queue);
break;
case UART_BUFFER_FULL:
ESP_LOGI(TAG, "ring buffer full");
uart_flush_input(UART_NUM_2);
xQueueReset(uart2_queue);
break;
case UART_BREAK:
ESP_LOGI(TAG, "uart rx break");
break;
case UART_PARITY_ERR:
ESP_LOGI(TAG, "uart parity error");
break;
case UART_FRAME_ERR:
ESP_LOGI(TAG, "uart frame error");
break;
default :
ESP_LOGI(TAG, "Event raised: %d", event.type);
break;
}
esp_event_loop_delete(uart2_queue);
}
}
}
void app_main()
{
uart_init();
xTaskCreate(uart_2_event_task, "uart_2_event_task", 2048, NULL, 6, NULL);
}
// If your code is longer than 30 lines, GIST is preferred.
Debug Logs
Received data from QR Code is ...........
{
“user_id”:“2",
“entity_id”:“1",
“dev_id”:“1",
“key”:“eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJkYXRldGltZSI6IjIwMTktMDktMDUgMDk6NDI6NDcuNjgwMzE3IiwiZGV2X2lkIjoxLCJlbnRpdHlfaWQiOjF9.xGGpWhBESsqpxnPFflyZ7eQ6pPpXXotadaAAsPVc1Cg”,
“app_id”:“j5l1S4",
“app_time”:“05-09-2019-03-12-47"
}
/home/gohith/WorkForce/esp/esp-idf/components/freertos/queue.c:621 (xQueueTakeMutexRecursive)- assert failed!
abort() was called at PC 0x4008f06f on core 0
0x4008f06f: xQueueTakeMutexRecursive at /home/gohith/WorkForce/esp/esp-idf/components/freertos/queue.c:621 (discriminator 1)
ELF file SHA256: 5d990ea5107040cff6d53d78240913caf67dfb3296d50a590ca5941262b0d91a
Backtrace: 0x4008bf39:0x3ffd00b0 0x4008c2b1:0x3ffd00d0 0x4008f06f:0x3ffd00f0 0x4013d7d5:0x3ffd0110 0x400d5925:0x3ffd0140 0x4008e4b9:0x3ffd0170
0x4008bf39: invoke_abort at /home/gohith/WorkForce/esp/esp-idf/components/esp32/panic.c:157
0x4008c2b1: abort at /home/gohith/WorkForce/esp/esp-idf/components/esp32/panic.c:174
0x4008f06f: xQueueTakeMutexRecursive at /home/gohith/WorkForce/esp/esp-idf/components/freertos/queue.c:621 (discriminator 1)
0x4013d7d5: esp_event_loop_delete at /home/gohith/WorkForce/esp/esp-idf/components/esp_event/esp_event.c:604
0x400d5925: uart_2_event_task at /home/gohith/WorkForce/esp/Work_space/Work/build/../main/kea_beta.c:444
0x4008e4b9: vPortTaskWrapper at /home/gohith/WorkForce/esp/esp-idf/components/freertos/port.c:143
Rebooting...
ets Jun 8 2016 00:22:57
Other items if possible
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20 (8 by maintainers)
@Gohith Thanks for reporting this, we will look into it. Thanks.