mongoose-os / mos

The Mongoose OS Command Line Tool - https://mongoose-os.com/docs/mongoose-os/quickstart/setup.md
Other
45 stars 31 forks source link

Add parameter to specify BOOT and ENABLE pins on usbserial dongle #20

Open Harvie opened 5 years ago

Harvie commented 5 years ago

Hello, i have ESP32 development board, which has ENABLE (RESET) pin connected to DTR of FTDI usb serial converter. This works very well when flashing ESP32 using Arduino IDE, but does not work when using mos flash, because mos tool seems to use RTS pin of FTDI rather than DTR.

Can you please add arguments, so i can specify this? Eg. something like:

mos flash --port /dev/ttyUSB1 --pin-reset=DTR --pin-bootloader=CTS

This would be super usefull for me.

rojer commented 5 years ago

CTS is an input pin, do you mean RTS?

Harvie commented 5 years ago

CTS is an input pin, do you mean RTS?

Didn't knew that. I don't really care about bootloader pin, because i switch it manualy. But the reset pin is important for me. Still i guess other people might need to specify bootloader pin.

pohy commented 5 years ago

Hello, I encountered the same problem. Solved it by swapping DTR and RTS. It's quick and dirty: https://github.com/pohy/mos/commit/6e269733ede65109d387c8cc38c08fa75527fc94

Harvie commented 5 years ago

@pohy cool! @rojer do you think we can have commandline option for this ^^^ ?

Harvie commented 5 years ago

CTS is an input pin, do you mean RTS?

I've just realized that CTS pin of FTDI usb2serial is bidirectional. Hence my confusion. It would be great if MOS provided also support for reset using FTDI bitbang mode, it's quite common series of chips and the api is compatible across all FTDI products, so it should be easy to do.

Idealy support both like this:

--pin-reset=DTR --pin-bootloader=RTS

or

--ftdi --pin-reset=DTR --pin-bootloader=CTS

rojer commented 5 years ago

not as easy as it seems. we'd need ftdi-specific api to control it, since normally cts is input-only.

Harvie commented 5 years ago

@rojer i am fully aware of this. hence i suggested the --ftdi flag to switch between the native serial and ftdi APIs...

rojer commented 5 years ago

i mean, before committing to tis, i'd like to know how common this is. swapping dtr and rts - ok, sure. but using cts as output - why, when you have rts available?

Harvie commented 5 years ago

Because FTDI is very often sold in device called "FTDI cable", which has following pinout: image

They sell these FTDI cables everywhere. And they come in various forms, like actual cable:

image

or even PCB with same pinout as the cable:

image

(This one has additional pin header to work as arduino ISP, but unfortunately there is not RTS...)

To be honest i would be happy for dtr/rts swap, but having support for classic FTDI cable would certainly be usefull.

Currently we have hand soldered programming jigs involving pieces of wire and hot glue. It would be nice to be able to use something cheap and easily accesible.

rojer commented 5 years ago

ok, this makes sense. i think this could be done in two steps: