For usb_serial_jtag REPL only, xTaskCreate was passing a pointer to
esp_console_repl_com_t, while esp_console_repl_task was expecting
a pointer to esp_console_repl_universal_t.
The way the two structures are defined, this makes no difference, and
the pointer values are the same. Still, this could potentially break
in the future.
(I am not sure what is the distinction between repl_com (common?) and
repl_universal; it seems that `int uart_channel` could just as well
be part of esp_console_repl_com_t; alternatively, as suggested in the
previous commit, this structure could contain a callback function
pointer, which would allow `esp_console_new_repl_*` functions to
specify how stdin/stdout should be initialized by the REPL task.)
The crash occurred when calling setvbuf(stdin,...) with stdin==NULL.
This happened because esp_console_repl_task started running before
its args->uart_channel was initialized; then esp_console_repl_task
went into the code path 'uart_channel != CONFIG_ESP_CONSOLE_UART_NUM',
and tried to 'fopen("/dev/uart/0");`
Since the UART VFS is not registered when ESP_CONSOLE_USB_SERIAL_JTAG
option is enabled, fopen failed and 'stdin' was NULL.
Fix by moving the initialization of repl task arguments before the
start of the task, same as it is done for the usb_cdcacm case.
The crash started happening after the commit 287ab7566b. I haven’t
verified this, but I guess the reason why it wasn’t happening before
was that xTaskCreate was not correctly yielding to the newly created
higher-priority 'repl' task, therefore the code which was setting
the repl task arguments after xTaskCreate had time to execute.
It should be noted that the 'uart_channel' argument is a bit hacky,
in the first place. The code should be refactored to pass a callback
function to the repl task, and let this callback initialize stdin and
stdout based on the chosen console channel. Then esp_console_repl_task
does not require assumptions about the specific interface used.
Closes https://github.com/espressif/esp-idf/issues/9662
Console sets UART clock source to REF_TICK on ESP32 and ESP32S2 by
default, however, APB clock frequency does not change when power
management is disabled. Using APB clock source allows higher baud rates
for UART console.
Closes https://github.com/espressif/esp-idf/pull/8572
Console example doesn't duplicate code in `console` component.
Linenoise has been improved: it now has a parametrized command line
length. It is now possible to paste data efficiently to the console.
Note: this can only be done if the cursor is at the end of the line.
Closes https://github.com/espressif/esp-idf/issues/7057