Rename serial ports using Arduino
I am working on a project involving 3 Arduino Leonardo boards that send and receive MIDI data to and from Max MSP over USB. The issue I am struggling with now is that the three boards keep appearing in the list of available MIDI inports (using midiinfo) just as "Arduino Leonardo". That makes it hard to route them or to set the ports with a message when the patch is loaded. Although I renamed them at the Arduino level so they appear as Arduino Leonardo #1, Arduino Leonardo #2 and Arduino Leonardo #3 (see the discussion in the Arduino forum here), they still appear as "Arduino Leonardo" in Max MSP. I guess that Max is looking for the port name somewhere else, but I don't know where, or whether it is possible to rename the serial ports from within Max itself. I would appreciate any hint!
You need to either modify boards.txt file 3 times
before uploading to leonardo, or make own hardware definitions
in user lib/hardware folder.
The key is this part : (it might look a bit different, depending on IDE version used)

Original :
leonardo.build.vid=0x2341
leonardo.build.pid=0x8036
leonardo.build.usb_product="Arduino Leonardo"
change for example to :
leonardo.build.vid=0x2342
leonardo.build.pid=0x8037
leonardo.build.usb_product="Leo-Midi-1"
----------
leonardo.build.vid=0x2343
leonardo.build.pid=0x8038
leonardo.build.usb_product="Leo-Midi-2"
----------
leonardo.build.vid=0x2344
leonardo.build.pid=0x8039
leonardo.build.usb_product="Leo-Midi-3"
------------
or something similar.
As first You would quit Arduino IDE, compress original
boards.txt for backup, make first change and upload
the code to first Leonardo.
Quit Arduino , modify boards.txt again, upload etc.
------
The vendor and product IDs are not for selling, but for own use who cares.
-------------
The second option involves making own boards.txt,
copying bootloaders, descriptors etc to arduino user library path.
-------
This worked fine for me , renaming 4 leonardo boards which were used as HID
joystick .
What OS are You using ?
Maybe midi needs something more than just vendor and product ID changed.
Thank you for your suggestions! I will go through them on the weekend and let you know what happened. I am using OS 10.15.2 (Catalina).
Last time I did so was on el capitan 10.11.6
Not sure if that can work on Catalina, but an idea would be to go to audiomidi setup
utility and delete allready created leonardo midi devices.
P.S. I remember modifying also descriptors file
and USB headers, but that changed definitely
in Arduino version that runs on Catalina.
Maybe You could send me infos on midi library You used for the leonardo boards.
I could compare that to what worked here
Just managed to pack this :
Put it into Arduino user library/Hardware.
You will get 3 new boards in the menu :
Leo-Midi-1, Leo-Midi-2 and Leo-Midi-3
I've just tested it using last Arduino IDE
and Midi Library.
The boards get reported separately in MidiSetup.
I could not test it on Catalina, but on Capitan all is ok.
Happy New Year !
Thanks for compiling that. I get the following error though: "Invalid library found in /Users/marc/Documents/Arduino/libraries/Hardware: no headers files (.h) found in /Users/marc/Documents/Arduino/libraries/Hardware"
On the other hand I renamed the boards using the Audio MIDI setup utility and it looks that this is what Max was reading after all, because after modifying there the device names to be called "Leonardo 1", "Leonardo 2" and "Leonardo 3" they now appear in Max as "Leonardo 1 Arduino Leonardo", "Leonardo 2 Arduino Leonardo" and so on. I don't get why "Arduino Leonardo" keeps appearing but that isn't so terrible. Happy New Year to you too!
I don't know what is missing.
Maybe something to do with Catalina ?
I have just placed the folder avr
into users Documents/Arduino/Hardware and was able to
uplaoad using latest 1.8.10 IDE on el Captan.
One could maybe copy variants/Leonardo folder too.
Put that into avr folder.

In case that still does not work, one could
copy more stuff from IDE
P.S. the main reason for having different names
is that midi setup assigns own #1 #2 etc to indentical midi interfaces
depending on order and USB port they get plugged in, so it is not
sure what gets send to which real interface.
At least that used to be so
I followed your instructions and now it works perfectly! In my first attempt I copied the Hardware folder into Arduino/Libraries, that was the problem. Thank you so much!
Great, You can peak in Descriptors.c file to see what
has been changed, for future.
Is it just works on Apple?
I made the modification on "C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt" and did not work.
user Documents folder on mac is similar to user Documents folder on win.
just look fo the right place.
C:\Program Files (x86)\Arduino\ etc is definitely not user folder
Tks Source Audio. I found the correct path:
C:\Users\{user_name}\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3.
It works fine.