← index #8218PR #12200
Likely Duplicate · medium · value 1.357
QUERY · ISSUE

ESP32 Port - Using UART0

openby Tangerinoopened 2022-01-28updated 2025-01-13
enhancementport-esp32

Any particular reason the UART0 is blocked for user code?
What are the implication of using it? What are the fun errors?
This can drive the hardware design choices.
Thank you

STATIC mp_obj_t machine_uart_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
    mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);

    // get uart id
    mp_int_t uart_num = mp_obj_get_int(args[0]);
    if (uart_num < 0 || uart_num >= UART_NUM_MAX) {
        mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("UART(%d) does not exist"), uart_num);
    }

    // Attempts to use UART0 from Python has resulted in all sorts of fun errors.
    // FIXME: UART0 is disabled for now.
    if (uart_num == UART_NUM_0) {
        mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("UART(%d) is disabled (dedicated to REPL)"), uart_num);
    }
CANDIDATE · PULL REQUEST

ports/esp32: Support JTAG console, free up UART.

mergedby DvdGiessenopened 2023-08-09updated 2023-09-01
port-esp32

CONFIG_USB_OTG_SUPPORTED is automatically set by the ESP-IDF when the chip supports USB-OTG, which is the case for the ESP32-S2 and ESP32-S3.

When trying to use the JTAG console with these chips, it would not work because our USB implementation will take over control over the USB port, breaking the JTAG console in the process.

Thus, when the board is configured to use the JTAG console, we should not enable our USB console support.

Additionally, this change also frees up UART0 when an USB-based console is configured, since there's no reason to prevent (re)configuration of UART0 for other uses in that case.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied