adding sound support

This page describes the first steps on how to add sound support to the MyBook world. The main purpose was to use the Mybook as an MP3/FLAC/… jukebox.
Note that I do not claim that this is the best way to do it, there are probably more elegant methods.

Cross compiling kernel modules using gcc 4.1

The first step to convert the Mybook to a jukebox, is to compile the kernel sound modules. As the Mybook compiles rather slowly, I choose to cross-compile on an Ubuntu Lenny system. My starting point was the nice guide on installing debian on the Mybook by Mario Pascucci.

My Mybook has a rather recent firmware. The kernel version is the following (reported by cat /proc/version):
Linux version (moc.imesxo.cisa.moc.imesxo.yoccm|ekralc#moc.imesxo.cisa.moc.imesxo.yoccm|ekralc) (gcc version 4.1.1) #1 PREEMPT Fri Jan 18 10:40:25 GMT 2008

As the gcc version used to compile the modules should match the one to compile the kernel, I could not exactly follow the steps described by Mario Pascucci. Here follows my (rather unscientific) approach to get it done.

  • First download the sources distributed by WD. (beware: 400MB download!)
  • Unpack the WD-GPL-v1.18.tar.bz2 archive
  • Mario Pascucci used the bulidroot package enclosed in this archive, as I had problems compiling gcc 4.1.1 with it, I downloaded the most recent version of buildroot from the daily snapshots page
  • Unpack the buildroot sources, run "make menuconfig" and set the following options:
    • Target architecture = arm
    • Target architecture variant = arm926t
    • Toolchain/uCLibC library version = daily snapshot
    • GCC compiler version = 4.1.2 (4.1.1 was not available but this one works fine)
    • Any other options can be set according to your requirements
  • On my ubuntu system, I have different gcc versions installed. As the default one (gcc 4.2.3) yielded errors, I used the 4.1.3 version by setting the following environment variables:
    • export HOSTCC=gcc-4.1
    • export HOSTCXX=g++-4.1
  • Now run make. Some questions will be asked on the uCLibC configuration. The default answer can be given to all of them, except when it asks whether there is a floating point unit, the answer should be No.
  • Next you will get a compile error. It can be fixed by applying a busybox patch. The problem seems to be that Large File Support (LFS) was disabled for uCLibC. The patch did not work directly on my source tree, but I could apply it manually to the file /toolchain_build_arm/gcc-4.1.2/libstdc++-v3/crossconfig.m4 on line 159.
  • Run make again, now it should build fine.
  • For the following steps, we need the just compiled toolchain binaries to be in the path. This can be done by running:
    • export PATH=$PATH:<your_buildroot_dir>/build_arm_nofpu/staging_dir/bin
  • Now we are ready to build the kernel. Go to the directory vendor/linux-kernel in the WD archive.
  • Run "make CROSS_COMPILE=arm-linux- oxnas_wd2nc_defconfig"
  • Run "make CROSS_COMPILE=arm-linux- menuconfig" and enable all desired modules (in my case, I enabled all sound-related modules)
    • If you did not configure the system for the Leon chip, you should disable it under system type/oxford semiconductor nas options/include support for LEON. Leon support is not required for compiling kernel modules. More information can be found here.
  • Run "make CROSS_COMPILE=arm-linux- modules"
  • To get a nice tree of modules, run " make CROSS_COMPILE=arm-linux- INSTALL_MOD_PATH=<some_path> modules_install"
  • Copy the resulting modules from some_path to your Mybook (e.g., to /lib/modules/ )

Loading the modules on the Mybook

My Mybook only had optware installed. Normally the modules could be copied to /lib/modules/ and then added to modules.dep by the depmod command. However, for unclear reasons the depmod command (from the optware package) yielded a strange error message. To circumvent this, the following steps can be followed:

  • Copy the relevant lines from the modules.dep file on your desktop system (typically in /lib/modules/<kernel_version>/modules.dep). This can be done by running "grep sound modules.dep » /mybook_path/lib/modules/ /modules.dep"
  • Search and replace the paths in modules.dep (typically only the kernel version number should be changed)
  • Run "modprobe snd-usb-audio". This should load all necessary modules.
  • Check whether the modules are loaded by issuing "lsmod"

Playing sound

After plugging in a USB soundcard, I checked the files in /proc/asound and everything looked fine. However, optware only include programs that use oss, not alsa. Therefore we need alsa oss emulation. This can be achieved by running "modprobe snd-pcm-oss" and "modprobe snd-mixer-oss".
After running these commands, the /proc/asound/oss/devices file should contain information on installed cards.

As there are by default no /dev/dspX files on the mybook, I created them by running "mknod dsp 14 3" and "mknod dsp1 14 19" and "mknod dsp2 14 35"

While the /proc/asound/oss/devices file contained the correct information on my system, I still could not play sound, neither by catting a file to /dev/dsp (broken pipe) or by using madplay or mpg123. I'll keep you informed if I find a solution. Any hints are welcome.


Building an MP3 jukebox using the NSLU

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License