Skip to content

Conversation

@jessebraham
Copy link
Member

@jessebraham jessebraham commented Jan 17, 2022

Thanks to @JurajSadel for his work on this!

As stated in the title, this adds support for flashing via the ESP32-C3's USB Serial JTAG peripheral. This required performing a small refactor for get_serial_port to instead return a SerialPortInfo struct, as we needed access to the PID later on.

Has been tested on macOS x86_64 successfully. I will test it on Windows later today, and I believe @MabezDev will be able to test on an M1 Mac.

Closes #93.

@MabezDev
Copy link
Member

Hmm this isn't working for me anymore on linux (Mac M1 won't work until we fix the serial library), but the original branch still works for me via the usb jtag serial?

Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take that back actually, it does work! However sometimes it seems it can get into a state where no matter how many retries it won't work until its power cycled 🤔. Possibly this is a quirk of the hardware peripheral, maybe we can test with esptool.py.

For now, this is definitely an improvement, so lets get it landed and figure out the quirks later on.

@jessebraham
Copy link
Member Author

Thanks for taking a look! I did have that happen once right when I started testing, but it did not happen again so I chalked it up to PEBKAC. I will take a second look at it today and compare with esptool.py so see if we're missing anything.

@bjoernQ
Copy link
Contributor

bjoernQ commented Jan 21, 2022

I tried it on Windows (Windows 11) with mixed results. Seems I had tinkered around with Zadig before and I had to revert to the original drivers first.

After attaching the USB cable, it (always?) gets stuck like this

Serial port: com3
Connecting...

test
Reset done

When I do a board-info first it often is able to do the flashing. It doesn't reset the target however after flashing so I need to manually push the reset button on the dev-board.

After one or more successful flash attempts it ends up in the Reset done - hanging like above (there should be a ctrl-c handler since there is no way to get out of that other than pulling the USB cable currently)

@jessebraham
Copy link
Member Author

jessebraham commented Jan 21, 2022

Thanks for testing it out. Very strange indeed. I guess this will require some more digging!

Just as another data point, I wasn't even able to get my Windows 10 machine to connect using this method, however now that you mentioned Zadig I realize I may have the incorrect driver installed...

@jessebraham jessebraham marked this pull request as draft January 21, 2022 17:58
@JurajSadel
Copy link
Contributor

It looks like it has different behavior on different machines. I was able to flash on Windows 10 with pretty high success even after repeating flashing ~10 times. However, I encountered the same behavior @bjoernQ described with monitor. The board was hung in download mode until I manually pressed the reset button and I couldn't get out of that download mode by changing states with write_request_to_send()- it doesn't change the voltage level on the physical pin for me.

JurajSadel and others added 3 commits January 26, 2022 08:35
add binary for tests

add test message to debug

test: test reset sequence for USB-serial-JTAG C3

Add USB-serial-JTAG support

add test message to debug

test: test reset sequence for USB-serial-JTAG C3
@jessebraham jessebraham force-pushed the feature/usb-serial-jtag branch from 05a5353 to 6f88f36 Compare January 26, 2022 16:36
Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write_request_to_send()- it doesn't change the voltage level on the physical pin for me.

Seems this is an issue with serial-port-rs on windows (similar behavior already reported in #74)? Works well on x86 linux & mac.

Overall, I think this is probably good to go, the issues seem to be independent to this PR.

@jessebraham
Copy link
Member Author

Yeah, I generally agree with that assessment. It seems to be working most of the time as-is from what I can tell, which is a good start at the very least. I'm only really running macOS these days, so makes sense that I wouldn't see the same behaviour described above.

@jessebraham jessebraham marked this pull request as ready for review January 27, 2022 16:20
@jessebraham jessebraham merged commit ddea266 into esp-rs:master Jan 27, 2022
@jessebraham jessebraham deleted the feature/usb-serial-jtag branch January 27, 2022 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

builtin serial/jtag - unable to flash via serial

4 participants