guild icon
Toit
#Jag Monitor Error: unexpected EOF
Thread channel in help
crockedile
crockedile 02/10/2025 04:45 PM
I am dealing with a troublesome microcontroller. I have an ESP32 that I have flashed Jaguar too multiple times. I can flash the firmware and get the device connected to the network using wifi login credentials. When I try to monitor the jag device "jag monitor" it fails. However, a "jag scan" command shows the device set up properly. If I do "jag run" and upload a helloWorld.toit file, I am told the code runs - but there is no output.

Below is my chain of commands from start to finish. I have tried uninstalling Jaguar, restarting my computer, and reinstalling again. Please provide any tips:

'''
PS C:\Users\robert> winget install --id=Toit.Jaguar -e
Found Jaguar [Toit.Jaguar] Version 1.47.0
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/toitlang/jaguar/releases/download/v1.47.0/jag_installer_x64.exe
██████████████████████████████ 12.2 MB / 12.2 MB
Successfully verified installer hash
Starting package install...
Successfully installed
PS C:\Users\robert> jag setup

.........

Successfully setup Jaguar v1.47.0 with Toit SDK v2.0.0-alpha.174.
PS C:\Users\robert> jag flash
v COM5
Enter WiFi network (SSID): wifiUser
Enter WiFi password for 'wifiUser':
Downloading esp32 firmware from https://github.com/toitlang/envelopes/releases/download/v2.0.0-alpha.174/firmware-esp32.envelope.gz ...
9.46 MiB / 9.46 MiB [-----------------------------------------------------------------------------------]

.......

Leaving...
Hard resetting via RTS pin...
PS C:\Users\robert> jag monitor
Starting serial monitor of port 'COM5' ...

Error: unexpected EOF
PS C:\Users\robert> jag scan
Scanning ...
v third-strength (address: http://192.168.137.245:9000, 32-bit)
PS C:\Users\robert> jag run "H:\Toit\sensorTest\helloWorld.toit"
Running 'H:\Toit\sensorTest\helloWorld.toit' on 'third-strength' ...
Success: Sent 37KB code to 'third-strength'
PS C:\Users\robert>
'''
(edited)
floitsch
floitsch 02/10/2025 05:49 PM
Interesting.
If this is your only device, then having jag run succeed, almost certainly means that Jaguar correctly found your device and managed to start the program on it.
floitsch
floitsch 02/10/2025 06:02 PM
Somehow the jag monitor seems to fail...
We are using Golang's go-serial under the hood. I looked for known issues with that error message but didn't find anything.
floitsch
floitsch 02/10/2025 06:13 PM
Maybe you could try with a Toit version?
import uart main args: port-path := args[0] port := uart.HostPort port-path --baud-rate=115200 try: reader := port.in while data/ByteArray? := reader.read: if data.last == '\n': data = data[.. data.size - 1] print data.to-string-non-throwing finally: port.close

If you run this program with jag run -d host monitor.toit (assuming you saved this file as monitor.toit).
This program doesn't automatically reset the device.
floitsch
floitsch 02/10/2025 06:15 PM
I also edited one of my earlier messages to try with jag monitor -a.
crockedile
crockedile 02/10/2025 07:39 PM
I continue to get the "Unexpected EOF" error and can no longer get the esp32 to connect to the wifi network at all - thus am failing to send the monitor.toit file.

I will try my hardware on another computer tonight. Any other ideas would be appreciated.
floitsch
floitsch 02/10/2025 07:58 PM
The monitor file should be run on your desktop. The -d host means that it runs on your machine.
crockedile
crockedile 02/10/2025 08:08 PM
A this point, when I try to run "jag flash" or "jag monitor" the powershell window is defaulting to flashing and monitoring on COM1 .

ESP32 is plugged into COM5. When I do "jag flash --port "COM5" I get the following:

