Pages: [1]   Go Down
Author Topic: Optiloader writes fuse bytes to be zero, that doesn't look right?  (Read 467 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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:
#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?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 179
Posts: 8064
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

See target_progfuses() and target_normfuses().
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
if (f) {
...

Thanks!
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 179
Posts: 8064
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

See target_progfuses() and target_normfuses().
Ach! I missed this:
Code:
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. smiley-sad
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6371
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: