Ethernut Home Hardware Firmware Tools Download Community
 
 
Search | Legals | Deutsch

Ethernut Fuses

Introduction

This article presents detailed information about ATmega128 fuse settings with focus on the Ethernut hardware. While reading this, you should have the ATmega128 datasheet in hand.

The AVR microcontroller, of which the ATmega128 is a member, contain a number of fuses to enable or disable special features like crystal clock options, reset options etc. To program (enable) a fuse bit, you use the same software and hardware as for uploading your program code into FLASH memory or configuration data into EEPROM memory. Like FLASH and EEPROM memory, fuses can be programmed (to zero) or unprogrammed (to one). However, when erasing an AVR device, the fuses will be preserved.

A word of caution. Playing around with fuse settings is risky, as long as you don't take special care. Wrong fuse settings may completely disable the device.

If you purchased an assembled Ethernut from one of its distributors, you don't need to care about fuse settings in the first step. Later, if you want the force the ATmega to jump into the bootloader upon reset or if you want to clear the EEPROM when erasing the ATmega, then this is the place you have been looking for.

If you own an older ATmega103 based Ethernut board, then there is not much you can do with the fuses.

If you built your own Ethernut compatible board, you have to modify the original fuse settings. Otherwise you won't be able to run Nut/OS, at least not with full speed and standard baud rates for the serial port.

Required Hardware

There are several programming adapters (AKA programming dongles) available.
We recommend the SP Duo Programmer from Embedded Creations,

SP Duo

which offers a few advantages, mainly

This device works well on Windows and Linux. However, the SP Duo supports programming only, no JTAG debugging. If you are able to spend more money, then the AVR JTAGICE mkII is a good choice.

JTAGICE mkII

However, the author didn't test this device with Linux. Other users reported, that it is working. Blame them, not me, if it is not.

More information about programming hardware are presented here.

Required Software

Atmel offers AVR Studio for Windows for free. This isn't just a simple programming software, but an integrated development environment with assember, debugger, simulator, source code editor and other goodies.

Originally written by Uros Platise, uisp is a command line tool for the Linux operating system. It's currently maintained by Ted Roth and Marek Michalkiewicz and available at savannah.nongnu.org. A port to the Windows operating system is included in the WinAVR distribution.

More information about programming software is given here.

Ethernut Programming Connector

All Ethernuts provide at least one 10-pin programming connector. Unfortunately Atmel decided to use the same physical connector type for JTAG and SPI. Using the wrong connector with your programming adapter will at least blow the power fuse on the Ethernut 2.x and may even destroy your Ethernut 1.x boards.

Board Version SPI (aka ISP) JTAG
Ethernut 1.1 Available Not available for ATmega103 CPU.
Ethernut 1.3 Rev-F and below Available Requires special PORT F adapter
Ethernut 1.3 Rev-G Available Available
Ethernut 2.0 Rev-A Available, see JP4 Available, see JP4
Ethernut 2.1 Rev-B Requires special expansion port adapter Available

This table somehow reflects the Ethernut design history. While JTAG wasn't available in the early days, the latest board revision provides JTAG only, unless you build your own adapter. The AVR JTAGICE comes with a split cable, which can be used to create such an adapter with flying cables. Refer to the schematics of your board to connect the wires.

Split Cable

Some pictures about how to connect a programming adapter to the Ethernut board are available here.

ATmega128 Factory Settings

We can use uisp on the command line to read the fuses of the ATmega 128, which had been shipped from the factory and not yet modified. The command line parameters in our example fit for the SP Duo connected to the first serial port. When using a different adapter, please refer to its manual for the correct parameters. Note, that uisp expects Linux device names for the serial port, even if running on Windows. If the adapter is connected to the second serial port, then replace /dev/ttyS0 with /dev/ttyS1.

# uisp -dprog=stk500 -dserial=/dev/ttyS0 -dspeed=115200 -dpart=atmega128 
--rd_fuses
Firmware Version: 49.48
Atmel AVR ATmega128 is found.
Fuse Low Byte = 0xe1
Fuse High Byte = 0x91
Fuse Extended Byte = 0xfd
Calibration Byte = 0x00 -- Read Only
Lock Bits = 0xff
BLB12 -> 1
BLB11 -> 1
BLB02 -> 1
BLB01 -> 1
LB2 -> 1
LB1 -> 1
Watch out for lines, which may be wrapped if your browser window is too narrow.

