Dear reader,
I have four Arduino Uno, each running distinct code. They do their job well, unsupervised by any other PC. However, sometimes I need to connect them to my laptop, or another PC, or a Raspberry Pi, etc. in order to update their code. The difficulty is that as soon as I connect all of them, I have no clue which one stands for COM1, COM2, COM3, etc. I'm always afraid of flashing the wrong Arduino.
My question is: Is there any way to connect via Arduino IDE, not based on COM info, but rather some unique identifier (like those numbers we get when requesting tools/Get board info)?
You could do this by changing the VID/PID of the USB chip on each Uno to a unique value. The process of doing that would depend on which USB chip your Unos have. If it's the ATmega16U2 then you would flash the firmware using either DFU over the USB connection or else using an ISP programmer connected to the ICSP header near the USB chip. FTDI has a tool you can download from their website that makes it pretty easy to change the VID/PID, though it's unlikely your Uno uses an FTDI chip. I don't know whether it's possible to change VID/PID on the CH340.
Once you change the VID/PID, the driver will no longer work so you'd also need to use a customized driver.
It's likely to be a fairly complex process to do this. You probably won't find a lot of information on doing it but the topic has come up here on the forum a few times in the past. I haven't messed with the VID/PID very much, and have never done the driver thing so I won't be able to help with any of that.
If you do manage to get unique VID/PID for each board, the Arduino IDE has a feature where you can create a board definition with that VID/PID, after which the port associated with that VID/PID will be labeled with the board name in the Tools > Port menu. You don't need to actually use that board definition. You could just create some hidden dummy boards and continue using the Tools > Board > Arduino/Genuino Uno board as always. I created a custom hardware package with dummy board definitions for all the common USB chips, which provides a good example of how to do this: