nickgammon/arduino_sketches

Fixed Filename Uploader - Fusebits SOLVED!

mega-hz opened this issue · 13 comments

Hello Nick,
firstly thank you for those good uploader-sketches!

I am using the fixed-filename-uploader in a tester/flasher for new 2560 based Boards.
Because of those 2560 are brand new, their Fusebits are set to 1mhz internal as default.
My Problem is: I need to set the Fusebits to run with 16Mhz external crystal.
it seems to be your code reads the fuse-bits and write them back after programming.
How can i set up the fusebits instead of reading them from the chip?
They should be always HI:0xD8, LO:0xFF and EXT:0xFC
So where in the Sketch can i change this?
I can`t find the right variables for the fuses...

Thank you

I had a discussion with someone else about this recently. His solution was as follows:

if (strcmp (currentSignature.desc, "ATtiny85") == 0)
  {
  writeFuse (0xE2, writeLowFuseByte);
  writeFuse (0xD5, writeHighFuseByte);
  writeFuse (0xFF, writeExtendedFuseByte);
  } 

You could do something similar (of course, with a different board name ("ATmega2560"), and appropriate fuse byte values).

I think I would put that code around line 1371 of the sketch, eg. in your case:

  // now fix up fuses so we can boot    
  if (errors == 0)
    {
    updateFuses (true);

    if (strcmp (currentSignature.desc, "ATmega2560") == 0)
      {
      writeFuse (0xFF, writeLowFuseByte);
      writeFuse (0xD8, writeHighFuseByte);
      writeFuse (0xFC, writeExtendedFuseByte);
      } 

    }

Thats it!

thank you very much for your help!
everything runs now greatful

Wolfram.

Does a chiperase clear everything?

Yes.

Also eeprom?

No.

Since you have changed the fuse to require a 16 MHz clock, do you in fact have a 16 MHz external clock when you try to reflash?

But If i flash the same Board again it doesnt Run anymore.

You can't program it, or it programs OK (no error messages) but the board doesn't run?

And, to be clear, it runs when you program it the first time?

Now i found the reason and the solution:

The HI Fuse must have D9 instead of D8 ! = BOOTRST
This doesn`t have to be set, because of no bootloader!
Now i can flash every board, even it was flashed before!

  • SOLVED -