using multiple usbasp connected to PC in the same time

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

using multiple usbasp connected to PC in the same time

Klaus Rudolph
Hi all,

I have a setup with 3 microncontrollers and want to update all of them
via script using avrdude and 3 usbasp devices each one after another.

Is there any chance to select the devices? Currently I only provide the
"-c" option to select usbasp in general but I have no idea how to select
a specific device on the USB bus.

Any idea?

Klaus

Reply | Threaded
Open this post in threaded view
|

Re: using multiple usbasp connected to PC in the same time

Joerg Wunsch
As Klaus Rudolph wrote:

> Is there any chance to select the devices?

Since the USBasp does not feature a serial number, there is no chance
based on that.

Your only option is to customize the product string descriptor in each
device, and then use multiple avrdude.conf entries (can be placed in
~/.avrduderc) for each programmer. If the config file specifies a
vendor or product string, it is matched against the device's strings.

--
Joerg Wunsch

Reply | Threaded
Open this post in threaded view
|

Re: using multiple usbasp connected to PC in the same time

Klaus
Thanks!

I have no idea how avrdude internally is searching the device, but it
looks like that it scans over all usb busses until it finds a device of
given type.

If we are able to restrict the found device type to a specific hardware
address like: pci-0000:00:14.0-usb-0:1.6:1.0 like we can do in udev
rules, we can address each one individual.

Maybe that is an idea for an improvement to have than a customized
avrdude.conf or avrduderc file which contains something like


programmer
   id    = "usbasp1";    << see 1 here
   desc  = "USBasp, http://www.fischl.de/usbasp/";
   type  = "usbasp";
   connection_type = usb;
   usbvid     = 0x16C0; # VOTI
   usbpid     = 0x05DC; # Obdev's free shared PID
   usbvendor  = "www.fischl.de";
   usbproduct = "USBasp";
   usbpath    = "pci-0000:00:14.0-usb-0:1.6:1.0"


No idea if the syntax for the path is a good idea, but that is what I
use for serial adapters which are also all have same id/serial combination.

An additional "list" command for avrdude will be very helpful here to
directly find all connected devices.

Something like

avrdude --listall -cusbasp

returns all found devices including hardware addr which makes it easy to
configure the customized config file.

Klaus


Am 14.10.20 um 15:05 schrieb Joerg Wunsch:

> As Klaus Rudolph wrote:
>
>> Is there any chance to select the devices?
>
> Since the USBasp does not feature a serial number, there is no chance
> based on that.
>
> Your only option is to customize the product string descriptor in each
> device, and then use multiple avrdude.conf entries (can be placed in
> ~/.avrduderc) for each programmer. If the config file specifies a
> vendor or product string, it is matched against the device's strings.
>

Reply | Threaded
Open this post in threaded view
|

Re: using multiple usbasp connected to PC in the same time

Klaus Rudolph
In reply to this post by Joerg Wunsch
Thanks!

I have no idea how avrdude internally is searching the device, but it
looks like that it scans over all usb busses until it finds a device of
given type.

If we are able to restrict the found device type to a specific hardware
address like: pci-0000:00:14.0-usb-0:1.6:1.0 like we can do in udev
rules, we can address each one individual.

Maybe that is an idea for an improvement to have than a customized
avrdude.conf or avrduderc file which contains something like


programmer
   id    = "usbasp1";    << see 1 here
   desc  = "USBasp, http://www.fischl.de/usbasp/";
   type  = "usbasp";
   connection_type = usb;
   usbvid     = 0x16C0; # VOTI
   usbpid     = 0x05DC; # Obdev's free shared PID
   usbvendor  = "www.fischl.de";
   usbproduct = "USBasp";
   usbpath    = "pci-0000:00:14.0-usb-0:1.6:1.0"


No idea if the syntax for the path is a good idea, but that is what I
use for serial adapters which are also all have same id/serial combination.

An additional "list" command for avrdude will be very helpful here to
directly find all connected devices.

Something like

avrdude --listall -cusbasp

returns all found devices including hardware addr which makes it easy to
configure the customized config file.

Klaus

Am 14.10.20 um 15:05 schrieb Joerg Wunsch:

> As Klaus Rudolph wrote:
>
>> Is there any chance to select the devices?
>
> Since the USBasp does not feature a serial number, there is no chance
> based on that.
>
> Your only option is to customize the product string descriptor in each
> device, and then use multiple avrdude.conf entries (can be placed in
> ~/.avrduderc) for each programmer. If the config file specifies a
> vendor or product string, it is matched against the device's strings.
>

Reply | Threaded
Open this post in threaded view
|

Re: using multiple usbasp connected to PC in the same time

Joerg Wunsch
As Klaus Rudolph wrote:

> I have no idea how avrdude internally is searching the device, but it
> looks like that it scans over all usb busses until it finds a device of
> given type.

This is the way USB works, in general.

> If we are able to restrict the found device type to a specific hardware
> address like: pci-0000:00:14.0-usb-0:1.6:1.0 like we can do in udev
> rules, we can address each one individual.

libusb abstracts the underlying OS. libusb_device is just an opaque
pointer to an implementation-defined struct; any details about how
that OS handles the hardware access is hidden, and cannot be used by
an application on top of libusb.

So, a portable application has to rely on the USB model, which means
to use serial numbers to distinguish devices. As an alternative, see
my previous proposal: the infrastructure for that is already
implemented in AVRDUDE right now.

If you were to propose USBasp could also handle serial numbers, I'm
not opposed to adding that functionality in AVRDUDE. However, it's my
understanding that USBasp's goal was merely to provide a simple
standalone ISP programmer for the casual AVR developer, so they
deliberately left out the serial number feature. (There are other
programmers around providing that.)

--
Joerg Wunsch

Reply | Threaded
Open this post in threaded view
|

Re: using multiple usbasp connected to PC in the same time

Klaus


Am 14.10.20 um 16:05 schrieb Joerg Wunsch:

> As Klaus Rudolph wrote:
>
>> I have no idea how avrdude internally is searching the device, but it
>> looks like that it scans over all usb busses until it finds a device of
>> given type.
>
> This is the way USB works, in general.
>
>> If we are able to restrict the found device type to a specific hardware
>> address like: pci-0000:00:14.0-usb-0:1.6:1.0 like we can do in udev
>> rules, we can address each one individual.
>
> libusb abstracts the underlying OS. libusb_device is just an opaque
> pointer to an implementation-defined struct; any details about how
> that OS handles the hardware access is hidden, and cannot be used by
> an application on top of libusb.

Ah, yes, you are right.

What about simply counting found devices and add an optional device
count parameter to avrdude so that a user simply can select "the third
found device of that type"?

Only a suggestion and not an expectation :-)

Thanks
  Klaus


Reply | Threaded
Open this post in threaded view
|

Re: using multiple usbasp connected to PC in the same time

Joerg Wunsch
As Klaus wrote:

> What about simply counting found devices and add an optional device
> count parameter to avrdude so that a user simply can select "the third
> found device of that type"?

Well, might be possible, but then you also need a way to run it in
order to just count (and print) each device, without any further
interaction. Otherwise, you won't know which one is what ... and,
the sequence might change frequently.

I wish USBasp offered a feature to store a serial number in EEPROM ...
could even be configured through USB, so no separate ISP programmer is
needed. But that needs a firmware addition. I have no idea how much
flash is left in the current firmware version.

The, AVRDUDE could use the standard way of matching a (possibly
partial) serial number, as in "-P usb:0815".

@Thomas Fischl, are you listening here?

--
Joerg Wunsch