To interpret the output, we need to refer to the ATmega128 datasheet. This chips hass three fuse bytes, the Fuse Low Byte, the Fuse High Byte and the Extended Fuse Byte.

In the extended byte, only the second fuse bit is programmed (0xfd is 11111101 in binary digits). The datasheet explains, that this bit is named M103C and enables the ATmega103 compatibility mode. This is probably not, what we want for running Nut/OS built for the ATmega128.

The high byte has four fuses programmed by default, BOOTSZ0 and BOOTSZ1 (second and third bit) as well as SPIEN and JTAGEN (sixth and seventh bit). While the first two can be ignored unless BOOTRST (first bit) is programmed, the latter should be kept unchanged. Unprogramming them would disable SPI or JTAG programming with exactly that meaning.

The low byte mainly controls the on-chip oscillator. With the default setting the ATmega runs with its internal RC oscillator at 1 MHz. Thus, the external crystal is not used and we can proof this with an oscilloscope. Changing these fuses is highly critical with an SPI programmer. There are quite many variations available and many of them require a special hardware other than the crystal we got on the Ethernut board. When the CPU clock is disabled somehow, SPI programming is no more available. One reason, why you should think about purchasing the SP Duo. JTAG programming is available without a running CPU clock.

We can use uisp to change the fuses to the Ethernut default setting. Again check for wrapped lines. All parameters upto --wr_fuse_e=0xff should be entered in one line.

# uisp -dprog=stk500 -dserial=/dev/ttyS0 -dspeed=115200 -dpart=atmega128 
--wr_fuse_l=0x3f --wr_fuse_h=0x83 --wr_fuse_e=0xff
Firmware Version: 49.48
Atmel AVR ATmega128 is found.
Fuse Low Byte set to 0x3f
Fuse High Byte set to 0x83
Fuse Extended Byte set to 0xff
When using AVR Studio, you may refer to images in the bootloader settings at the end of this page.

Ethernut Factory Settings

We can call uisp on the command line to read the fuses. Again the following parameters are for the SP Duo connected to the first serial port.

# uisp -dprog=stk500 -dserial=/dev/ttyS0 -dspeed=115200 -dpart=atmega128 
--rd_fuses
Firmware Version: 49.48
Atmel AVR ATmega128 is found.
Fuse Low Byte = 0x3f
Fuse High Byte = 0x83
Fuse Extended Byte = 0xff
Calibration Byte = 0x00 -- Read Only
Lock Bits = 0xff
BLB12 -> 1
BLB11 -> 1
BLB02 -> 1
BLB01 -> 1
LB2 -> 1
LB1 -> 1

EEPROM Settings

With the Ethernut default fuse settings, the EEPROM contents will not be changed by the programmer's chip erase. This has the advantage, that Basemon can be used to enter MAC address and IP configuration and that these settings will remain when loading a new application into Ethernut's FLASH memory.

However, there may be situations where you want clear the EEPROM contents. Fuse number 3 (the forth bit because we count from zero) of the Fuse High Byte needs to be unprogrammed to disable EESAVE (preserve EEPROM).

# uisp -dprog=stk500 -dserial=/dev/ttyS0 -dspeed=115200 -dpart=atmega128 
--wr_fuse_h=0x8b
Firmware Version: 49.48
Atmel AVR ATmega128 is found.

Fuse High Byte set to 0x8b

Bootloader Settings

By default the ATmega128 starts running at FLASH memory address zero when the reset button is pressed or when the board is powered up. Some applications may require to start with the bootloader. Again we could use uisp the set the corresponding fuses. For the GUI fans among you, we present the full listing of the AVR Studio fuse dialog. Compared to the default settings, only the Boot Reset vector Enabled had been additionally checked. Thus, you may use the following images as a reference for the Ethernut default configuration.



Ethernut Fuses 1
Ethernut Fuses 2
Ethernut Fuses 3
Ethernut Fuses 4
Ethernut Fuses 5

Good luck! You may need this. :-)