Hi,
Currently we are using the log output as main debug system on our ESP32 board.
We have some problems with it:
- Sometimes we loose bytes (not transmited ? error during the transmission to the USB Serial Dongle ? We don't really know)
- Sometimes we have some log messages that "cuts" other log messages
We see that ESP_LOGx() macros/functions call the vprintf() function.
We would like to investigate on vprintf() functions especially for the second problem.
We would like to debug in this function to know how the bytes are transmit to uart and to know if there are RTOS things during the process. (queue, semaphore, vTaskYield(), etc)
We found that the code used for this function is defined in newlib and it is provided to the espidf as a library that comes from https://github.com/espressif/newlib-esp32
We are currently debugging this problem with eclipse, GDB and QEMU. (with a substitute-path configured).
The debug works, but not as well, I think the library is not compiled with optimisation for debug because we can step into/step out but sometimes it jumps, it's not really accurate.
I don't find a lot of documentations to build newlib-esp32 on windows so i'm here to ask if someone can send me the compiled library with debugging options enabled or if you know how to build it on windows
Implementation of the printf() function
Re: Implementation of the printf() function
Hi!
I do not think the newlib cause the problems ,the macro ESP_LOGx calls the function esp_log_write, and esp_log_write calls the esp_log_writev like below:
In esp_log_write function, va_start is not reentrant, which is not recommended used in RTOS.
Could you try on your board with modifying esp_log_write function like
,or share your project? (idf version? board type?)
I do not think the newlib cause the problems ,the macro ESP_LOGx calls the function esp_log_write, and esp_log_write calls the esp_log_writev like below:
- void esp_log_write(esp_log_level_t level,
- const char *tag,
- const char *format, ...)
- {
- va_list list;
- va_start(list, format);
- esp_log_writev(level, tag, format, list);
- va_end(list);
- }
In esp_log_write function, va_start is not reentrant, which is not recommended used in RTOS.
Could you try on your board with modifying esp_log_write function like
- void esp_log_write(esp_log_level_t level,
- const char *tag,
- const char *format, ...)
- {
- va_list list;
- mutexLock();//use FreeRTOS mutex
- va_start(list, format);
- esp_log_writev(level, tag, format, list);
- va_end(list);
- mutexUnlock();//use FreeRTOS mutex
- }
-
- Posts: 9746
- Joined: Thu Nov 26, 2015 4:08 am
Re: Implementation of the printf() function
Since when is va_start not reentrant? My manuals indicates it as MT-safe.
Re: Implementation of the printf() function
I direct ESP_LOGx to UDP and that works fine. I do see some 232 corruptions from time to time though but hey that's 232.
printf() is not declared as RT safe (its pre C++11 for a start) & so you might well see RT issues!
I think you are looking quite deep. Why debug that deep when you could roll your own RT safe logger?
Guess you have to trust that the UART library is RT safe and so that's a very simple wrapper if you wanna do your own logger thing.
But actually ESP_LOGx is RT safe! (k, never checked but 2 years in n having seen plenty of other weird stuff but still each log line has been complete etc).
printf() is not declared as RT safe (its pre C++11 for a start) & so you might well see RT issues!
I think you are looking quite deep. Why debug that deep when you could roll your own RT safe logger?
Guess you have to trust that the UART library is RT safe and so that's a very simple wrapper if you wanna do your own logger thing.
But actually ESP_LOGx is RT safe! (k, never checked but 2 years in n having seen plenty of other weird stuff but still each log line has been complete etc).
& I also believe that IDF CAN should be fixed.
Who is online
Users browsing this forum: No registered users and 103 guests