I've been browsing Westfw's optiloader file WestfW-OptiLoader-f41e3fd.zip
The part that puzzles me is the treatment of the fuse bytes.
According to the source:
image_t PROGMEM image_328p = {
{
"optiboot_atmega328.hex" }
,
{
"atmega328P" }
,
0x950F, /* Signature bytes for 328P */
{
0x3F,0xFF,0xDE,0x05,0 } /* fuses to set during programming */
,
{
0x2F,0,0,0,0 } /* fuses to set after programming */
I added a couple of comments.
Now as I read that:
#define FUSE_PROT 0 /* memory protection */
#define FUSE_LOW 1 /* Low fuse */
#define FUSE_HIGH 2 /* High fuse */
#define FUSE_EXT 3 /* Extended fuse */
After programming (and this code appears to be executed) it sets the low, high, and extended fuses to be 0. But that just doesn't look right, looking at the fuse meanings. For example that turns on "reset disable" and "debug wire". It also sets the bootloader size to 2048 words.
So I'm clearly missing something here, but what?