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

task watchdog in repl console task when using tinyusb console (IEC-266) #133

Open
2 tasks done
inbarab opened this issue Feb 10, 2025 · 9 comments
Open
2 tasks done
Assignees
Labels
Status: Opened Issue is new

Comments

@inbarab
Copy link

inbarab commented Feb 10, 2025

Answers checklist.

  • I have read the documentation of the component in question and the issue is not addressed there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

How do I run the esp-idf repl console over the tiny usb cdc-acm?
When running the esp-idf cli (esp_console_repl_task) based on the tusb console example, I get a task watch dog on the repl task (see stack dump below)
Board: esp32-s3 wroom 1
esp-idf 5.2.3
espressif/tinyusb 0.18.0
espressif/esp_tinyusb 1.7.1

PS C:\dev\ESP\tusb_console> xtensa-esp32s3-elf-addr2line -pfiaC -e build/tusb_console.elf 0x42014FAF:0x3FC93CB0 0x420153CC:0x3FC93CD0 0x403770E9:0x3FC93D00 0x400559DD:0x3FC9CC50 0x4037D00E:0x3FC9CC60 0x4037AE7D:0x3FC9CC80 0x4200CEA5:0x3FC9CCC0 0x4200CFBB:0x3FC9CCE0 0x4200C44F:0x3FC9CD00 0x4200B55D:0x3FC9CD20 0x4200BA1E:0x3FC9CD50 0x42006B4E:0x3FC9CD70 0x4201E8EE:0x3FC9CD90 0x420098D9:0x3FC9CDB0 0x42009CE9:0x3FC9CDE0 0x4200A014:0x3FC9CE30 0x4200A051:0x3FC9CE50 0x42008D84:0x3FC9CE70 0x4037B571:0x3FC9CEA0

0x42014faf: task_wdt_timeout_handling at C:/dev/ESP/esp-idf523/components/esp_system/task_wdt/task_wdt.c:441
0x420153cc: task_wdt_isr at C:/dev/ESP/esp-idf523/components/esp_system/task_wdt/task_wdt.c:515
0x403770e9: _xt_lowint1 at C:/dev/ESP/esp-idf523/components/xtensa/xtensa_vectors.S:1240
0x400559dd: ?? ??:0
0x4037d00e: vPortClearInterruptMaskFromISR at C:/dev/ESP/esp-idf523/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h:560
(inlined by) xTaskGetSchedulerState at C:/dev/ESP/esp-idf523/components/freertos/FreeRTOS-Kernel/tasks.c:4982
0x4037ae7d: xQueueGenericSend at C:/dev/ESP/esp-idf523/components/freertos/FreeRTOS-Kernel/queue.c:941
0x4200cea5: osal_mutex_unlock at C:/dev/ESP/tusb_console/managed_components/espressif__tinyusb/src/osal/osal_freertos.h:171
(inlined by) _ff_unlock at C:/dev/ESP/tusb_console/managed_components/espressif__tinyusb/src/common/tusb_fifo.c:48
(inlined by) _tu_fifo_write_n at C:/dev/ESP/tusb_console/managed_components/espressif__tinyusb/src/common/tusb_fifo.c:551
0x4200cfbb: tu_fifo_write_n at C:/dev/ESP/tusb_console/managed_components/espressif__tinyusb/src/common/tusb_fifo.c:863
0x4200c44f: tud_cdc_n_write at C:/dev/ESP/tusb_console/managed_components/espressif__tinyusb/src/class/cdc/cdc_device.c:178 (discriminator 4)
0x4200b55d: tud_cdc_n_write_char at C:/dev/ESP/tusb_console/managed_components/espressif__tinyusb/src/class/cdc/cdc_device.h:102
(inlined by) tinyusb_cdcacm_write_queue_char at C:/dev/ESP/tusb_console/managed_components/espressif__esp_tinyusb/tusb_cdc_acm.c:235
0x4200ba1e: tusb_write at C:/dev/ESP/tusb_console/managed_components/espressif__esp_tinyusb/vfs_tinyusb.c:127
0x42006b4e: esp_vfs_write at C:/dev/ESP/esp-idf523/components/vfs/vfs.c:482 (discriminator 4)
0x4201e8ee: write at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp-elf/src/newlib/newlib/libc/syscalls/syswrite.c:11 (discriminator 1)
0x420098d9: linenoiseInsertPastedChar at C:/dev/ESP/esp-idf523/components/console/linenoise/linenoise.c:698
0x42009ce9: linenoiseEdit at C:/dev/ESP/esp-idf523/components/console/linenoise/linenoise.c:892
0x4200a014: linenoiseRaw at C:/dev/ESP/esp-idf523/components/console/linenoise/linenoise.c:1105
0x4200a051: linenoise at C:/dev/ESP/esp-idf523/components/console/linenoise/linenoise.c:1168
0x42008d84: esp_console_repl_task at C:/dev/ESP/esp-idf523/components/console/esp_console_repl.c:530
0x4037b571: vPortTaskWrapper at C:/dev/ESP/esp-idf523/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134

@espressif-bot espressif-bot added the Status: Opened Issue is new label Feb 10, 2025
@github-actions github-actions bot changed the title task watchdog in repl console task when using tinyusb console task watchdog in repl console task when using tinyusb console (IEC-266) Feb 10, 2025
@peter-marcisovsky
Copy link
Collaborator

Hi @inbarab
Can you please check, if #128 is related to your case?

@inbarab
Copy link
Author

inbarab commented Feb 12, 2025

Hi @peter-marcisovsky,
I don't think it is. I'm not trying to use the same USB for several functions, I'm trying to get a single repl console to run over tinyUSB cdc-acm
This is a first step before creating a composite device (as suggested in #128) for cli + msc. That is the reasom I need the tinyusb cdc-acm, and can't use the rom usb.

I uploaded the changes I made to the example here:
https://github.com/inbarab/esp-idf. Specifically see commit inbarab/esp-idf@aa9b20d...cba1eeb

@peter-marcisovsky
Copy link
Collaborator

Hi @inbarab

I'm trying to get a single repl console to run over tinyUSB cdc-acm

Please do correct me if I misunderstood your solution, but this is exactly what the other user in #128 was trying to do (the only difference being, he wanted to have a Composite USB device)

This is a first step before creating a composite device (as suggested in #128) for cli + msc

Plus, your next step will be exactly the same as the other user's (creating a composite USB device)

For now, our resolution stands as in the mentioned GH Issue:

the feature you are requesting is not available right now in esp-idf

We can reconsider whether to officially support this feature and may put it into our development plans, since there are multiple users asking about this feature, but unfortunately it is not our priority right now and I can't say when an whether we will officially support it.

For now, you can build your solution upon this reply.

@inbarab
Copy link
Author

inbarab commented Feb 13, 2025

Hi @peter-marcisovsky

Perhaps I misunderstood, but I though #128's main problem was the coexistence of the debugger and tinyusb over the usb connector
In any case, I have already used this as you suggest, only to run into further problems that I am addressing with espressif support, mainly that the repl console thread blocks and triggers the task watch dog
You can reproduce this problem using the modified tusb console example from
here

Thanks
Inbar

@lijunru-hub
Copy link
Contributor

Using esp_console_new_repl_uart does indeed trigger the watchdog, as the console currently does not have good support for TinyUSB CDC-ACM.

You can:

  1. Disable the task watchdog.
  2. Use a third-party CLI. You can refer to this example:
    https://github.com/espressif/esp-iot-solution/blob/master/examples/usb/device/usb_dongle/main/data_back.c.

@inbarab
Copy link
Author

inbarab commented Mar 25, 2025

I tired the example you suggested
It doesn't work either - I'll open an issue on that example :-)
Edited to add - there is already an issue with that example, see espressif/esp-iot-solution#282
In short - the function that's supposed to write the output does not because the define in that function does not exist, and once that is solved, the Command_Parse input index is not static so the command is, in fact, deleted every time a new character is received
It also doesn't echo

https://github.com/espressif/esp-iot-solution/blob/master/examples/usb/device/usb_dongle/main/data_back.c.

Regarding the suggestion to disable the watch dog, that does not help. While the watchdog stops tripping, the output does not work (printing from another task while waiting for input does not reach the console)
Please advise

@lijunru-hub
Copy link
Contributor

@peter-marcisovsky Can we make esp_console support TinyUSB CDC ACM?

@peter-marcisovsky
Copy link
Collaborator

Hi @lijunru-hub this feature is a nice to have one, but it's not among our priorities right now. Unfortunately, I can't commit to any specific date about delivering this feature.

@inbarab
Copy link
Author

inbarab commented Mar 30, 2025

I have a suspicion: is it possible the cdc-acm driver does not feed the incoming chars to the virtual file system rx fifo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new
Projects
None yet
Development

No branches or pull requests

4 participants