Ethernut 2.1 B

From Nutwiki
Jump to: navigation, search
Ethernut 2.1 B

Test Environments

Board Nut/OS WinAVR Tera Term
2.1 B 2.6.4 20080610 4.61


On this page you will learn how to setup an Ethernet 2.1 development and testing environment.

You will learn the easiest way on how to use the examples from nutwiki and your own applications. This Guide is not supposed to be a complete manual but as a Quick Start Guide, teaching one of the many methods to get an application running on your Ethernut board.

Immediatly after working through this document, you have the competence to test the examples featured by nutwiki.

Additionally all major topics are also covered in screencasts (Win only).

  1. 16px Screencast Part 1 The Nut/OS Configurator
  2. 16px Screencast Part 2 Preparations
  3. 16px Screencast Part 3 Compiling and Burning
  4. 16px Screencast Part 4 Serial Communications / TeraTerm

Note: The Screencasts found here are at the moment the ones from Ethernut 1.3 H. As the workflow described is identical, please just substitute where it says 'Ethernut 1.3 H' with 'Ethernut 2.1 B'.

24px Required Tools for Windows


Of course you need the latest version of Nut/OS.

Visit this page to download the latest version for Win32:

Nut/OS for Windows features an installer which will do most of the work for you.

It is recommended to install the ethernut folder directly on the root directory:

24px C:/ethernut-4.6.4/ 

Note: All paths in this guide refer to that location!

Tera Term

Tera Term is a so called terminal emulator. We use it to communicate via COM with the board.



WinAVR (pronounced "whenever") is a suite of executable, open source software development tools for the Atmel AVR series of RISC microprocessors hosted on the Windows platform.

It includes the GNU GCC compiler for C and C++.


It is recommended to install the WinAVR folder directly on the root directory:

24px C:/winavr/

Note: All paths in this guide refer to that location!

Text Editor

You can use any text editor you want. Some recommended ones include:

24px Required Tools for Linux

Essential Tools

The following GNU tools are required to configure and build a minimal Nut/OS development environment:

  • C compiler 4.1 or later
  • Binutils 2.18 or later
  • Autoconf 2.61
  • Automake 1.10

AVR cross toolchain

Furthermore, you need a so called cross toolchain, which allows us to create binaries on a Linux host, which will later run on our target board. When developing for 8-bit AVR, we need

  • GNU Compiler Collection for AVR
  • GNU Binary Utilities for AVR
  • AVRDUDE programmer software


wxWidgets is a cross-platform C++ GUI framework, required for Nut/OS configurator GUI.


Lua is an embeddable scripting language, which is used here to specify the configuration rules. This is also required for Nut/OS configurator to run.


Of course you need the latest version of Nut/OS.

Visit this page to download the latest source code package for Linux (Debian):

It is recommended to install the ethernut folder directly in your home directory:

24px $ ~/ethernut-4.6.4/ 

Note: All paths in this guide refer to that location and will be referred to as "ethernut folder/directory" or "/ethernut-4.6.4"


Minicom is a so called terminal emulator. We use it to communicate via COM with the board.

The Nut/OS Configurator

64pxScreencast Part 1

In order to build an optimized Nut/OS for you needs you have to configure one.

In some examples from nutwiki you are asked to setup something in the Nut/OS configurator. This is the time and place to do so.

In general the workflow is as following:

1. Start the Nut/OS Configurator:

24px C:\ethernut-4.6.4\nutconf.exe
24px ~/ethernut-4.6.4/nutconf

2. Select and open the configuration file:


3. Click on Menubar: Edit > Settings

  • Goto Tab: Build
    • Choose Platform: avr-gcc
    • Choose Build Directory: nutbld_21b
  • Goto Tab: Tools
    • 24px Enter Tool Paths: c:\ethernut-4.6.4\nut\tools\win32;c:\winavr\utils\bin;c:\winavr\bin; (Win only)
      (Do not forget the last semicolon and modify paths if you used other locations as described above.)
  • Goto Tab: Samples
    • Choose Application Directory: nutapp_21b
    • Choose Programmer: avr-dude
  • Click OK

4. Click on Menubar: Build > Build Nut/OS

  • Say OK 2 times.

5. Click on Menubar: Build > Create Sample Directory

  • Say OK

Note: You should create a new sample directory every time you build a new system, even if you do not want to use the samples. There are two files named

  • Makerules
  • Makedefs

in that directory, that are necessary for every application to compile.

Nut/OS Configurator built a customized version for your needs and put it in:


Additionally it created an Sample Application Directory with source codes ready to compile:



64pxScreencast Part 2

Application Directory

First of all we need a home for our application.

Create a new directory "testcode" in


You can, of course, use any names you want.


1. Write your application code, or for testing purposes, paste in an example code from nutwiki in a plain text file.

2. Save it as testcode.c in:


Note: Make sure, that in your Windows folder options, the setting 'Hide file extensions for unknown file types' is deactivated! If not, you will create .txt files instead of .c or Makefiles, when saving in the Editor!


For our applications to compile, we need a makefile.

This is used and interpreted by a tool called GNU Make, which we will use later.

Makefiles may differ from application to application, but the following is a general purpose one, which will work for basic applications.
Later, when you are familiar with Nut/OS and makefiles you can create your own ones.

Note, that in this example makefile, the project name, <source lang="text"> PROJ = testcode </source> has to be identical to the name of your application's .c file!

<source lang="text"> PROJ = testcode

include ../Makedefs

SRCS = $(PROJ).c OBJS = $(SRCS:.c=.o) LIBS = $(LIBDIR)/nutinit.o -lnutpro -lnutos -lnutarch -lnutdev -lnutarch -lnutnet -lnutfs -lnutcrt TARG = $(PROJ).hex PARM = $(PROJ).eep

