Playing audio on the NSLU2

3D Sound USB Audio Device

I'm a happy NSLU2 user since a few months now, and I'm using it for all kinds of things, e.g. as a 24/7 remote ssh server at home (using DynDNS and the ddclient Debian package), as IRC logger (screen + irssi), etc. etc.

I was considering multiple options as to where/how to install the slug (USB thumb drive, Compact Flash, disk drive, ...) but I settled with a full Debian install on an 1 GB USB thumb drive for now. I implemented some measures to maximize the life time of the USB thumb drive, maybe I'll post some info on that later...

One new thing I've been trying lately is to use the slug as an audio player.

As it doesn't come with an integrated sound card, you have to use an external USB audio device. I've got mine (see photo) from eBay for ca. 5 Euro (+ shipping) and it works out of the box with Linux 2.6.18 using the snd_usb_audio kernel module. You simply attach it via USB (the module is automatically loaded) and then attach external speakers to it. Here's an lsusb of the device:

Bus 001 Device 011: ID 1130:f211 Tenx Technology, Inc.

One problem with playing audio on the slug is the slow CPU. At 266 MHz (and without FPU!) playing audio with "normal" audio players such as mplayer or mpg321 is not possible. But there are several ways to make the slug play your favorite music. Here's a list of players I tested and a status report of whether they work at all. If yes, I listed a rough percentage of CPU load resulting from playing the music.

  • MP3:
    • mplayer, mpg321, aplay, playsound, and splay don't work.
    • $ madplay foo.mp3: 17% CPU load
  • Ogg vorbis:
    • mplayer, aplay, playsound, and ogg123 don't work.
    • $ apt-get install libvorbisidec-dev
      $ cd /usr/share/doc/libvorbisidec-dev/examples
      $ make
      $ cat foo.ogg | ./ivorbisfile_example | aplay -f cd
      

      Result: 40% CPU load

  • MOD, XM, S3M, IT, etc.:
    • $ mikmod foo.mod: 10% CPU load (even with compressed MOD files)
  • WAV:
  • FLAC:
  • SPEEX:
    • $ speexdec foo.spx: doesn't work, 100% CPU load. Any known alternatives?
  • AU:
    • $ cat foo.au > /dev/dsp: 3% CPU load (but sounds crappy)
    • $ cat foo.au > /dev/audio: 3% CPU load (sounds better)
    • $ mplayer foo.au: 5% CPU load
    • $ aplay foo.au: 5% CPU load
    • $ playsound foo.au: 5% CPU load
  • AIFF:
    • $ sox foo.aiff -t wav - | aplay: 50% CPU load (a bit stupid, but it works)
  • Streaming MP3:
    • $ mplayer http://www.example.com/foo.mp3: doesn't work, 100% CPU load.
    • $ wget http://www.example.com/foo.mp3 -O - | madplay - : 17% CPU load
  • Streaming Ogg Vorbis:
    • $ cd /usr/share/doc/libvorbisidec-dev/examples
      $ wget http://www.example.com/foo.ogg -O - | ./ivorbisfile_example | aplay -f cd
      : 40% CPU load

The SlugAsAudioPlayer page in the NSLU2-Linux wiki might have further information on this topic.

Feel free to add comments if you know of other audio types which can be played on an NSLU2.

Testing stuff with QEMU - Part 2: MenuetOS, a tiny OS written in 100% assembly language

Note: This article is part of my Testing stuff with QEMU series.

MenuetOS screenshot

From Wikipedia:

MenuetOS is an operating system with a monolithic preemptive, real-time kernel, including video drivers, all written in FASM assembly language, for 64-bit and 32-bit x86 architecture computers, by Ville Mikael Turjanmaa.

MenuetOS development has focused on fast, simple, efficient implementation. It has a graphical desktop, games, and networking abilities (TCP/IP stack), yet still fits on one 1.44MB floppy disk. It also facilitates easy, full-featured assembly language programming. This stands in marked contrast to the (as of 2007) widespread view that assembly languages are useful mainly for old and embedded systems.

