https://toitlang.org/ logo
Serial device does not appear in Linux when connec...
# help
j
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.
f
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).
j
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.
f
That would work.
I just compiled an S2 image with CDC support, but my Linux doesn't really like it:
Copy code
[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.
Not completely sure, if that's my machine, the specific s2 board, or a problem with the envelope.
j
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
f
hmm. it looks like the /dev/ttyACM0 is actually appearing after some time, but I don't see it on my WiFi network.
at least it appeared on my laptop. No luck yet on my desktop machine.
j
Have you tried some other USB port on the desktop?
f
I just disconnected it from my hub, and trying on a different port now.
I have the ttyACM0 again, but no output.
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.
I might as well upload my envelope so you can try too.
j
What would happen if you typoed WiFi SSID, or password? Would it just get stuck like you have it currently?
f
yes. but I have set my wifi credentials using
jag config
, so I don't need to type it. So those are correct.
j
Right
Yea, I might have some time (maybe 20 minutes) until I have to go. So I can test it if can send the envelope
f
on it.
building
Once it's finished you should be able to
jag flash esp32s2-cdc
assuming you have a Jaguar that wants SDK alpha-180.
(run
jag version
to be sure).
j
I have it
Copy code
Version:         v1.51.0
SDK version:     v2.0.0-alpha.180
Build date:      2025-05-10T05:48:25Z
f
It's the latest version. so changes were pretty good 🙂
j
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)
f
Neither of those should apply for Jaguar.
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.
And Jaguar doesn't go into deep-sleep by itself.
Varinat has been built and uploaded. You should be able to use it.
If it works for you, I will add it as an automatic one to our builder.
j
Copy code
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
No luck yet. But -71 is a new error?
The device can be found from the network using
jag scan
, so that also something
f
I have had similar errors...
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
.
If I connect it to my laptop, ..., then jag doesn't even seem to run.
So it's likely crashing underneath (or so).
Hard to tell without any debugging output.
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.
CDC works without Toit.
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. @kasperl any idea of what could be causing this?
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...
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.
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
j
I managed to hijack Arduino UNO's USB-UART bridge chip to monitor serial log
f
Nice