Embedded Linux/Microcontroller Project


What is uClinux?


Getting started with uClinux


uClinux Ports

The Developers

E-Mail Forum

Contact us

HTTP download

Sponsor Links

ColdFire Links:








EMAIL - gerg@snapgear.com

What better use for a router than to turn it into an MP3 player!

The SnapGear (formerly Lineo and Moreton Bay) NETtel is a low cost embedded network appliance. It is designed to be a very flexible embedded engine for creating dedicated networked devices. One of its main uses is as a small network router, providing a gateway/firewall for dialup or cable/ADSL internet connections.

The really great thing about the NETtel is that it is powered by a version of Linux. The NETtel runs a uClinux/ColdFire kernel and tool set. Micro-controller Linux (uClinux) is a port of Linux to run on CPU's that do not support virtual memory.

The green circuit board in the front is a NETtel router - without its cloths on. The black/brown box and prototype board on top of it are the audio circuitry and power supply for it. The speakers are an ordinary pair of PC mains powered speakers.

The NETtel is connected to the local LAN via ethernet. I use the serial port as a console.

Turning the NETtel into an MP3 Player

The Hardware

The only additional hardware required was a Digital to Analog Converter (DAC). I chose a simple National Semiconductor DAC0800 part, they are cheap and easy to get hold of.

Interfacing to the NETtel is a bit of a trick. There is no general purpose headers to use for new hardware. So I decided to sacrifice the 8 front panel LEDs to become the 8 bit digital output for the DAC. This has the added advantage that the LEDs are driven via a latch, so no additional latch will be required.

Other than the DAC I also setup a low-pass analog filter on the DAC's output to clean up the audio. The Output can then be driven by any commonly available powered PC speakers.

To really produce smooth audio output you really want to use DMA. So I added a track from one of the ColdFire CPU's DMA request lines to the output of one of its general purpose timers. This means the DMA engine can deliver data to the DAC at any programmed frequency.

A cheap little piece of vero board, some soldering, and we have an assembled audio player board ready to go!

Software for Playing Audio

The next thing to do was write a driver for the DAC. This was pretty easy using Rob Scott's DMA based LCD driver. I added code to setup the ColdFire CPU's second internal timer (allowing the frequency to be set by an ioctl). I also added double buffering support, so that DMA buffers can be output back to back. Otherwise the audio output may have small delays between chunks of data. This driver can be found in the latest uClinux-ColdFire source code.

We are ready to play audio files. I knocked up some code to dump wav files to the DAC driver. Wav files are perfect since the data is essentially raw audio, ready to convert to analog. This allowed me to verify that the driver and hardware was all working. Playing small wav files gets boring really quickly though!

We are now ready to do MP3 decoding and play. Rob Scott came to the rescue again with a port of Stephane TAVENARD's MPEGDEC library. A simple hack of the demo program, to create real mp3play (in the source distrubution), and I now have a MP3 decoder that writes its output audio data directly to the DAC.

The last trick is to deliver files to the MP3 player on the NETtel. The NETtel has no mass storage, so can't store any mp3 files itself. The best solution is to mount a SAMBA share (using the SMB file-system), and network read the files from another system. This solution works perfectly.

Playing MP3 Files

The whole setup works great! MP3 files are played very smoothly at 44.1KHz. The sound quality is very good even though the DAC is only 8 bit.

The code is actually doing a full 2 channel (stero) decode, at 16 bits per channel. The player just discards a channel, and 8 bits of data. According to ps the MP3 player is using about 62% of the available CPU.

If you want to know more, or have any questions, drop me a line gerg@snapgear.com. SnapGear often has the MP3 playing NETtel at Linux industry trade shows. Stop by the SnapGear stand and have a look if you are ever at one!

UPDATE: A 16-Bit Stereo NETtel MP3 Player!

Rob Scott has modified a NETtel router and can now do 16-bit stereo MP3 decoding and playing. Very nice!

A few details: the rightmost big 24 pin chip is a Scenix processor, running at 45 MHz (using the coldfire xtal output), and the three middle chips are input and output synchronizers, since ColdFire doesn't like the timing produced by the Scenix and vice versa. The two smaller chips are the I2S DAC and op-amp.

The Scenix presents two ports to the ColdFire: data and control. The control port implements DAC enable, DMA go, 22K/44K Hz sample rate select, and an LED output bit. The data port accepts the audio samples. The code in the Scenix processor implements the control port, a 128 byte FIFO, and an audio I2S stream serializer. In operation, once the DAC enable bit is set, and DMA go is set, the Scenix code asserts DMA request when there is space available in the FIFO. Once data is in the FIFO, a real time clock interrupt is used to format the received data into I2S compatible format, and send it to the DAC.

Technical Specs

NETtel Router

    CPU        Motorola ColdFire 5307 CPU at 90MHz
    Memory     4MB SDRAM
               1MB FLASH
    Ethernet   10Mb (*2)
    Serial     RS-232 (*2)
    OS         uClinux/ColdFire

DAC Hardware

    DAC        DAC0800, 8bit (single channel only)
    Filter     10KHz

Copyright © 1998 - 2002 D. Jeff Dionne and Michael Durrant Copyright © 2001 - 2013 Arcturus Networks Inc.
uClinux, µClinux, uCsimm, µCsimm, uCdimm, µCdimm, Arcturus and the logos versions are Trademarks of Arcturus Networks Inc.
SnapGear and logo are Trademarks of SnapGear Inc.

Last Updated: 03-JUN-2002