Licenses

The radio application code is published under
The
BSD License . Nut/OS is derived from many sources. However, all
releated licenses are compatible with the BSD License and all Nut/OS specific
modifications are published under this license as well. Specifically no
firmware code is included, which license prohibits the further distribution of
binaries without accompanying source code. This includes the C standard library
newlib
.

Requirements

In order to run the binary package, the following items are needed:

Target hardware is Atmel's AT91SAM9260 Evaluation Kit. A quite limited version
runs on the AT91SAM7X256-EK as well.

An add-on board had been designed, which
is named Calypso and fits on both kits. It contains a TLV320AIC23B Audio Codec,
an LC Display, three push buttons and two 3.5mm audio connectors, providing
mic/line input and headphone/line output. This application will use the output
connector only.

A PC running Windows is used as the development environment. It must provide a
USB port, an additional serial comm port (RS232) will be quite helpful.

The SAM9260 MCU contains a bootloader (called SAM-BA) in internal ROM. Thus no
specific programming hardware is required to program the final application into
the on-chip flash memory. We used the SAM-BA v2.4 utility, which can be
downloaded free of charge from Atmel's
Website .

Download the binary installation
at91samir-bin-1.0.3-1.exe.
Simply run this executable to install the binaries on your Windows PC.

If you want the build the firmware from the source code, you additionally need these items:

Download the latest Nut/OS release 4.4 for the Windows environment from the
archive. In the same location you will find the Internet Radio
application source. The name of the archive is at91samir-src-1.0.3.zip.

The Nut/OS package comes with all required tools except the compiler. There are
several free distributions of the GNU Toolchain for ARM. If you are using PC
Windows, then YAGARTO
will be a good choice. This is a free distributions of the GNU Compiler for ARM,
which we also used for this document.

Using Linux
While Nut/OS is available as a source code package for Linux, we do not know
which tools are available to replace SAM-BA. A possible solution might be
provided by
SAM_I_AM
.

Memory Footprint

While the ARM9 version uses very large buffers to maintain constant streaming,
the data buffers had been significantly reduced for the ARM7 implementation.
Furthermore, the ARM7 version comes without web server interface.

AT91SAM9260

AT91SAM7X

Program Code

128 kByte

98 kByte

Data Space

1 MByte

64 kByte

SAM9260 Implementation

Hardware Installation

All connectors should be removed from the AT91SAM9260-EK Board. Plug the double
row header socket of the Calypso Board on the PIO B header of the
AT91SAM9260-EK. Make sure that all 40 pins are connected.

Trying the Binaries

For a first test we will upload the binary directly into the RAM. We will later
explain how to store the application in non-volatile flash memory.
It is assumed that you downloaded and installed
at91samir-bin-1.0.3-1.exe.

Connect the AT91SAM9260-EK to your local Ethernet, to your PC's USB port and
serial port (via the DBGU connector) and to the power supply. Also plug in a
headphone.

Start any terminal emulator (HyperTerminal or preferably
TeraTerm
, if available) and set the serial port to 115200,8,n,1, all handshakes
disabled.

When applying 5V power to the AT91SAM9260-EK Board, the back-lit LCD will go
on, but nothing will be displayed yet. You should see the following output from
the SAM-BA bootloader in the terminal emulator:

RomBOOT
>

Start the SAM-BA v2.4 utility on the PC and click on USB connection.

Click on the SDRAM Tab, select Enable SDRAM 133 MHz from the script drop
down list and press the Execute button.

Press the Browse button (the one with the folder icon) to choose a file
to send to the board.

Navigate to sub-directory firmware\sam9260 within the binary installation directory,
where the file webradio.bin should be available. After the binary file had been selected,
press the button Send File.

Finally enter

go 0x20000000

in the text area on the bottom of the SAM-BA main window. This will start the
application on the target board.

When enough MP3 data had been collected after a few seconds, you should be able
to listen to the music on the headphones. The LCD starts scrolling the station
name on the first line and the song currently played on the second line.

Don't worry if your radio fails to connect to a radio station. The next chapter
will probably help.

Network Configuration

