Ethernut Home Hardware Firmware Tools Download Community
Ethernuts  /  Ethernut 5  /  Boot
Search | Legals | Deutsch

Ethernut 5 Boot Loading

Booting of Ethernut 5 is a two-stage process. The first stage boot loader, SAMBoot, is a few kBytes in size only. It simply transfers the second stage boot loader from serial Flash memory to SDRAM. This second boot loader, named Das U-Boot, is able to boot an operating system kernel from a variety of storage devices and via network.

When booting, Ethernut 5 uses the RS-232 port (DBGU) as a console. You need a Null-Modem cable to connect the board to your PC's serial port. If no serial port is available, you can use a so called USB to RS-232 bridge to add a virtual serial port.

Make sure, that JP1 is properly configured for DBGU. See the picture on the right.

A terminal emulator is required to communicate via the Ethernut 5 console. For Windows PCs we recommend Tera Term. On Linux Minicom works quite well. The RS-232 configuration used by Ethernut is typically


SAMBoot is a first stage boot loader running in first pages of internal Flash memory. A ready-to-use binary image is provided in the Ethernut 5 Flasher package on our download page.

SAMBoot is based on the LeanLoader project. The complete source code is available at SourceForge. To build SAMBoot from the source, you need to have a GNU ARM toolchain installed. Windows users should download Michael Fischer's YAGARTO.

Then get LeanLoader from the Subversion repository with the command

svn co leanloader

Change to the LeanLoader's target subdirectory and run the SAMBoot Makefile.

cd leanloader/target
make -f Makefile.samboot-ethernut50

If everything works as expected, the current directory will contain a new binary image named samboot.bin.

For sure, there are several ways to program SAMBoot into the internal Flash. if your PC is running Windows, then the SAM-BA tool from Atmel may be your first choice. This works almost in the same way as programming the EIR board, which is explained on the page EIR Firmware Upload Using SAM-BA. Note, that you need to erase the current Flash contents first by shortening pins 1 and 2 of JP2 (see picture on the right). After SAM-BA started, select the AT91SAM9XE-EK board. Before exiting SAM-BA, you must program the GPNVM3 bit, not the GPNVM2 bit that is used in the EIR description.

We haven't tried lately to use SAM-BA on a Linux PC, but several people reported success, so you may give it a try.

We tried OpenOCD to directly program the AT91SAM9XE Flash, but this fails. At the time of this writing, there seems to be no Flash support for this CPU. For now, the Ethernut 5 Flasher application is the only solution. Copy your new SAMBoot binary into the urom subdirectory and rebuild the flasher tool. OpenOCD is then used to transfer the flasher binary into the Ethernut 5 SDRAM. A more detailed description is given below.

Das U-Boot

U-Boot is available for a large number of target systems and is well documented. However, the project is quite active and, like with other Open Source projects, documents tend to become outdated too quickly.

After U-Boot is loaded and started by SAMBoot, it will print a number of information messages on the console, including

Hit any key to stop autoboot:

Within 3 seconds, hit any key while the terminal emulator window is active to interrupt the automatic boot procedure. You'll then get a command prompt. Enter

to get the list of available commands.

The Ethernut 5 patch adds a new command pwrman to handle power management. For a description enter

help pwrman

You can build U-Boot using OpenEmbedded. See Linux for Ethernut 5 for instructions.

Ethernut 5 support is in the official U-Boot repository, but we still need to apply some patches. A ready-to-use binary image of version 2013.01.01 is included in the Ethernut 5 Flasher package on our download page.

The source code is hosted at Like SAMBoot, you first need a GNU ARM toolchain to build U-Boot for Ethernut 5. However, building U-Boot on Windows may not work, because a number of additional tools are required. Our recommendation for Windows users is to install Linux in a VirtualBox.

Boot Configuration

U-Boot is quite flexible. Its behavior is controlled by environment variables, which may also contain scripts, which can be executed by the run command.

The Ethernut 5 DataFlash contains a full blown environment, pre-set for booting over the network and several other goodies. Note, that several bugs had been discovered in earlier versions. Make sure to use the latest update of the flasher tool.

For more details about the U-Boot environment see Ethernut 5 U-Boot Environment.

Initial Setup

As mentioned in the last chapter, U-Boot can be used to update items, that are stored in the serial Flash memory chip on Ethernut 5. Here is a list of these items:

Address1 Contents Size
0xC0000000 Available. You can freely use this area for your application. 0x21000 (132kB)
0xC0021000 Image of a full-blown U-Boot environment. 0x21000 (132kB)
0xC0042000 Image of the U-Boot boot loader. 0x84000 (528kB)
0xC00C6000 Linux kernel image in U-Boot readable format. 0x294000 (2460kB)
0xC035A000 Available for Nut/OS application images. 0x84000 (528kB)
0xC03DE000 Saved U-Boot environment. Use saveenv to store the current environment in this place. 0x21000 (132kB)
0xC03FF000 Available, but typically used by Nut/OS. 0x21000 (132kB)2

If you deleted or corrupted your Flash memory by accident, then U-Boot may fail to load. The same is true, if you build your own board based on the Ethernut 5 design (the Open Source license encourages you to do so) or if you have to replace the DataFlash chip.

Download the Ethernut 5 Flasher package from our download page and unpack it in any directory of your choice. The subdirectory urom contains the following images:

There are several ways to upload these images to your Ethernut board. The first one may be prefered by Windows users. Get the SAM-BA tool from Atmel's website. This GUI allows to flash all the images listes above. This can be done via USB or RS-232. A special ROM area in the AT91SAM9XE CPU must be activated, to make this happen. However, all you need to do is to erase the CPU by setting jumper JP2. Details can be found in the Ethernut 5 Hardware Manual. When started, SAM-BA will ask for the board to connect to. You will not find Ethernut 5, but this board is almost compatible to the AT91SAM9XE-EK. The GUI will then try to connect the ROM code on Ethernut 5. When connected, select the Flash page and upload samboot.bin to the internal Flash of the AT91SAM9XE. Then set the GPNVM bit 3 to disable the ROM code and activate SAMBoot again when the board is reset. But do not reset it now.

Select the DataFlash page and activate chip select 0. Then you may upload any or all of the remaining images, using the offset given in the table above, but not including the offset used by U-Boot, e.g. the Linux kernel will go to 0xC6000.

SAM-BA is not available for Mac OS X. Though, available for Linux, it may not work here. Before the CDC version became available, it didn't even work on my Windows 7 64-Bit machine. If you have any JTAG dongle available, you can alternatively use OpenOCD or any similar tool. OpenOCD is free (in the sense of freedom), but the trouble is, that it doesn't support DataFlash chips or the internal Flash of the AT91SAM9XE. But it is able to initialize the SDRAM on Ethernut 5 and upload an image and run it in SDRAM. For Linux or MAC OS X you can use almost any of the latest binary release of OpenOCD or build one from the source code. For Windows PCs this is not trivial and binary releases may not work reliable with your JTAG adapter. Note, that a special Windows version of OpenOCD for the Turtelizer 2 JTAG adapter is available on the download page.

The Ethernut 5 Flasher package contains a large binary en5flasher.bin. When uploaded and executed in SDRAM, it will automagically do all required steps in one go.

As Ethernut 5 is a new product, it may not be supported by your version of OpenOCD. The Flasher package contains an OpenOCD configuration file (ethernut5.cfg), which you need to copy to the board directory in your OpenOCD installation path.

They way to upload and run en5flasher.bin in SDRAM depends on your environment. If you are familiar with OpenOCD, this may not provide a big problem. I'll now describe the default procedure for Windows, using the Turtelizer 2. I assume, that you installed the OpenOCD version for Turtelizer including the Turtelizer USB driver in C:\ethernut\nut\tools\ and unpacked the en5flasher package in C:\ethernut\nutapp\en5flasher\. This will look quite familiar to Nut/OS users, others may prefer different locations, which is fully OK.

Again, it will be required to start the terminal emulator and connect your PC to the serial port of Ethernut 5 (see above).

Open a command line window, change to the en5flasher directory, set the PATH to the OpenOCD directory containing the OpenOCD executable and start OpenOCD with the following command sequence:

cd C:\ethernut\nutapp\en5flasher
openocd -s C:/ethernut/nut/tools/turtelizer2 \
        -c "source [find interface/turtelizer2.cfg]" \
        -c "source [find board/ethernut5.cfg]"

The backslashes used at the end of some of the lines is the Unix way to continue the command on the following line. it is used here to split the line for readability and will not work on the Windows command line. Instead, enter all three lines in one large line.

While OpenOCD is running in one command line window, open another one to start a Telnet client.

telnet localhost 4444

When connected, enter the following lines in the Telnet window:

reset init
load_image en5flasher.bin 0x20000000 bin
resume 0x20000000

The image is quite bulky and will need its time to upload. Be patient. After you entered the last line, which starts the flasher, you can watch its output on the terminal emulator. After the flasher finished its task, your Ethernut 5 is ready to reboot. On the Telnet window enter


to stop OpenOCD. Keep the terminal emulator running and reset your Ethernut board. Note, that the function of the reset button is configurable. If it doesn't work, remove and re-insert the power supply instead.

In the terminal emulator you should finally see SAMBoot first and then U-Boot, starting automatically after reset. However, booting the Linux kernel may still fail, because:

  1. The U-Boot Environment is not properly set.
  2. The NAND Flash contains no valid root file system.

Solving the first problem is explained above. For the second case I created another page, explaining how to build Yocto for Ethernut 5. You may also refer to other Internet resources like Linux4SAM.

One last note: Nut/OS users may have noticed, that en5flasher is an ordinary Nut/OS application, which can be build within a Nut/OS distribution. Be aware, that compiling urom.c will take a really long time. I used Nut/OS 4.9, but the latest 4.8 should work too.

Power Management

Ethernut 5 uses an ATmega168 for power management. The download page contains a Nut/OS application similar to the flasher package described in the last chapter, which will re-program the AVR firmware. To enable this function, you need to re-configure jumper JP3 as explained in the Ethernut 5 hardware manual.

Flashing the Root File System

The archive on the download page contains two files. The file ethernut5-image-ethernut5.jffs2 contains a file system in JFFS2 format and can be directly used for uploading to U-Boot, for writing it to the NAND Flash. Alternatively, the file named ethernut5-image-ethernut5.tar.bz2 may be unpacked on an existing file system like a memory card or stick or an NFS share.

By default, U-Boot will direct the kernel to the JFFS2 filesystem located on the on-board NAND flash. You need to change the bootargs defined in the U-Boot environment in order to use other devices for the root FS, like NFS shares, memory cards or sticks. Have a look to the U-Boot Manual provided by DENX Software Engineering. This page shows how to create a root FS.


Castrop-Rauxel, 13th of June 2011.