LinkStation playing music!
Inspired by this page on NAS-Central, I ordered a USB sound card on TaoBao (15 RMB including delivery!) and plugged it into my LinkStation. A quick dmesg showed that the device was detected, but not recognized.
The NAS-Central page mentions that some kernel modules are needed to get USB audio to work, but of course, the device does not have these modules by default. After googling for a few hours I still could not find any precompiled modules that matched my LinkStation’s kernel version, 2.6.22. I decided to jump in and try to compile the modules myself.
So how do you compile kernel modules?
Well, first of all you’ll need the correct kernel sources, but that’s easy: Buffalo provides them. Download the linux-* package that matches your NAS.
Now you need a compiler. Turns out Buffalo uses CodeSourcery so we best stick to that as well. Get the pre-compiled cross-compilation toolchain here. Select “ARM GNU/linux” and the operating system that you will use for building. No need to download the toolchain source.
Before we can compile the modules we need a kernel configuration file. Some Buffalo source packages seem to include it (the file is called .config and is hidden because of the leading dot) but the one I downloaded did not include one. Copy this file into the root of the folder where you’ve extracted the Buffalo sources. This .config file most likely has all support for audio disabled so we’ll enable it by adding CONFIG_SND=m (or check whether there’s a CONFIG_SND present and change that to =m). The ‘m’ tells the make file to build it as a separately loadable module, instead of building it into the kernel. (Since I didn’t want to change the stock kernel, I had to build loadable modules instead.)
Now the good part starts: make modules
The make file should notice the new CONFIG_SND directive and ask you about the specific sound related modules. Make sure you answer ‘m’ to all of ‘em. You don’t need them all, but figuring which you need/don’t need is too much work.
When make is done we need to ‘install’ the modules, but not in our host/build system of course! Use the INSTALL_MOD_PATH directive to copy the built modules into a separate folder: make modules_install INSTALL_MOD_PATH=/tmp/MyModules
When done, copy all the files from /tmp/MyModules/lib/modules/126.96.36.199ownkernel/kernel/sound (recursive) to your NAS. Now comes another the tricky part: loading the needed modules. The module you need is snd-usb-audio and snd-pcm-oss, but before this one will need you’ll have to load a couple of others. The normal way this is done is to move the modules into the NAS’s kernel folder and issue a depmod -a to update the module dependecies and a modprobe snd-usb-audio to load the module with its dependencies. I did it the wrong way: using insmod to load each module by hand, and trying to figure out the order in which to load them by trial-and-error. Eventually, insmod snd-usb-audio.ko loaded without complaints.
Last step: create the device nodes. As per the NAS-Central page:
I am now able to stream music using mpg123, madplay, mpd (all installable using ipkg.)
The sound quality of that 15 RMB sound card sucks though
Here’s the final .config file I used to build the sound modules.