Testing (the GPL'd) MenuetOS in QEMU is easy:

wget http://mesh.dl.sourceforge.net/sourceforge/menuet/M32-084.ZIP
unzip M32-084.ZIP
qemu -fda M32-084.IMG -m 384

There's also Menuet 64, written in 64-bit assembly, but that's not open source'd for some strange reason I don't understand. But you can try that one, too (the binary images, that is), using QEMU:

wget 'http://www.menuetos.be/download.php?CurrentMenuetOS'
unzip M64-059.ZIP\?3.1
qemu-system-x86_64 -fda M64-059.IMG

Measuring the energy consumption of everything you own

Voltcraft Energy Check 3000

Inspired by this post from Lars Wirzenius, I recently bought an electricity meter (or energy meter) and measured the energy consumption of everything I could find in my flat.

I did not yet perform any long-term tests, i.e. measuring the average consumption over multiple days or so, only some quick ad-hoc checks. I just recorded the number of watts the respective device used when powered on.

Here are the results:

Kitchen stuff:

  • Microwave. Off: 0 W. On: 1150 W.
    Depends on the configured "mode" of the microwave, I used the highest/hottest mode here.
  • Coffee machine. Off: 0 W. On: 884 W.
  • Mini-oven. Off: 0 W. On: 800 W.
    Depends on the configured "mode" of the mini-oven, I used the highest/hottest mode here.
  • Kettle. Off: 0 W. On: 2035 W.
    Quite a shock. I bet there are more energy-efficient ones out there, but still...
  • Toaster. Off: 0 W. On: 168 W.
  • Fridge. Off: 0 W. On: 110 W.
    This needs testing over a longer period of time. Fridges are not powered all the time.

Computer stuff:

  • Printer (Epson Stylus DX4200). Off: 0 W. Idle: 2.6 W. Printing: 10 W.
  • Laptop (Toshiba Satellite A80-117). Off: 0 W. On: 40 W. Heavy CPU load: 50 W. In powersave mode: 32 W.
  • PC (ASUS P4B266, 2 GHz). Off: 2.7 W. On: 60 W. Heavy CPU load: 92 W.
  • Computer monitor (CRT). Off: 1.7 W. On: 77 W. Pretty dark screen contents: 60 W. Text console: 50 W.
  • NSLU2. Off: 0 W. On: 3.5 W. Heavy CPU load: 3.9 W.
    This is one of the greatest pieces of hardware I ever bought, and these numbers are one reason for that!
  • External USB hard drive. Off: 0 W. On: 9.6 W. Heavy I/O load: 10.8 W.
  • DSL splitter + router. Off: 0 W. On: 1.2 W.
  • Radio. Off: 0.6 W. On: 2.1 W.
  • Shredder. Off: 0 W. On: 40-60 W.
  • External loudspeakers ("bass booster"). Off: 1.5 W. On: 3.5 W.
  • Portable mini CD player. Off: 0.4 W. On: 1.6 W.

By removing all devices which draw more than 0 watts in stand-by mode, I was able to reduce the overall (useless) energy consumption (and costs!) quite a bit.

I also replaced a bunch of 40 W and 60 W lightbulbs with energy saving lightbulbs which are equally bright, but only consume 8 W or 12 W respectively. On the long run you can save quite some amount of energy (and money) with them. They do cost a little bit more than normal lightbulbs, but save lots of electricity costs and they also last a lot longer (8000-15000 hours vs. 1000 hours according to Wikipedia).

Silent, fast, long-living USB storage devices for use as NSLU2 hard drive?

As I recently bought a NSLU2 ("slug") for 24/7 server usage and random ARM-based development (more on that later), I'm looking for a suitable storage device to use as the root filesystem for a complete Debian system.

The requirements are:

  • Large enough (>= 1 GB).
  • Silent. Hard disks are not an option (no IDE, no SATA, no USB, neither 2.5" nor 3.5")
  • Low power consumption.
  • As fast as possible.
  • USB-attached (the slug only has 2 USB connectors).
  • Should live as long as possible.

The last item is the most important.

The obvious choice is a USB memory stick, but unfortunately those are flash-based and only survive a certain number of write cycles. Thus I'm looking for something which at least survives enough write cycles to make it usable for a few years...

I do know several ways to reduce the number of writes via software, that's not what I'm currently interested in. I'd like to know which storage types will survive the longest amount of time (because of their hardware properties).

Some options:

  • USB memory stick, obviously. Usually quite slow, but there are quite fast ones (read 33 MB/s, write 22 MB/s), too. Some seem to survive 100.000 or even 1.000.000 write cycles, but that may not be enough. Are there any sticks with more possible write cycles?
  • Any other USB-attached (via external USB card-reader if necessary) silent storage type: SD, MMC, Transflash, Memory Stick, Compact Flash, whatever. Does any of those survive more write cycles?
  • Any other viable option?

Has somebody else done something like this before and can share some experiences as to which storage type is best suited for such a scenario? I suspect my slug will be mostly idle, but there might also be phases where it runs on 100% CPU and heavy disk I/O for multiple days in a row...

Syndicate content