Go Down

Topic: Optiloader writes fuse bytes to be zero, that doesn't look right? (Read 603 times) previous topic - next topic

Nick Gammon

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:

Code: [Select]
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:

Code: [Select]
#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?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

johnwasser

The code fetches the value to be programmed and only programs it if the value is non-zero.

See target_progfuses() and target_normfuses().
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Nick Gammon


The code fetches the value to be programmed and only programs it if the value is non-zero.

See target_progfuses() and target_normfuses().


Ach! I missed this:

Code: [Select]
if (f) {
...


Thanks!
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

johnwasser



See target_progfuses() and target_normfuses().

Ach! I missed this:
Code: [Select]
if (f) {
...



To tell the truth, I missed it too when I read target_progfuses() and the first time through target_normfuses().  Then I noticed it on second reading and went back to target_progfuses() and found the same thing there!  I hate when the code changes between readings. :(
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

westfw

It's so nice to have other people explain my questionable code  :-)

Go Up