An Update on Serial Number 0123456789ABCDEF

So I managed to find a satisfactory and effective resolution to my problem with serial number 0123456789ABCDEF. If you recall, the problem is that certain consumer-grade USB devices ship with non-unique serial numbers, making it difficult to use them with USB pass-through under VirtualBox.

  • Serial number on multiple devices = 0123456789ABCDEF
  • VirtualBox USB filtering (permanently mapping a device to a specific VM) relies a unique field. With diverse devices, this can be the vendor/product ID. With normal devices with unique serial numbers, the serial number can be used in the filters.
  • With identical product, vendor and serial numbers, you’re stuck with “Port,” which at least in CentOS/Rocky’s USB subsystem, is dynamically assigned when the device is plugged in to the host. Example: Plug in a device, it shows up on Bus 001, Device 005. Unplug it, plug it back in, and it’s now on Bus 001, Device 006.
  • Allegedly, udev rules can be set to assign a specific port (or a port “nickname”) using some other unique identifier, like the actual physical port the device is connected to. Still less than ideal, since that would require adherence to a strict protocol of unplugging and plugging into the same port. Anyway, I couldn’t get that to work.

So I dug around a bit, and found that the devices DO have a unique component — the device’s MAC address. It’s visible when using lsusb in verbose mode. But VirtualBox can’t see it, and it’s not an option in the VirtualBox filtering.

So what I ended up doing was abandoning VirtualBox’s USB filtering entirely.

I created a text file mapping those MAC addresses to VMs. Then I created a script which iterates through LSUSB, and checks the MAC addresses of every USB device it finds through that mapping file. When it finds one, it needs two things to make the usb attachment happen via command line. It needs either the UUID or machine name of the VM, and it needs the UUID or “address” of the USB device. My mapping file stores the MAC address of the device (discovered via lsusb) and the UUID of the VM, which is available via vboxmanage list vms.

The UUID of the USB device can be found by comparing the Bus and Port values found in lsusb to the output of vboxmanage list usbhost. With creative use of bash and awk, I was able to iterate through the devices, determine which ones are assigned to VMs, check to see if they’re currently attached, and if not, issue the vboxmanage controlvm vm-uuid usbattach usb-uuid command to attach the device to its home VM. So in case of a host reboot or someone rejiggering ports, a single command is enough to get things back where they belong.

I realize that there are probably only three people on the planet who have run into this particular problem, but I thought the solution was an interesting exercise in information-gathering on a VirtualBox host on a Rocky Linux platform, so I felt i was worth sharing.

DC540 will be at Social House in Chantilly this evening

Find us around 1830. Should be lightly attended, so if your social anxiety balks at crowds, this evening might be the night for you. We’ll be celebrating last culmination of our nine-part series on MicroPython & PCB Design with the RPi Pico, and getting ready for the next installments, which enhance your artistic toolset with regard to PCB design. I recommend the Margherita flatbread and a Space Dust. Look for the Defcon hat. Strangers are welcome.

DC540 December Giveaway

We’re eight classes in on our MicroPython & PCB Design series, and I got the urge to give some stuff away to drive more eyeballs to our content. So from now until the end of December, I’m tracking new subscribers to our YouTube channel: https://www.youtube.com/channel/UCbN6uet3koyKkKs5W8CoCxQ

Five of you will win prizes:

(1) Tarot Badge from DC30
(1) Tree of Life Badge from DC29
(3) Random DIY PCB kits from our collection

Maybe you’ll even learn something!

Tonight: MicroPython & PCB Design Class: Catching Up

What better way to spend Black Friday evening than cozying up by the fire and tuning into DC540’s catch-up class on MicroPython & PCB Design. We’ve done 7 classes so far of a planned 6-class series, and last week we started in fabrication prep. Enough people are traveling this week that we decided not to take the class forward this evening, but enough people are around that we’re going to hold “class” anyway, and dig deep in whatever direction folks want to explore.

No promises about next week. I’m having minor ear surgery next Friday morning. We’ll see how it goes.

7:30pm on Zoom.

MicroPython & PCB Design Class update

So I finally caught up with all the last few weeks of class videos, and they’re all out there on the YouTube playlist. We’re having such a great time working through this process, dealing with real-time mistakes, and just going through the grind of designing a board and getting it fabricated. It’s a group class, so it’s very conversational, and the group is comfortable together, so it occasionally gets irreverent and mildly sarcastic.