Flashing device over serial on port 'COM5' ...
esptool.py v4.8.1
Serial port COM5
Connecting....
Chip is ESP32-D0WD-V3 (revision v3.1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: cc:7b:5c:35:8c:34
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000d000 to 0x0000efff...
Flash will be erased from 0x00010000 to 0x00184fff...
SHA digest in image updated
Compressed 16544 bytes to 11349...
Wrote 16544 bytes (11349 compressed) at 0x00001000 in 0.3 seconds (effective 400.8 kbit/s)...
Hash of data verified.
Compressed 4096 bytes to 171...
Wrote 4096 bytes (171 compressed) at 0x00008000 in 0.0 seconds (effective 1302.7 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 31...
Wrote 8192 bytes (31 compressed) at 0x0000d000 in 0.1 seconds (effective 1050.1 kbit/s)...
Hash of data verified.
Compressed 1523952 bytes to 957355...
Wrote 1523952 bytes (957355 compressed) at 0x00010000 in 13.0 seconds (effective 935.5 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...



Further scanning or monitoring still defaults to COM1 port unless I specify. When I do, I get the error:

Error: unexpected EOF
floitschfloitsch
The monitor file should be run on your desktop. The -d host means that it runs on your machine.
crockedile
crockedile 02/10/2025 08:14 PM
Here is what that returns:

PS C:\Users\robert.crockett> jag run -d host H:\Toit\sensorTest\monitor.toit
EXCEPTION error.
OUT_OFBOUNDS
0: SmallArray
.[] <sdk>\core\collections.toit:946:5
1: main H:\Toit\sensorTest\monitor.toit:4:20
floitsch
floitsch 02/10/2025 08:37 PM
You need to run the monitor program with the port as argument. Like "COM5".
floitsch
floitsch 02/10/2025 08:38 PM
Also, try to reset the board by hand after flashing. (Either by pressing the reset button or by unplugging it).
crockedile
crockedile 02/10/2025 10:00 PM
Attempted those fixes. Also attempted on a second computer (mac) with the following error when trying to flash:

A fatal error occurred: Unable to verify flash chip connection (Serial data stream stopped: Possible serial noise or corruption.).
Error: exit status 1
robertcrockett@MacBookAir ~ % jag flash
Enter WiFi network (SSID): TMOBILE-DA88
Enter WiFi password for 'TMOBILE-DA88':
Flashing device over serial on port '/dev/cu.usbserial-110' ...
esptool.py v4.8.1
Serial port /dev/cu.usbserial-110
Connecting....
Chip is ESP32-D0WD-V3 (revision v3.1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: cc:7b:5c:35:8c:34
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.

A fatal error occurred: Unable to verify flash chip connection (Invalid head of packet (0xE0): Possible serial noise or corruption.).

I have tried wiping this board with ESPTool as well and the results are the same. I will try a different board tomorrow and see if this board is just messed up - might need a better way to reset it completely. Unsure.
floitsch
floitsch 02/10/2025 10:01 PM
If you haven't tried yet: use a different USB cable. They are known to be the source of lots of troubles
crockedile
crockedile 02/10/2025 10:03 PM
yeah, I've been bouncing between a few :😅: will update tomorrow.
crockedile
crockedile 02/11/2025 12:51 PM
UPDATE:
Back at the office. Running into the same issue on another ESP32. Used ESPtool to wipe both of them.

At this point, I start to flash the device and it asks for wifi info. It connects to the wifi and then fails to finish flashing:

C:\Users\robert.crockett>jag flash
Enter WiFi network (SSID): test
Enter WiFi password for 'test':
Flashing device over serial on port 'COM3' ...
esptool.py v4.8.1
Serial port COM3
Connecting......................................
A fatal error occurred: Failed to connect to ESP32: No serial data received.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
Error: exit status 1
Troubleshooting - ESP32 - — esptool.py latest documentation
(edited)
floitsch
floitsch 02/11/2025 02:18 PM
Is the serial port the correct one?
Toit uses the esptool underneath. If you can wipe with it, then you should also be able to flash with it.

Maybe try to press the boot button while powering on the device.

Note: Jaguar takes the wifi credentials but shouldn't connect yet
crockedile
crockedile 02/11/2025 04:59 PM
Got it working on a different windows laptop with no problem.

The only remaining issue is on my Desktop with the inability to monitor the serial connection. Monitoring works fine on laptop with the same usb cord.
floitsch
floitsch 02/11/2025 05:27 PM
Weird. Does the toit program encounter the same issue?
bmentink
bmentink 02/12/2025 12:00 AM
I find if I have these issues, dropping the baudrate to 600000 does the trick ..
floitsch
floitsch 02/12/2025 10:51 AM
I could create an envelope that runs with the lower baudrate.
floitsch
floitsch 02/12/2025 10:53 AM
Also, if you haven't tried yet, install the latest CP210x driver. (Assuming that's the one on your board): https://www.silabs.com/developer-tools/usb-to-uart-bridge-vcp-drivers
The CP210x USB to UART Bridge Virtual COM Port (VCP) drivers are required for device operation as a Virtual COM Port to facilitate host communication with CP210x products. These devices can also interface to a host using the direct access driver.
floitsch
floitsch 02/12/2025 11:07 AM
I uploaded an envelope 'esp32-slow-uart' to the 174 release.
You can use it with jag flash esp32-slow-uart (or jag firmware update esp32-slow-uart to update).
You then need to run monitor with jag monitor --baud 57600.
crockedile
crockedile 02/13/2025 09:21 PM
thank you I will try that from the desktop tomorrow and report back. I appreciate your diligence.
👍1
crockedile
crockedile 03/10/2025 02:27 PM
this worked. The lower baud rate was needed.
👍1
crockedileOPcrockedile
this worked. The lower baud rate was needed.
floitsch
floitsch 03/10/2025 02:40 PM
In that case I will upload a version for 175 as well.
crockedile
crockedile 03/10/2025 02:44 PM
to be honest, I am not sure if it is needed. I think I overcome the same issue by simply flashing with a lower baud rate. my fault.

If ommiting this change from 175 would make toit less bloated, I dont see a reason to keep it.
(edited)
floitsch
floitsch 03/10/2025 02:52 PM
great. Thanks.
27 messages in total