PostHeaderIcon Attack ATmega Embedded Firmware: Lock Bits and Fuse Bits Are Different Locks

The AVR family carries two separate blocks of configuration bits, and both are frequently called fuses in conversation. They are not the same kind of thing, they do not do the same job, and a project that confuses them will choose the wrong approach before any hardware is touched.

One block controls what the device will let you do: whether program memory can be read back, whether the bootloader can write to itself, whether the debug interface stays enabled. The other controls how the device operates: which clock source it uses, how it starts up, whether brown-out detection is active. The first is a lock. The second is a configuration. A device with an awkward configuration is still readable; a device with a lock set is not, no matter how the configuration is set.

The two blocks compared

Property Lock bits Fuse bits
Purpose Access control Operating configuration
Effect on readback Blocks program and data reads None
Effect on execution None Determines clock, startup, brown-out
Reset behaviour Cleared by a chip erase Restored to default by a chip erase
Granularity A small number of modes Individual settings, many combinations

The third row is the one people miss. A device with every lock bit set still runs perfectly; protection does not stop the CPU. Conversely, a device with completely permissive locks and a wrong clock fuse will not run at all, and the resulting “it does not respond” is frequently misdiagnosed as protection.

Why the distinction changes the route

The route depends on which block is responsible for the observed behaviour.

Observation Responsible block Route
Device runs, reads return a fixed pattern Lock bits Physical, or an unlock that erases
Device does not run, does not respond to programming Fuse bits, usually clock Recover the clock, then proceed
Device runs, programming interface refused Lock bits, with debug disabled Physical, or a bootloader path
Device responds, memory reads are empty Already erased Nothing to recover from memory

The second row is where a lot of time is wasted. An AVR whose clock fuses have been set to an external source that is not present on the board will appear dead to a programmer that expects to synchronise with the internal oscillator. The device is not protected; it is waiting for a clock that never arrives. Supplying that clock, or using a programmer that can drive the clock line, restores access without any destructive step.

The lock bit modes

AVR lock bits are not individual booleans. They form a small set of modes, and the mode determines both readback and self-programming.

Mode Program memory readable Bootloader can write Typical use
Unlocked Yes Yes Development
Read protected No Yes, if boot section enabled Production
Read and write protected No No High-assurance production
Reserved or invalid Device dependent Device dependent Should not be used

The second row describes the ordinary production configuration: the code cannot be read out, but a bootloader in the device can still update it. That combination is normal and is often mistaken for a contradiction, since the bootloader has write access and no read access.

The self-programming subtlety

This is the detail that separates the AVR from devices with a simpler lock. The lock affects the device’s ability to read its own program memory, not just an external programmer’s ability to read it. A read-protected part cannot execute a self-read instruction over protected memory.

Operation Unlocked Read protected
External read of program memory Allowed Refused
Device reads its own program memory Allowed Refused
Device writes to program memory via bootloader Allowed Allowed, if boot section enabled
Device reads its own EEPROM Allowed Allowed

The third and fourth rows are what make a bootloader a viable update path on a protected device, and the fourth is why EEPROM is often the one thing that can still be read.

What a protected read returns

The failure mode is worth specifying because it is not uniform across families and programmers.

Behaviour Meaning
All zeros Read refused
All ones Read refused, or blank device
Correct device signature, blank program Protection active; the signature is not protected
Programmer reports a protocol error The device refuses the read command

The third row is the important one for assessment: the signature bytes are readable on a protected device, which means identity can be confirmed even when the code cannot be read.

The route that actually works

Since the lock cannot be removed without a chip erase, and a chip erase destroys the code, the routes that return firmware do not go through the lock.

Route Invasiveness Applies when
Physical readout of the flash array Destructive to the package Always, in principle
Bootloader exploitation None, if a bootloader with read ability exists Rare; most bootloaders do not read
Debug interface, if not disabled None Only if lock bits left it enabled
Side-channel read of the array Non-destructive Depends on the implementation

The fourth row is worth knowing about and is not a general solution: power analysis against a read-protected AVR has been demonstrated, and it depends on details of the implementation that vary by family and by firmware.

Where the adjacent problems are

Once the array is out, several AVR-specific issues follow. The word and byte addressing difference is treated in attacking ATmega firmware, and the fact that flash, EEPROM and configuration are three separate devices is in attacking ATmega AVR programs. Where a bootloader exists and remains enabled, it is worth considering as an entry point, and attacking ATmega embedded firmware through the bootloader covers that path. The historical evolution of protection on this family, from unprotectable mask ROMs to lock bits, is traced under AVR crack.

Services at this boundary

Work covers fuse and lock state determination, clock recovery on devices that appear dead, signature confirmation, physical readout where protection is active, and image validation. It does not cover clearing a read lock while keeping the program, because a chip erase is the only primitive that clears it.

The first question to ask about a non-responsive AVR is not whether it is protected but which fuse set the clock, because a device waiting for a missing clock looks exactly like a protected one.

Comments are closed.