Difference between revisions of "Firmware/NutOS"

From Nutwiki
Jump to: navigation, search
(Created page with "<div id="content"> = Nut/OS = == Features == Nut/OS is based on an intentionally simple RTOS kernel, which provides a minimum of services to run Nut/Net, the TCP/IP stack....")
(No difference)

Latest revision as of 10:43, 13 July 2017



Nut/OS is based on an intentionally simple RTOS kernel, which provides a minimum of services to run Nut/Net, the TCP/IP stack. It's features include:

  • Coperative multithreading
  • Deterministic interrupt response times
  • Priority based event handling
  • Periodic and one-shot timers
  • Dynamic memory management

Main features of the TCP/IP stack are:

  • Base protocols Ethernet, ARP, IP, ICMP, UDP, TCP and PPP
  • User protocols DHCP, DNS, SNTP, SMTP, FTP, SYSLOG, HTTP and others
  • Socket API
  • Host, net and default routing

Nut/OS is a modular operating system. Instead of providing a fixed kernel block, all code is packed in libraries. Only those parts are linked to the final binary image, which are directly or indirectly referenced by the application. This guarantees the lowest possible footprint. Ernst Stippl regularly publishes related figures on his web site at www.es-business.com/ethernut/.

Standard C libraries like newlib or avr-libc are supported and allow to write highly portable applications. While direct hardware access and native interrupts are possible in application code, the system offers ready-to-use drivers for a large number of devices, including:

  • Ethernet controllers
  • UART devices with RS-232 handshake and RS-485 mode
  • SPI, I2C and CAN busses
  • MultiMedia and SD cards
  • Hardware and software audio codecs
  • Analog-to-digital converters
  • Serial flash memory
  • Realtime clocks
  • Infrared remote controls
  • Watchdogs and reset controllers
  • Character displays
  • GPIO and interrupt control
  • Modem control

Note, that not all drivers may be available on all platforms. The following microcontrollers are actively supported:

  • ATmega103, ATmega128, ATmega2561, AT90CAN128
  • AT91SAM9260, AT91SAM9XE
  • Gameboy Advance

The system is highly configurable and may work on other hardware too. Support for AVR32 is currently under development and a version for the Freescale Coldfire may become available as well. In addition it is possible to run Nut/OS applications on Linux.

In order to hide hardware specific details from application code, an almost complete C stdio API is available, which provides:

  • C99 integer types and optional floating point I/O
  • File system support, including FAT
  • Low level functions and streams on devices, TCP sockets and files

Nut/OS is perrmanently enhanced by an active community. The following features are currently not available, but planned for future releases or currently under development:

  • Graphical user interface
  • USB stack
  • IPv6
  • Encryption
  • Wireless LAN



During system initialization, the idle thread is created in the background first. The application code is not aware of this. Like any other C program, it contains a main routine. Internally the main routine is a thread, running concurrently with the idle thread.

During runtime, the main thread may create additional threads by calling NutThreadCreate.

Thread synchronization is provided by events. A thread may wait for an event or it may post an event to wake up another thread, which is waiting for this event.


Device Drivers

Simple operating systems like Nut/OS allow application code to directly access the hardware. Device drivers are not required. Nevertheless, Nut/OS provides a large number of device drivers to allow the application to use portable, high level functions to access them. For example, an MP3 player can use the standard C runtime function fread to read the audio file from an SD Card and fwrite to send it to the MP3 decoder for playing.

For special devices, like general purpose I/O (GPIO), SPI or I2C, specific helper routines are available to keep your applications portable among all supported platforms.

Nut/OS is a modular kernel, where device drivers are included only, when the applications registers them via NutRegisterDevice.



While file system support is not common for tiny systems, Nut/OS provides several. The most simple is read-only and named UROM. Files are stored as C arrays and directly linked to the application code. A special utility is available to convert a complete directory on your PC's harddisk into such arrays.

The most advanced file system is a FAT12/16/32 compatible one named PHAT. It is preferably used with MultiMedia and SD Cards.

The most recent Nut/OS beta includes UFLASH, which is optimized for serial flash chips. It requires a few hundred bytes of RAM only and has an excellent wear leveling performance.



Nut/OS contains a feature rich TCP/IP stack. Although quite similar, the API is not fully BSD-compatible. It uses its own set of functions. The great thing is, however, that established connections can be associated to stdio streams. For network communication, applications can use the full set of stdio routines like fprintf, fscanf, fgetc etc.

