Create Virtual USB Sticks With a Raspberry Pi Zero

Create Virtual USB Sticks With a Raspberry Pi Zero

Playing back music files from USB sticks is a common feature these days, and is built-into the infotainment system in [Folkert van Heusden]’s Opel Astra. Unfortunately such USB playback features often come with a range of limitations on things like audio codecs, and in the case of [Folkert]’s car, a 1000 file limit. This had him looking at an alternative to lugging a lot of USB sticks around to avoid the horror of hearing the same songs within a week while commuting. The solution? Make a Raspberry Pi Zero into a virtual USB mass storage device using the Mass Storage Gadget (MSG) driver in the Linux kernel.


Picking USB storage as the ideal option here comes mostly from the age of the infotainment system, which lacks Bluetooth, and the audio input jack is rather crackly. Of course, having the Raspberry Pi Zero pretend to be a storage device via the MSG driver wouldn’t solve the file limit, but to get around this two Python scripts were written: one which creates images from a folder of music files, and another which randomly picks one of the available images from the Zero’s SD card and configures the MSG driver to use it.


As for the list of future improvements, there is mounting the RPi Zero’s SD card as read-only to deal with the power-off when the car is shut down, and the creating of images requires to be run as root due to the use of loopback devices. As a Proof-of-Concept it does seem to be on the right track.


It’s not just the older infotainment ..

Support the originator by clicking the read the rest link below.