-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Serial UART Console Improvements #9964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Allow Initializing the serial UART console earlier than its default can be useful when debugging inside a port-specific // Initialize RTC
#if CIRCUITPY_RTC
common_hal_rtc_init();
#endif
// For the tick.
hardware_alarm_claim(0);
hardware_alarm_set_callback(0, _tick_callback);
// RP2 port-specific early serial initialization for psram debug.
// The RTC must already be initialized, otherwise the serial UART
// will hang.
serial_early_init();
#ifdef CIRCUITPY_PSRAM_CHIP_SELECT
setup_psram();
#endif Optional Timestamp An optional timestamp can be added to serial UART console output by setting #define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO1)
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO0)
#define CIRCUITPY_CONSOLE_UART_TIMESTAMP (1) CIRCUITPY_CONSOLE_UART_PRINTF This macro wraps an #include "supervisor/shared/serial.h"
#define CYW43_PRINTF(...) CIRCUITPY_CONSOLE_UART_PRINTF(__VA_ARGS__)
#define CYW43_VERBOSE_DEBUG (1)
#define CYW43_VDEBUG(...) CYW43_PRINTF(__VA_ARGS__) Here is a small sample with the above plus timestamps enabled:
The timestamps are wall-clock seconds.milliseconds and delta seconds.milliseconds in (). |
@dhalbert This is the first part of the serial console/RAM logging changes we chatted about a few weeks back. Please have a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding these features, which will be very handy. I had one question about naming.
Often when I am debugging, I do not use CONSOLE_UART, but instead just use mp_printf(&mp_plat_print, ...)
, so that my print's are interspersed with prints from the CircuitPython program. I think I mentioned briefly about making a DEBUG_PRINTF-style macro that printed to &mp_plat_print
. It would also be handy to do such logging with timestamps as well =, to &mp_plat_print
.
The above could all be "second part", since you mentioned this is "first part". What did you have in mind for "second part"?
The macro wraps
I'm testing the second part now:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! We had a side conversation in discord about some details. All set.
Smoke tested builds on an ESP32-C3 and Feather ESP32 V2 board |
FYI the removal of |
@tannewt Yes, I missed that case. Change |
A set of improvements to the serial UART console.
serial_early_init()
to be called earlier in port initialization.mp_print_t
device.