When running out of the box, the application will query its IP configuration
from a local DHCP server, if one is available. If not, some hard coded values
are used. You can later modify them in the file webradio.c.

Changing the code requires rebuilding the application. An easier
way is available with the Nut/OS Discoverer, which is part of the
binary installation. You can start it from the Windows Start Menu at
Start -> Programs -> AT91SAM Internet Radio Binaries -> Nut/OS Discoverer

Selecting Scan from the main menu will broadcast a query for Nut/OS
nodes to the local network and the Internet Radio should respond with its IP
setting.

Double click on the entry in the Discoverer's main window. This pops up a new
window, which allows you to edit the current settings.

When updating the target board, the new settings will be stored in the serial
DataFlash, but are not immediately available. It is required to reset the
target board and start the application again. Up to now we loaded the the
binary directly into the RAM and it will be lost when pressing the reset
button.

Running SAM-BA over and over again to upload and start the application may
become boring soon. The next chapter will explain, how to permanently store the
application on your evaluation board.

Flashing the SAM9 Evaluation Board

Beside loading a binary into the SDRAM, SAM-BA also allows to store binaries in
the serial Dataflash or the NAND Flash. And, if a valid image is detected in
the serial Dataflash after reset, the ROM Bootloader will copy it to ... what?

Well, this is where things are becoming a bit complicated. Note, that the ROM
bootloader is located in the non-reprogrammable ROM of the AT91SAM9260 chip. Of
course this has to be universal and does not know anything about external RAMs,
specifically SDRAM configurations. Fortunately it knows about the two internal
4k RAM pages. They are far too small for our radio, but large enough to run a
second stage boot loader, which can be crafted for our specific RAM layout.

Thanks to Atmel France for providing two second stage boot loaders for our
Internet Radio. You may have noticed those two additional files, that are available
in the directory firmware\sam9260.

Before copying the image, these second stage boot loaders also initialize the DBGU
port, the PLLA and the SDRAM interface.

Let's start SAM-BA and on the first notebook page titled
DataFlash AT45DB/DCB execute the scripts

Enable DataFlash on CS1

Send Boot File

Use Web_Radio_dataflash_at91sam9260ek.bin as the boot file to be sent. Then
send the file webradio.bin, but do not forget to set the upload address to
0x8000. When the file has been send, press the reset button on the target board
to start the radio.

A similar procedure can be used to load the radio application from NAND Flash.
This time select the NandFlash tab and execute the scripts

Recovering
Once a boot file had been stored in any of the Flash memory chips, SAM-BA
connections are no more available. Keeping push button BP4 pressend on the
SAM9260-EK while powering up the board will remove the boot file and re-enable
SAM-BA on the next reset.

Using the Web Interface

The radio application provides a very simple web interface. Use any webbrowser
to connect to the target board, by entering http:// followed by the IP address
as a URL. The current IP address is displayed in the terminal emulater. Or you
can use the Nut/OS Discoverer, of course.

Development Software Installation

The following steps are required, if you want to build the binaries from the
source code.

Step 1: Downloading and installing YAGARTO

If not already done, download at least the YAGARTO toolchain and the YAGARTO
tools from www.yagarto.de
and install them on your Windows PC. You may also consider to install
OpenOCD
and the Eclipse IDE from the same webpage.

Step 2: Downloading and installing SAM-BA

We will use SAM-BA Version 2.4 to upload the application to the target board.
This tool is available free of charge from www.atmel.com
(select Products / AT91SAM 32-bit ARM-based Microcontrollers / Tools &
Software).

Step 3: Downloading and installing Nut/OS

For our radio we need version 4.4 or any later release, available in our
download area.

The Zip Archive at91samir-src-1.0.3.zip contains
the source code of the radio application and the MP3 decoder plus some Nut/OS
configuration files. Extract the file into the Nut/OS installation directory,
that had been created in step 2.

As you can see from the screenshot, the Helix MP3 Decoder had been added to the
Nut/OS source tree. Further two new application directories and two new build
directories had been added, one of each for the SAM7X and the other for the
SAM9260.

Nut/OS Configuration