Here’s the YouTube playlist link: https://www.youtube.com/playlist?list=PLvHfoRwREM9NEh0unEx78AdT5MzEejzg7

I expect we’ll have one or two more classes before we wrap this series up. Hit us up on all the platforms if you find it useful.

Serial Number 0123456789ABCDEF is killing me.

I generally prefer to blog when I’ve solved an obscure problem, or even a not-so-obscure problem, because I’m proud of myself for doing it, and because for everyone out there who already knows the answer, there are 20 people out there who don’t, and I like to be helpful.

Not this time. I’m blogging about it this time in the hopes that explaining it in sufficient detail might trigger an a-ha moment for me, or maybe that someone out there in the ether will find it and know, and feel that same urgent need to be helpful that I frequently feel.

So I’ll be as concise as possible here:

CentOS-based server running VirtualBox.

Multiple USB devices connected to the server, intended to be passed through to individual VMs.

These particular devices caused us to settle on VirtualBox, because it was on the only virtualization platform we found that could pass them through reliably in a usable way.

So we found one that we like as far as function set and usability. We’re happily plugging along and making our VM work happily with it. OK, let’s make another one. Spin up another VM, plug in another (identical) device.

Oh noes. The vendor, product, manufacturer name, and everything are all identical! What do we do? Those of you who’ve done this before, I know what you’re about to say. “Use the serial number in the VBox USB Filter, dumbass!” To that I say, “did you read the title of this post?”

Yeah. This particular vendor rolled out this product commercially with generic, identical serial numbers. Whatever fucktard made that decision, I curse their existence.

After a bit of futzing, we found that we could filter on “Port”, which is the port number assigned to the device, visible in lsusb and in the device in. /dev/bus/usb/001/###.

So yeah, we got on with our day and forgot about it. Oh yeah — then we got another one.

“No problem,” I said, “we know how to handle that.” So we’re working through setup, and I have the filter in place, and we pull it out and put it back in for whatever reason, and the filter’s not kicking in. I look again, and the port number has incremented!

Yeah. USB port numbers in linux, at least in this distro, are dynamic. So you can’t expect them to continue to work after a server reboot, or maybe even after a device reset. Bad news.

So a colleague sends me an article on using udev rules to find the uniqueness buried in udevadm attributes to generate a named symlink to the device. That sounds awesome.

Well, less than awesome. The only uniqueness I was able to find in the attributes was “bus” and “devpath”, which are the physical USB bus and port the device is connected to. The lovely non-unique serial number is in there glaring at me triumphantly with its useless stupid face.

So I futzed around with udev rules, trying to get that symlink to come up, and haven’t figured out quite the magic words yet. Maybe because the article is based on a ttyACM device that’s directly in /dev, and my particular situation involves a device that shows up way under /dev/bus/usb/001/### instead. In any case, I see no evidence of a symlink being created anywhere in the /dev tree, and I have no way of knowing whether it would be usable in VBox USB filtering even if it did show up. So I’m calling it a night, and I’ll put fresh eyes on it tomorrow maybe.

That’s my day, how’s youres?

MicroPython and PCB Class #7 of ?

Class #7 (of a series which was originally 6), is scheduled for this coming Friday, November 18. I’d like to go through the process of ordering boards on JLCPCB (because that’s where I’ve ordered from the most).

DC540 Monday Meetup 11/14: VIRTUAL

Hop into the DC540 Discord on Monday around 1830 Eastern and join in the festivities. We had a fun in-person meeting last week with pizza and beer, and I’ve got some rearranging to do so I’m calling this week’s meetup virtual.

We’ll give an update on the ongoing MicroPython & PCB class, we’ll talk a little bit of business, maybe talk about Mastodon a bit, and hopefully get to know some new folks.

Discord invite: https://discord.gg/NHzG9F8x

DC540 this evening

I’m thinking we should meet in the backyard/basement this evening. Might be the last time in the season to enjoy a little bit of outdoor weather. I’ve refreshed the beer supply and improved the side path lighting. What say you? A little badd pizza & beer on the patio while discussing badgelife, job searches, and other relevant topics? Who’s in?