avrdudes / avrdude

AVRDUDE is a utility to program AVR microcontrollers
GNU General Public License v2.0
735 stars 136 forks source link

[bug #31779] Add support for addressing usbtinyisp with -P option #220

Closed avrs-admin closed 2 years ago

avrs-admin commented 2 years ago

Grygoriy Fuchedzhy grygoriy.fuchedzhy@gmail.com Sat 04 Dec 2010 11:25:53 AM UTC

I'm using usbtiny programmers.

Now there isn't way to specify which programmer exactly to use via avrdude if there are several usbtinyisp programmers connected to my computer.

So I decided to use -P option to specify which one to use, preserving behavior when no -P option given.

Patch against avrdude-5.10 attached.

Example of usage:

callisto ~ $ lsusb  | grep '1781:0c9f' Bus 005 Device 123: ID 1781:0c9f Multiple Vendors Bus 005 Device 122: ID 1781:0c9f Multiple Vendors callisto ~ $ avrdude -c usbtiny -p m8 -P 005:123

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9307

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

file #22122: usbtiny-port.patch file #23824: 0001-added-addressing-of-usbtiny-with-P-option.patch

This issue was migrated from https://savannah.nongnu.org/bugs/?31779

avrs-admin commented 2 years ago

Joerg Wunsch Mon 15 Aug 2011 05:53:47 PM UTC

Unfortunately, the enumeration using bus_number:device_number is very Linux-specific.  For example, under FreeBSD 8 (and above), the equivalent names for all devices on one machine would look like:

bus_name:dev_name: /dev/usb:/dev/ugen1.2 bus_name:dev_name: /dev/usb:/dev/ugen0.4 bus_name:dev_name: /dev/usb:/dev/ugen0.3 bus_name:dev_name: /dev/usb:/dev/ugen0.2 bus_name:dev_name: /dev/usb:/dev/ugen1.1 bus_name:dev_name: /dev/usb:/dev/ugen0.1

No idea how it would look like under Windows.

I'd like to see that patch tuned in a way so the bus/device numbers can be given as just "-P usb:0.4", which would then translate into /proc/bus/000/004 under Linux, /dev/ugen0.4 under FreeBSD, and whatever is needed for it under Windows.

Too bad Lady Ada didn't implement serial numbers.

avrs-admin commented 2 years ago

Joerg Wunsch Tue 16 Aug 2011 06:15:57 AM UTC

Just for the record: this is FreeBSD prior 8.x:

bus_name:dev_name: /dev/usb0:/dev/ugen0

(Only those devices on the bus which don't have a non-generic driver are displayed there, rather than the entire hierarchy.)

avrs-admin commented 2 years ago

Joerg Wunsch Tue 16 Aug 2011 10:30:42 AM UTC

I'd like to see that patch tuned in a way so the bus/device numbers can be given as just "-P usb:0.4"

Well, Windows appears to use bus:device names like

bus-0/\.\libusb0-0001--0x03eb-0x2103

Looks too complicated to derive some kind of generic name from that.

My suggestions:

. Please don't mess with the code in main.c, at least not within a patch that is supposed to only affect the usbtiny.  (A more generic per-programmer default device scheme would be welcome, but then, as a separate patch, please.)

. For consistency, please follow the -P usb convention as used by other USB-based programmers.  I.e., plain -P usb (which should be the default fot the usbtiny) means "use the first matching device found on the USB", and -P usb: means "use a specific device".  For other USB-based programmers is the (trailing part of the) serial number, for the usbtiny, the idea to use the (OS-specific) bus/device pair has some merit.

. When (at least) one -v option has been specified, make the code print out all candidate devices (i.e. everything where the VID/PID matches).  That way, the user can get a list of all candidate devices by specifying a guaranteed to be invalid string for

; the documentation mentions "-v -P usb:xxx" as an example.  The list of candidate devices that is printed then should be given in a way so the output can be copy&pasted into the commandline.  Examples could look like: Linux: avrdude: usbdev_open(): Found USBtinyISP, bus:device: 003:001 FreeBSD (recent USB subsystem): avrdude: usbdev_open(): Found USBtinyISP, bus:device: /dev/usb:/dev/ugen1.2 FreeBSD (old USB subsystem): avrdude: usbdev_open(): Found USBtinyISP, bus:device: /dev/usb0:/dev/ugen0 Windows: avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0/\\.\libusb0-0001--0x03eb-0x2103 Other systems (like Solaris) would then self-adapt to this as well (since the printed strings are exactly those as reported by libusb). I'm setting the status to "Postponed", because I don't have the resources to adapt the patch to this right now. Volunteers welcome!
avrs-admin commented 2 years ago

Joerg Wunsch Tue 16 Aug 2011 10:35:09 AM UTC

Oops, the web interface eats up some backslashes.  For reference, the Windows device names look like:

bus-0/\\.\libusb0-0001--0x03eb-0x2103

avrs-admin commented 2 years ago

Grygoriy Fuchedzhy Wed 17 Aug 2011 02:13:45 PM UTC

. Please don't mess with the code in main.c, at

least not within a patch that is supposed to only affect the usbtiny.

done

. For consistency, please follow the -P usb convention as used by other USB-based programmers. I.e., plain -P usb (which should be the default fot the usbtiny) means "use the first matching device found on the USB", and -P usb: means "use a specific device". For other USB-based programmers

is the (trailing part of the) serial number, for the usbtiny, the idea to use the (OS-specific) bus/device pair has some merit.

done. Just like it was in previous patch bus is struct usb_bus::dirname.  device is struct usb_device::filename. User always can look how they look like using -v option.

. When (at least) one -v option has been specified, make the code print out all candidate devices (i.e. everything where the VID/PID matches). That way, the user can get a list of all candidate devices by specifying a guaranteed to be invalid string for ; the documentation mentions "-v -P usb:xxx" as an example. The list of candidate devices that is printed then should be given in a way so the output can be copy&pasted into the commandline. Examples could look like:

done.

Please review and test as I can test using linux only. New patch is against avrdude-5.10 Thanks!

(file #23824)

avrs-admin commented 2 years ago

Joerg Wunsch Wed 17 Aug 2011 03:27:34 PM UTC

Thanks for the quick followup!

Documentation changes were still lacking, but I did that myself by now.

Added in r974.

avrs-admin commented 2 years ago

Grygoriy Fuchedzhy Wed 17 Aug 2011 08:59:47 PM UTC

I have one minor correction to documentation you wrote, windows example in the example section is not correct: -P usb:bus-0/\.\libusb0-0001--0x1781-0x0c9f there should be one more ":" in that string, I think something like: -P usb:bus-0:\.\libusb0-0001--0x1781-0x0c9f

However I don't know how exactly it will look like on windows.