This
Shockwave Flash Tutorial will guide you through the whole
procedure of creating the Nut/OS libraries for our radio. It is a good idea to
start the Nut/OS Configurator from the Windows Start Menu now and follow the
demo step by step.

More details about configuring and building Nut/OS for the SAM9260 are
explained in the document Nut/OS on
the AT91SAM9260 EK. When following the instruction on this page,
make sure the use ethernut-4.4.exe or any later realease and select the
configuration file at91sam9260-ek-radio.conf.

Choose nutbld-sam9260-ram\ for the build tree and nutapp-sam9260-ram\
as the application (sample) directory.

Building the Software MP3 Decoder Library

Open a command line window (aka DOS Box) and change to the Helix Decoder
subdirectory within your build tree. This directory contains just a Makefile,
which compiles the Helix Source Code in the Nut/OS source tree and copies the
resulting library in the lib/ subdirectory of this build tree when entering
'make install'. However, make sure your PATH environment is correctly set. The
following command sequence can be used with YAGARTO, running on a German
Windows 2000 installation.

cd C:\ethernut-4.4.0\nutbld-sam9260-ram\hxmp3
SET PATH=C:\ethernut-4.4.0\nut\tools\win32;C:\Programme\yagarto\bin;%PATH%
make install

In the last line the resulting binary is copied to bin/arm9 inside the Nut/OS
source tree.

SAM7X Implementation

Hardware Installation

All connectors should be removed from the AT91SAM7X-EK Board. Plug the single
row header socket of the Calypso Board on row C of the triple row header of the
AT91SAM7X-EK. Make sure that all 32 pins are connected.

When applying power to the AT91SAM7X-EK Board via the USB connector, the
back-lit LCD will go on, but nothing will be displayed yet.

Software Installation

This
Shockwave Flash Tutorial will guide you through the whole
procedure of creating the Nut/OS libraries for our radio. It is a good idea to
start the Nut/OS Configurator from the Windows Start Menu now and follow the
demo step by step.

We installed Nut/OS in C:\ethernut-4.4.0\ and chose
C:\ethernut-4.4.0\nutbld-sam7x-radio\ for the build tree and
C:\ethernut-4.4.0\nutapp-sam7x-radio\ as the application (sample) directory.
However, you are free to choose different directories. Here's the result of our
build:

Application Program Modules

Known Problems and Limitations

Limited User Interface
Most items are hardcoded, specifically the list of radio stations.

SAM7X Limitiation
Currently only mono stations with 16kHz sampling rate are supported.

Frequently Asked Questions

Hardware

Can I order ready build Calypso Board from you?
Calypso Boards can be purchased online from www.egnite.de
. International orders are accepted, payment can be done by credit card or
bank transfer.

Can I order bare PCBs of the Calypso Board from you?
No, but the Eagle
CAD file of the board layout is available in the appendix of Atmel's
application note. Many board houses accept Eagle Board Files.

Can I alternatively use the AT73C213 DAC, which is available on the
SAM9260-EK Board?
Yes, but the source code needs to be modified. More on this later...

Is the SAM7x256 version really usable?
Yes, but it is limited to low bitrates only and may be used for transmission of speech
(news services etc). Furthermore it will work fine at higher bitrates in local networks.

How about the AT91SAM7x512?
The additional 64kB RAM will help a lot, though it is still below the optimal
300-500kB. The additional 256kB Flash will be fine for adding additional
features like the web interface, which had been excluded on the AT91SAM7X256.
Note however, that such features may also use scarse RAM. Keep in mind, that the
SAM7X network controller has no dedicated RAM for buffering Ethernet packets.
Instead it occupies CPU RAM.

Software

Why do I get a "time_t undeclared" error when compiling the radio
application?
This error occurs, when trying to build application version 1.0.2 or earlier
with Nut/OS 4.3.9 or any later version. To fix this, either upgrade to a newer
application release or add the line

#include <time.h>

to the source file mp3player.c.

Similar Projects

www.circuitcellar.com/AVR2006/winners/DE/AT2581.htm
This versatile wireless Internet music player by Mohammed Rana Basheerwon won a
price in the 2006 AVR Design Contest. It is built around the AT90CAN128 and
plays music from Internet radio stations and shared network drives.