all: $(OBJS) $(TARG) $(ITARG) $(DTARG)

include ../Makerules

clean: -rm -f $(OBJS) -rm -f $(TARG) $(ITARG) $(DTARG) -rm -f $(PROJ).eep -rm -f $(PROJ).obj -rm -f $(PROJ).map -rm -f $(SRCS:.c=.lst) -rm -f $(SRCS:.c=.bak) -rm -f $(SRCS:.c=.i) </source> Note, when copy and pasting the above Makefile: the spaces before -rm... have to be tabs instead of normal spaces!

Create a plain text file and paste in the code above.

Call it Makefile (Without any file extension) and save it to:


Configuration Files

The files

  • Makedefs
  • Makerules



are essential. By building a new Nut/OS and a new sample directory (nutapp_21b) these files get updated. Your application directory (testcode) will remain untouched.

(If you used different paths, note, that the configuration files have to be located in the top directory of the apllication directory.)

Note: You have to build a new sample directory and move 'Makedefs' and 'Makerules' to your application's parent directory (if your app directory is not already a subfolder of "nutapp_21b" as recommended) every time you build a new Nut/OS!

Path environment (Win only)

Every command line session has its own PATH variable.

Applications like GNU Make look up paths in that variable.

We need to add to the path variable our tools:

24px C:/ethernut-4.6.4/nut/tools/win32;c:/winavr/utils/bin;c:/winavr/bin;

To do so, we could enter in the command line prompt:

SET PATH=c:/ethernut-4.6.4/nut/tools/win32;c:/winavr/utils/bin;c:/winavr/bin;%PATH%

(The %PATH% at the end appends the original content of the PATH variable to the newly set.
By leaving that out the PATH gets overwritten.)

Because every time you close the command line prompt your PATH variable gets lost,
there is a better way to handle it.

1. Create a plain text file and enter:

SET PATH=c:/ethernut-4.6.4/nut/tools/win32;c:/winavr/utils/bin;c:/winavr/bin;%PATH%

2. Name it AVR.bat and save it to:

24px C:\ethernut-4.6.4\nutapp_21b\testcode\

This is called a Batch file.
Everytime you type in AVR in the testcode directory now, the PATH variable gets set.
You have to execute AVR every time after you open a new command line window.
If you do not, GNU Make will not find the tools.


To connect your Ethernut 2.1

  • Connect the SP DUO to Ethernut's JTAG connector
  • Connect the SP DUO to an available COM port of your computer using the serial cable.
  • Connect the power supply to the barrel connector on the Ethernut board. The

Ethernut board is equipped with its own rectifier bridge and voltage regulator. Therefore the polarity of the barrel connector isn't important.

  • Apply power to the Ethernut board by connecting the power supply to an

electrical outlet. When the board is powered up, the red power LED should go on.

For further details have a look at the Hardware Manual

Compiling and Burning

64pxScreencast Part 3

Now its time to compile.

1. Open a command line window.24px / Shell window 24px

2. Change to

24px C:\ethernut-4.6.4\nutapp_21b\testcode\
24px ~/ethernut-4.6.4/nutapp_21b/testcode/

3. Enter: Windows only!

24px SET PATH=c:/ethernut-4.6.4/nut/tools/win32;c:/winavr/utils/bin;c:/winavr/bin;%PATH%


24px AVR

if you are using a batch file.

4. Enter:

make clean

This tells "Make" to clean up the directory with respect to the rules made in the Makefile

You should get something like:

rm -f testcode.o

rm -f testcode.hex testcode.bin testcode.elf
rm -f testcode.eep
rm -f testcode.obj
rm -f
rm -f testcode.lst
rm -f testcode.bak
rm -f testcode.i

If not, you maybe left out step 3.

'Make Burn'

1. Connect your Ethernut 2.1. (for further details take a look at the Hardware Manual)

  • Power Supply
  • COM to SP DUO to JTAG

2. Enter:

make burn

This compiles the necessary files for you and a tool called avr-dude burns the binaries onto your Ethernut board's flash storage.

To configure avr-dude, please edit the following file:


24px BURNPORT=com1(2,3..etc.) 24px BURNPORT=/dev/ttyS0(1,2,3..etc.)

Serial Communications / Tera Term

64pxScreencast Part 4

Done. All you have to do now, is to connect the serial cable to the Ethernut's COM Port and start TeraTerm or any other serial communications tool.

Configure TeraTerm with the follwing settings:

  • Menubar > Setup > Serial port...
    • Baud rate: 115200
    • Data: 8Bit
    • Parity: None
    • Stop: 1bit
    • Flow control: none
    • Transmit delay: 0;0

Now reset your Ethernut board and you will (hopefully) see the output.

Important things to remember

In order to not get frustrated remember:

  • When entering the tool paths in the Configurator, do not forget the semicolon at the end of the line!
  • Make sure, that the setting 'Hide file extensions for unknown file types' is deactivated in you Windows folder options. Otherwise, 'Editor' won't create proper .c or Makefiles.
  • In the Makefile, make sure, that the project name is identical to your .c file's name!
  • Update the PATH variable every time you open a new command line prompt! Write a bash file for that.
  • You have to build a new sample directory and move 'Makedefs' and 'Makerules' from there to your application's parent directory every time you build a new Nut/OS with the Configurator!
  • To configure avr-dude and toggle the COM port for example, please edit the following file: c:\ethernut-4.7.4\nut\app\Makeburn.avr-dude

See also

External Links

[1] Ethernut 2.1 Hardware Manual (September 2008)

[2] Ethernut Software Manual (November 2005)