328p fuse settings check

I've been trying to get an Atmega328p on an Arduino-clone board with an Optiboot bootloader to reset to the bootstrap on watchdog timeout.

Looking at the fuses, the Reset to Bootstrap bit is 0, which should force a jump to the bootstrap on reset, and in fact an assembly language "jmp 0x7c00" restarts the board correctly.

However, simply configuring the watchdog and letting it time out ends up in the weeds. Interrupt-only mode works, but not System-reset mode.

Looking again at the boot flags the High Fuse bootstrap size bits are 01, which gives a 1024 word / 2048 byte bootstrap partition. The actual partition is 512 word / 1024 bytes, hence the 0x7c00 start address.

I'm using the bootloader which came with the chip, which I can't modify; have I got my arithmetic wrong somewhere, or are the bootloader fuses mis-progammed?

Thanks - Will

The full set of fuses are:

Fuse bits (L/E/H): FF FF DA
Lock bits:         FF
Signature:         1E 95 F (ATmega328P)
Oscal:             AF

Fuse Low = 11111111 (FF)
           ||||++++______Low Power Crystal 8 - 16MHz
           ||++__________Start Up Time=11
           |+____________Clock Output Disabled
           +_____________(no divide)

Fuse High = 11011010 (DA)
            |||||||+______Reset to Bootstrap
            |||||++_______1024 words (2048 bytes)
            ||||+_________EEPROM Erased on chip erase
            |||+__________Watchdog programmable
            ||+___________ISP programming enabled
            |+____________DebugWire off
            +_____________RST enabled

Fuse Extended = 11111111 (FF)
                |||||+++______Brownout Disabled

Lock Bits = 11111111 (FF)
            ||||||++______Read/Write to everywhere
            ||||++________R/W Application
            ||++__________R/W Boot Section

Do a check with a 2nd program:

The bit BOOTRST tells the micro where to jump after a reset. If it's set (in fuses, set is "0" and clear is "1") then the MCU look the next two bits (BOOTSZx) and finds the size of the point of the flash to jump to after the reset by simply doing a subtraction: the address of the highest Flash cell - the size of the area reserved for the bootloader.

So, the actual reserved area is 2048b (1024w) but if the chip was originally flashed to reserve 1024b (512w) then the bootloader is placed at a different address and in the first case the chip jumps to an empty area.

Use this calculator to help you find the correct values for the fuses: http://www.engbedded.com/fusecalc

I suggest to burn again the bootloader on the chip using the correct fuses and try again after this step. Or, try flashing the fuses to indicate the correct size of the actual reserver area.

Thanks - that makes things a bit clearer. I'll have to do some more digging around the registers, but I think you're righ, it's a question of reprogramming the chip.