with 2 a-stars i am unable to distingush between them, so i only see one of them.
normally i use the serial number to do this; with multiple uno’s it’s 3 udev rules.
system is debian jessie on a i5 laptop.
.
one bad way as they’re only for me would be to play with the usb vendor / product id’s
these appear in the boot loader.
.
so how would one add a serial number to an a-star?
.
stephen

The ATmega32U4 has a set of 32 read-only signature bytes and 10 of those bytes actually contain a serial number, though it isn’t documented in the datasheet. If you want to see the serial number on your A-Star (or an Arduino Leonardo or any other board with an ATmega32U4), you can run this sketch:

It would probably be sufficient for you to just make the sketch report this serial number to the computer as a standard USB serial number, without modifying the bootloader. That would allow you to assign different serial port names to each board when it is running the sketch, using udev rules (for Linux) or by changing the COM port in the Device Manager (for Windows).

The USB code that gets loaded in your Arduino sketches is stored in the Arduino IDE and you can modify its source code to add support for the serial number. Here is a patch showing the changes you could make to the Arduino IDE verison 1.5.8 to enable serial number support:

i’m trying to do this at astar connection, not from within a sketch.
when i plug them both in, they are distingushed by the bus/device they
appear as, but i only get a single device.
the serial number needs to be in the usb packet sent from the device in the
handshake resulting from the ‘insertion’.
.
as i said i normally use a udev rule to distingush between each uno etc…
so i normally see in /dev something like:-

where/what do i change to add the ATTR{serial}, i did look in the Project directories with a grep.
got the feeling it’s not trivial.
.
i’m still using /dev/ttyACMn in the port selection drop down.
unplugging one & then plugging it in again gives it incrementing port
number syndrome, which is a pain.
must be a way in udev rules to cater for that.
.
stephen

When you plug the A-Star 32U4 into USB, it is usually running a sketch instead of the bootloader. It would only be running the bootloader if the sketch had been erased, and there is no option to do that in the Arduino IDE so it is not a common state. Therefore, if you follow my instructions above to modify the sketch to have a serial number, it should allow you to distinguish different A-Stars using udev rules like the ones you posted.

What do you mean by “they are distingushed by the bus/device they appear as, but i only get a single device”? Each A-Star really should get its own /dev/ttyACMn device when you plug it in, regardless of whether it has a serial number or not, and regardless of whether it is running the bootloader or the sketch. What happens when you plug in two A-Stars and run ls /dev/ttyACM* in a shell? What messages about the A-Stars do you see in the output of dmesg?

i agree they both run a sketch after the bootloader times out, but i shouldn’t need to run a
sketch to get the 32u4’s id codes to distingush each.
my assorted serial interfaces and uno’s all have their own serial numbers.

i’d also like to know how/what i could use the USB HID interfaces they appear to have

I think the udev rule you posted just adds a symlink named A_STAR (without a number) and I don’t know how to automatically add numbers to it.

i agree they both run a sketch after the bootloader times out

The A-Star should be running the sketch immediately after you power them on; you should not have to wait for the bootloader to time out (which takes 8 seconds). Are you sure you have to wait for the bootloader to time out? How long do you have to wait and what does lsusb say during that time?

The USB product ID for the A-Star 32U4 sketch is 0x2300 and the product ID for the bootloader is 0x0101, so your lsusb output shows that the devices are running the sketch. If you follow my instructions above to add serial number support to the sketch, then those devices will have serial numbers that you can use to distinguish them. If you added serial number support to the bootloader, the serial number wouldn’t be usable until the board is in bootloader mode.

Having serial number support in the bootloader will probably not help you much, because the Arduino IDE does not really use the name of the serial port in order to find the correct serial port for the bootloader. After telling the A-Star sketch to restart and go into bootloader mode, the IDE just waits until any new serial port appears, and then the IDE connects to that port, regardless of its name, assuming that the port will be from the bootloader.