Skip to content
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

system/console/basic example does not work on ESP32-S3 using USB serial/jtag controller (IDFGH-8166) #9662

Closed
3 tasks done
davidzuhn opened this issue Aug 28, 2022 · 3 comments
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@davidzuhn
Copy link
Contributor

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.1-dev-437-g5c1044d84d

Operating System used.

macOS

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

No response

Development Kit.

ESP32-S3-DevKit-C v1.0

Power Supply used.

USB

What is the expected behavior?

I tried to run the system/console/basic example when configured for the USB serial/jtag controller. I expected a working command line console over the USB port. I've seen this work in previous snapshots of the ESP-IDF.

What is the actual behavior?

The board goes into a continuous loop with the following console output:

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40375af5
0x40375af5: esp_restart_noos_dig at /Users/zoo/esp32/esp-idf-latest-20220828/components/esp_system/esp_system.c:46 (discriminator 1)

SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3810,len:0x1184
load:0x403c9700,len:0xa3c
load:0x403cc700,len:0x29f0
entry 0x403c9898
I (186) cpu_start: Pro cpu up.
I (186) cpu_start: Starting app cpu, entry point is 0x40375674
0x40375674: call_start_cpu1 at /Users/zoo/esp32/esp-idf-latest-20220828/components/esp_system/port/cpu_start.c:142

I (0) cpu_start: App cpu up.
I (196) cpu_start: Pro cpu start user code
I (196) cpu_start: cpu freq: 160000000 Hz
I (197) cpu_start: Application information:
I (198) cpu_start: Project name:     console
I (198) cpu_start: App version:      v5.1-dev-437-g5c1044d84d
I (198) cpu_start: Compile time:     Aug 28 2022 13:46:47
I (199) cpu_start: ELF file SHA256:  6edb499afddc010f...
I (200) cpu_start: ESP-IDF:          v5.1-dev-437-g5c1044d84d
I (201) heap_init: Initializing. RAM available for dynamic allocation:
I (202) heap_init: At 3FCA1188 len 00048588 (289 KiB): D/IRAM
I (203) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DRAM
I (204) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (204) heap_init: At 600FE03C len 00001FC4 (7 KiB): RTCRAM
I (206) spi_flash: detected chip: generic
I (206) spi_flash: flash io: dio
W (207) spi_flash: Detected size(8192k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (209) sleep: Configure to isolate all GPIO pins in sleep state
I (210) sleep: Enable automatic switching of GPIO sleep configuration
I (210) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (255) example: Command history enabled
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x4206fcb9  PS      : 0x00060f30  A0      : 0x8200ef8e  A1      : 0x3fcecd30  
0x4206fcb9: setvbuf at /Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/xtensa-esp32s3-elf/src/newlib/newlib/libc/stdio/setvbuf.c:119

A2      : 0x00000000  A3      : 0x00000000  A4      : 0x00000002  A5      : 0x00000000  
A6      : 0x3fcecf64  A7      : 0x3c0ad120  A8      : 0x8206fcb9  A9      : 0x3fcecd10  
A10     : 0x00000000  A11     : 0x3fcecd30  A12     : 0x00000008  A13     : 0x3fcecf64  
A14     : 0x3fcecba0  A15     : 0x0000000b  SAR     : 0x00000005  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000064  LBEG    : 0x400556d5  LEND    : 0x400556e5  LCOUNT  : 0xfffffffc  


Backtrace: 0x4206fcb6:0x3fcecd30 0x4200ef8b:0x3fcecd60 0x40382231:0x3fcecd90
0x4206fcb6: setvbuf at /Users/brnomac003/.gitlab-runner/builds/qR2TxTby/0/idf/crosstool-NG/.build/xtensa-esp32s3-elf/src/newlib/newlib/libc/stdio/setvbuf.c:119

0x4200ef8b: esp_console_repl_task at /Users/zoo/esp32/esp-idf-latest-20220828/components/console/esp_console_repl.c:490

0x40382231: vPortTaskWrapper at /Users/zoo/esp32/esp-idf-latest-20220828/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:151





ELF file SHA256: 6edb499afddc010f

Rebooting...

Steps to reproduce.

  1. cd $IDF_PATH/examples/system/console/basic
  2. idf.py set-target esp32s3
  3. idf.py menuconfig Under components | ESP System Settings, I set the value for ESP_CONSOLE_UART to ESP_CONSOLE_USB_SERIAL_JTAG
  4. idf.py build flash monitor

Debug Logs.

No response

More Information.

The usb serial/jtag controller works, as my own code (which doesn't use esp_console_repl_task, but a broken out variant) is working just fine with the same version of ESP-IDF.

This is not the same as issue IDFGH-7840 (#9369), as the stack trace differs (and that bug was fixed).

Running the system/console/basic example in v5.1-dev-97-g1b51788872 works just fine, so this is a regression.

@davidzuhn davidzuhn added the Type: Bug bugs in IDF label Aug 28, 2022
@davidzuhn
Copy link
Contributor Author

davidzuhn commented Aug 28, 2022

Oh, and kudos for the new form for reporting bugs. That's nice!

@espressif-bot espressif-bot added the Status: Opened Issue is new label Aug 28, 2022
@github-actions github-actions bot changed the title system/console/basic example does not work on ESP32-S3 using USB serial/jtag controller system/console/basic example does not work on ESP32-S3 using USB serial/jtag controller (IDFGH-8166) Aug 28, 2022
@davidzuhn
Copy link
Contributor Author

Also, while this is the simplest case, many of the other examples that build on this also fail (I found this by trying to run examples/peripherals/i2c/i2c_tools).

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Aug 30, 2022
@igrr
Copy link
Member

igrr commented Aug 30, 2022

Thank you for reporting the issue! The fix is in review, and should be merged soon. I'm also attaching the patch file.
19866.patch.txt

@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: In Progress Work is in progress Status: Reviewing Issue is being reviewed Resolution: NA Issue resolution is unavailable labels Aug 30, 2022
espressif-bot pushed a commit that referenced this issue Sep 22, 2022
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 287ab75. 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 #9662
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants