guild icon
Toit
#Serial device does not appear in Linux when connecting a board with ESP32-S2 via USB
Thread channel in help
Jesse Sivonen
Jesse Sivonen 05/21/2025 11:22 AM
I cannot monitor serial messages with jag monitor of my Groundstudio Carbon S2 development board because it does not appear as serial device when connected to my Linux system via USB cable. The serial device does appear at path /dev/ttyACM0 when manually setting the chip into download mode using hardware buttons. The device stopped appearing after flashing Jaguar to the board using jag flash. To me, according to what I've read, that could hint that the firmware does not enable the serial USB device class of the board. Shouldn't Jaguar do that automatically? Any help would be appriciated, because debugging program is quite hard without any logging.
Jesse SivonenOPJesse Sivonen
I cannot monitor serial messages with jag monitor of my Groundstudio Carbon S2 development board because it does not appear as serial device when connected to my Linux system via...
floitsch
floitsch 05/21/2025 11:59 AM
I need to verify this more, but you are likely correct. The sdkconfig for the S2 does not have USB CDC enabled.
Since this is an sdkconfig, it's not just something Jaguar can enable/disable, but it requires a new envelope (which contains the '.elf' file).
I have an S2 on my desk and will see if I can make the USB connection for terminal output work.

In the meantime: do you maybe have an additional esp32 or similar board lying around? The carbon S2 exposes the TX0, so if you have a board that has a USB-uart chip on it (can even be a non-esp32 chip), then you might (ab)use that board's USB-UART chip for output.
Basically, you could then just connect GND, TX0, and disable the other board (by pulling it's EN to GND).
Jesse Sivonen
Jesse Sivonen 05/21/2025 12:14 PM
Thanks! I'll try to hijack USB-UART bridge of another board tomorrow. I don't have any other kinds of ESP32 boards except Carbon S2 currently, and I assume that they don't have the USB-UART chip, so I could try it with some older Arduino UNO or similar.(edited)
floitsch
floitsch 05/21/2025 12:18 PM
That would work.
floitsch
floitsch 05/21/2025 12:18 PM
I just compiled an S2 image with CDC support, but my Linux doesn't really like it:
[498355.059862] cdc_acm 5-2.2:1.0: ttyACM0: USB ACM device [498355.067022] usb 5-2.2: USB disconnect, device number 71 [498355.717746] usb 5-2.2: new full-speed USB device number 72 using xhci_hcd [498356.302995] usb 5-2.2: device descriptor read/64, error -32 [498374.320576] usb 5-2.2: unable to read config index 0 descriptor/all [498374.320594] usb 5-2.2: can't read configurations, error -110 [498374.408770] usb 5-2.2: new full-speed USB device number 73 using xhci_hcd
and similar errors.
floitsch
floitsch 05/21/2025 12:19 PM
Not completely sure, if that's my machine, the specific s2 board, or a problem with the envelope.
Jesse Sivonen
Jesse Sivonen 05/21/2025 12:28 PM
Hmm... So it first connects correctly (line 1), then disconnects for some reason (line 2) and tries to reconnect (line 3) but the board doesn't respond (correctly) to the "read device descriptor" request (line 4). Or something like that. I'm wondering why would it disconnect immidiately after connecting
floitsch
floitsch 05/21/2025 12:30 PM
hmm. it looks like the /dev/ttyACM0 is actually appearing after some time, but I don't see it on my WiFi network.
floitsch
floitsch 05/21/2025 12:30 PM
at least it appeared on my laptop. No luck yet on my desktop machine.
Jesse Sivonen
Jesse Sivonen 05/21/2025 12:31 PM
Have you tried some other USB port on the desktop?
floitsch
floitsch 05/21/2025 12:31 PM
I just disconnected it from my hub, and trying on a different port now.
floitsch
floitsch 05/21/2025 12:32 PM
I have the ttyACM0 again, but no output.
floitsch
floitsch 05/21/2025 12:32 PM
Could be that it's waiting for some Jaguar message (but I don't see it appearing with jag scan), or it could be stuck.
floitsch
floitsch 05/21/2025 12:34 PM
I might as well upload my envelope so you can try too.
Jesse Sivonen
Jesse Sivonen 05/21/2025 12:35 PM
What would happen if you typoed WiFi SSID, or password? Would it just get stuck like you have it currently?
floitsch
floitsch 05/21/2025 12:36 PM
yes. but I have set my wifi credentials using jag config, so I don't need to type it. So those are correct.
Jesse Sivonen
Jesse Sivonen 05/21/2025 12:36 PM
Right
Jesse Sivonen
Jesse Sivonen 05/21/2025 12:36 PM
Yea, I might have some time (maybe 20 minutes) until I have to go. So I can test it if can send the envelope
floitsch
floitsch 05/21/2025 12:40 PM
on it.
floitsch
floitsch 05/21/2025 12:41 PM
building
floitsch
floitsch 05/21/2025 12:41 PM
Toit envelopes for different configurations. Contribute to toitlang/envelopes development by creating an account on GitHub.
floitsch
floitsch 05/21/2025 12:41 PM
Once it's finished you should be able to jag flash esp32s2-cdc
๐Ÿ‘1
floitsch
floitsch 05/21/2025 12:42 PM
assuming you have a Jaguar that wants SDK alpha-180.
floitsch
floitsch 05/21/2025 12:42 PM
(run jag version to be sure).
Jesse Sivonen
Jesse Sivonen 05/21/2025 12:43 PM
I have it

Version: v1.51.0 SDK version: v2.0.0-alpha.180 Build date: 2025-05-10T05:48:25Z
๐Ÿ‘1
floitsch
floitsch 05/21/2025 12:43 PM
It's the latest version. so changes were pretty good :๐Ÿ™‚:
Jesse Sivonen
Jesse Sivonen 05/21/2025 12:46 PM
Could this explain the disconnects?
If the application enters light sleep (including automatic light sleep) or deep sleep mode, USB CDC device will disappear from the system.
https://docs.espressif.com/projects/esp-idf/en/v4.3/esp32s2/api-guides/usb-console.html#limitations (#3)
floitsch
floitsch 05/21/2025 12:46 PM
Neither of those should apply for Jaguar.
floitsch
floitsch 05/21/2025 12:47 PM
I recently added support for playing around with light-sleep (in the esp32 library), but you need an envelope that supports power management (and the default ones don't). It's also not something Jaguar does.
floitsch
floitsch 05/21/2025 12:47 PM
And Jaguar doesn't go into deep-sleep by itself.
floitsch
floitsch 05/21/2025 12:49 PM
Varinat has been built and uploaded. You should be able to use it.
floitsch
floitsch 05/21/2025 12:49 PM
If it works for you, I will add it as an automatic one to our builder.
Jesse Sivonen
Jesse Sivonen 05/21/2025 12:53 PM
kernel: usb 1-3: new full-speed USB device number 14 using xhci_hcd kernel: usb 1-3: device descriptor read/64, error -71 kernel: usb 1-3: device descriptor read/64, error -71 kernel: usb 1-3: new full-speed USB device number 15 using xhci_hcd kernel: usb 1-3: device descriptor read/64, error -71 kernel: usb 1-3: device descriptor read/64, error -71 kernel: usb usb1-port3: attempt power cycle kernel: usb 1-3: new full-speed USB device number 16 using xhci_hcd kernel: usb 1-3: device descriptor read/8, error -71 kernel: usb 1-3: device descriptor read/8, error -71 kernel: usb 1-3: new full-speed USB device number 17 using xhci_hcd kernel: usb 1-3: device descriptor read/8, error -71 kernel: usb 1-3: device descriptor read/8, error -71 kernel: usb usb1-port3: unable to enumerate USB device
Jesse Sivonen
Jesse Sivonen 05/21/2025 12:54 PM
No luck yet. But -71 is a new error?
Jesse Sivonen
Jesse Sivonen 05/21/2025 12:55 PM
The device can be found from the network using jag scan, so that also something
floitsch
floitsch 05/21/2025 12:59 PM
I have had similar errors...
floitsch
floitsch 05/21/2025 01:00 PM
The weird thing: if I just provide power (a usb cable without data), then the device seems to work and shows up on jag scan.
floitsch
floitsch 05/21/2025 01:00 PM
If I connect it to my laptop, ..., then jag doesn't even seem to run.
floitsch
floitsch 05/21/2025 01:00 PM
So it's likely crashing underneath (or so).
floitsch
floitsch 05/21/2025 01:00 PM
Hard to tell without any debugging output.
floitsch
floitsch 05/21/2025 01:04 PM
If I find the time I might try to build an esp32s2 firmware directly from the esp-idf. Without any sdkconfig changes...
See if that works.
๐Ÿ‘1
floitsch
floitsch 05/21/2025 01:58 PM
CDC works without Toit.
floitsch
floitsch 05/21/2025 01:59 PM
I have furthermore changed Jaguar so that it just prints "hello" followed by a 500ms sleep. (in a loop).
This means that it doesn't even open the network (or similar).
In addition, I tried a variant where most of Toit isn't in IRAM. That didn't change anything either.
@bitphlipphar any idea of what could be causing this?
floitsch
floitsch 05/21/2025 02:03 PM
Since this only happens with the CDC I can't look at the console output to determine if the device crashes (or what the reason is), so I might need to attach a JTAG board to it. I don't think I will have the time to do that today...
floitsch
floitsch 05/21/2025 06:12 PM
I managed to make the CDC work. However, the work-around is not really something we can deploy: if I delay the start of the Toit program (currently by 1s), then the device works without issues.
floitsch
floitsch 05/21/2025 06:14 PM
I have asked on the esp32.com forum. Not likely we will get an answer, but just in case: https://esp32.com/viewtopic.php?p=147908
Jesse Sivonen
Jesse Sivonen 05/22/2025 07:23 PM
I managed to hijack Arduino UNO's USB-UART bridge chip to monitor serial log
Jesse SivonenOPJesse Sivonen
I managed to hijack Arduino UNO's USB-UART bridge chip to monitor serial log
floitsch
floitsch 05/22/2025 08:32 PM
Nice
48 messages in total