scientifichackers / ampy

MicroPython Tool - Utility to interact with a MicroPython board over a serial connection.
MIT License
723 stars 157 forks source link

The reason why ampy is unreliable for a large number of boards, like ESP32CAM etc... #124

Open gitcnd opened 10 months ago

gitcnd commented 10 months ago

Many boards use the serial RTS and DTR pins to control the MCU reset and GPIO0 lines - to enable "hardware reset" and firmware uploads for your board.

For example - here's a simple, working, perl terminal-emulator for all boards which do this:

https://github.com/gitcnd/mcu_serial

Unfortunately, ampy doesn't control either of those lines, so you're at the random mercy of whatever your host device decides to do with them... and if either of those 2 are held in the wrong state, this "locks up" your MCU, preventing ampy from talking to it.

See my above perl code for examples of how to properly control those lines. I don't know enough python to work out how to do the equivalent to fix this bug...

gitcnd commented 10 months ago

update: turns out this is a python deficiency, but it can be worked-around:

https://github.com/pyserial/pyserial/issues/729

See https://github.com/micropython/micropython/commit/f27593e960ff19e2b8374606658cda66765ffbcb

gitcnd commented 10 months ago

fixed: https://github.com/scientifichackers/ampy/pull/126