Wednesday 7 August 2024

VirtualHere on piCorePlayer

This is niche...

I'm in the middle of building a DIY music streamer based around piCorePlayer on a Raspberry Pi with a HiFiBerry Digi+ Pro HAT. This will live in my main AV rack and output to my AV Processor.

I selected PiCorePlayer as I already run a Logitech Media Server (LMS) and have a few squeezebox devices, so that OS is a good fit for me.

I also have an Elgato StreamDeck that I purchased some time ago that I'd like to use in my Home Cinema. This device has a bunch of customisable buttons that I intend to configure with shortcuts for lighting, av system power etc. 

The issue I have is that the StreamDeck needs to be plugged in to a PC via USB for configuration and operation. I don't have a PC nearby, and would ideally like to manage it from a Virtual Windows machine, but that runs on my Unraid server in a different building.

It would be great to be able to use the Pi in my DIY streamer to somehow relay the StreamDeck to my VM.

I came across some VirtualHere software that appeared to do just that. This runs a 'server' on a computer that you can plug USB devices into, and a 'client; on a remote machine. The client can connect to the USB devices as if they were local. 

There is a linux/arm server for PIs available, and a Windows client. The problem is how to install it on PiCorePlayer, which is based on Tiny Core Linux (TCL), and while it supports extensions and the like, is fairly locked down, and ultimately runs in RAM with no persistent storage out of the box.

It took a while, but I finally came up with a somewhat bodged solution.....

VirtualHere has a generic Linux installer script that I tried, but it wouldn't work, complaining that systemd was needed, but this doesn't exist in PiCorePlayer. 

Inspecting the script, though, I saw that it created a 'virtualhere' directory in /usr/local/etc/ and installed the vhusbdarm 'server'

I manually downloaded the appropriate vhusbdarm file from VirtualHere, made it executable and ran it via the piCorePlayer console. When I installed the client in my Windows VM, it immediately picked up the USB devices on the Pi. Further, once I plugged my StreamDeck into the Pi, it appeared, and I could run the configuration software on the Windows VM and operate the StreamDeck attached to the Pi. Good progress.

However, as soon as I rebooted the Pi, it all disappeared as piCorePlayer reloads to memory each time.

Happily, there's a user commands section in piCorePlayer tweaks configuration that allows custom commands to run at boot.


I ended up downloading the VirtualHere Linux server file to my Unraid server and configuring piCorePlayer to run the following commands on boot;

mkdir /usr/local/etc/virtualhere;
cd  /usr/local/etc/virtualhere;
curl -O -u user:pass ftp://192.168.1.199/user/archive/piCorePlayer/vhusbdarm;
sleep 10;
chmod +x /usr/local/etc/virtualhere/vhusbdarm;
/usr/local/etc/virtualhere/vhusbdarm

In a nutshell, this creates the requisite directory, CDs into it and pulls the VirtualHere software from my Unraid via FTP. (I figured this would be faster and more reliable than downloading)

It waits a few seconds to allow the download complete, then makes the file executable and runs it.

Et Voila, VirtualHere running on piCorePlayer;


And here is StreamDeck running in windows beside the VirtualHere UI. It's possible to set specific devices to 'auto connect' , and this works very well. If I restart the Pi, the USB devices disappear, but will re-establish themselves 30 seconds or so after the Pi comes back online.


There are more elegant ways to do this, I'm sure. I could have created a new partition on my Pi SD card for persistent storage, for example. Or slaved over the inbuilt Linux USB/IP feature. But this works just fine, and as I'm using only 1 device, I can use the free version of VirtualHere.






1 comment:

Craig McLellan said...

Hi Peter!

Cool to see more raspberry pi stuff. I use them extensively in my whole house audio system as sources with my Audac 4 zone matrix (I mentioned this when emailing you.)

I use one separately with a hifiberry digital HAT as well into a Quad 99 CDP-2 optical input for my office system. They are very reliable. Logitech Media Server with Qobuz/Spotify added never fails to work, either.

Going to have to look at VirtualHere, could prove to be useful for a project coming up next year.