Beside basic TCP and UDP sockets, several high level protocols are included as well. The latest version supports DHCP, DNS, FTP, HTTP, SMTP, SNMP, SNTP, syslog and others.

Getting Started

Using Nut/OS on Ethernut 1.3
The [[../hardware/enut1/index.html|Ethernut 1.3 reference hardware]] is based on the 8-bit ATmega128.

Using Nut/OS on Ethernut 2.1
Like Ethernut 1.3, the [[../hardware/enut2/index.html|Ethernut 2.1 reference hardware]] uses an ATmega128 CPU, but offers more memory, fast Ethernet and an RS-485 interface.

Using Nut/OS on Ethernut 3.0
The [[../hardware/enut3/index.html|Ethernut 3.0 Board]] comes with a fast 32-bit CPU.

Using Nut/OS on the Elektor Internet Radio
Also equipped with a 32-bit CPU, the [[../hardware/eir/index.html|Elektor Internet Radio]] not only has very large memory areas, but also the world's first Ogg Vorbis hardware encoder chip.

Large collection of code snippets and tiny examples.

Additional Documents

Must Have

[[../../pdf/enswm28e.pdf|Nut/OS Software Manual]]
How to install and use Nut/OS.

[[../../api/index.html|Online API Documentation]]

[[../../api-beta/index.html|API Documentation of the beta release]]

More documents

NEW: Porting Nut/OS
... to new platforms.

[[../documents/ntn-6_spi.html|SPI Bus Support]]
Technical details about SPI drivers.

[[../documents/arm-exceptions.html|ARM Exception Handling]]
Nut/OS doesn't provide any exception handling by default. This document shows how to implement an exception handler within your application.

[[../documents/arm-inline-asm.html|ARM GCC Inline Assembler Cookbook]]
The GNU C compiler for ARM RISC processors offers to embed assembly language code into C programs. This cool feature may be used for manually optimizing time critical parts of the software or to use specific processor instruction, which are not available in the C language.

[[../documents/led.html|LED control]]
A beginner's guide to connecting external hardware.

[[../documents/ntn-4_floats.html|Floating Point Support]]
The kernel won't need it, but your application may want to read or write floating point numbers.

[[../hardware/enut2/rs485.html|Using RS485 with Ethernut 2]]
Jumper settings, configuration and sample code.

[[../documents/at91sam9260.html|Running Nut/OS on the AT91SAM9260]]
A step by step guide. Preliminary.

[[../documents/at91sam7x256.html|Running Nut/OS on the AT91SAM7X]]
Access your MultiMedia Card on the AT91SAM7X Evaluation Kit via FTP.

[[../documents/atmega2561.html|Running Nut/OS on the ATmega2561]]
Preliminary support for the ImageCraft Compiler running on Windows.

[[../documents/watchdog.html|Using the Hardware Watchdog]]
How to implement a timer interrupt handler for Ethernut 3.

[[../documents/at91-timer-irq.html|AT91 Timer Interrupts]]
How to implement a timer interrupt handler for Ethernut 3.

[[../documents/phat.html|Using the PHAT File System]]
Making your MMC interface on Ethernut 3 work.

[[../documents/ntn-3_broadcast.html|Using UDP Broadcasts]]
This paper presents a simple tool to discover all Ethernuts in a local network.

Partly outdated

[[../documents/npl.html|Nut Programmable Logic]]
This tutorial teaches you to modify the CPLD on Ethernut 3.

[[../documents/webradio.html|MP3 Streaming]]
A step by step guide on how to build a stand-alone Embedded Internet Radio.

[[../documents/ntn-1_ppp.html|Setting up PPP]]
This paper provides helpful information about how to get started with Ethernut's PPP.

[[../documents/sam-web-radio.html|SAM Internet Radio]]
Implementing an Internet Radio on the AT91SAM9260 and AT91SAM7X Evaluation Kits.

[[../documents/ntn-2_events.html|Nut/OS Events]]
This paper explains Nut/OS event handling internals.

CPU and Memory Requirements

[[../../pdf/entet100.pdf|Nut/OS Threads, Events and Timers]]
Recommended reading for application programmers.

[[../../pdf/enmem21e.pdf|Nut/OS Memory Considerations]]
Includes a design proposal for bank switched RAM.