I'm reading data from UART 1, doing some processing on it, then logging the result to console which is on the default UART 0. The program is extremely unstable when I'm printing to console using either printf() or ESP_LOGI(), but is completely stable when these lines are commented out. The error I get back is "Guru Meditation Error of type LoadProhibited occurred on core 1. Exception was unhandled.", here's what the backtrace usually looks like:
Code: Select all
0x400843de: xQueueTakeMutexRecursive at /Users/frost/esp/esp-idf/components/freertos/./queue.c:2034
0x400826dd: lock_acquire_generic at /Users/frost/esp/esp-idf/components/newlib/./locks.c:155
0x400827c5: _lock_acquire_recursive at /Users/frost/esp/esp-idf/components/newlib/./locks.c:169
0x400eac1a: _vfprintf_r at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vfprintf.c:860 (discriminator 2)
0x400e4975: printf at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/printf.c:58
Code: Select all
unsigned char buff[BUF_SIZE];
while (1) {
int size = uart_read_bytes(GPS_UART, buff, BUF_SIZE, 1000 / portTICK_RATE_MS);
if (size > 0) {
...
for (int i = 0; i < size; i = i + 1) {
if (buff[i] == (int)'$') {
if (buff[i + 4] == (int)'G') {
char GPGGA[120];
i = i + 7;
for (int j = 0; j < size; j = j + 1) {
if (buff[i + j] == (int)'\n') {
j = size;
} else {
GPGGA[j] = (char)buff[i + j];
}
}
printf("here's the GPGGA %s\n", GPGGA);
// ESP_LOGI("gps", "here's the GPGGA %s\n", GPGGA);
}
}
}
Many thanks.