Poblems burning bootloader to Atmega1284p

Hi there, I'm trying to burn a bootloader to my Chip but I'm stucked... I first tried with Arduino as ISP but without luck. No I'm working with Nick Gammon's tools an I might found the problem. With the Fuse Calculator I have this output:

Atmega fuse calculator.
Written by Nick Gammon.
Entered programming mode OK.
Signature = 0x1E 0x97 0x05 
Processor = ATmega1284P
Flash memory size = 131072
LFuse = 0x62 
HFuse = 0x99 
EFuse = 0xFF 
Lock byte = 0xFF 
Clock calibration = 0x93 
OCD Enable.............................. [ ]
JTAG Enable............................. [X]
Enable Serial (ICSP) Programming........ [X]
Watchdog Timer Always On................ [ ]
Preserve EEPROM through chip erase...... [ ]
Boot into bootloader.................... [ ]
Divide clock by 8....................... [X]
Clock output............................ [ ]
Bootloader size: 8192 bytes.
Start-up time: SUT0: [X]  SUT1: [ ] (see datasheet)
Clock source: calibrated internal oscillator.
Brownout detection at: disabled.

on an other Topic (HERE I found the hint to change the low fuse from 0x62 to 0xE2 with hex uploader. BUT: When I start the sketch it says: "Attempting to enter programming mode ..." and nothing more... It's now running for 3 Minutes and no new output.

Can some please point me into the right direction or help to be able to burn the bootloader?

Thank you, Moritz

One more: When try to burn bootloader this ist the output:

Atmega chip programmer.
Written by Nick Gammon.
Version 1.28
Compiled on Jan 15 2015 at 22:36:19
Attempting to enter programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x97 0x03 
Processor = ATmega1280
Flash memory size = 131072 bytes.
LFuse = 0x62 
HFuse = 0x99 
EFuse = 0xFF 
Lock byte = 0xFF 
Clock calibration = 0x93 
Bootloader address = 0x1FC00
Bootloader length = 504 bytes.
Type 'Q' to quit, 'V' to verify, or 'G' to program the chip with the bootloader ...
Clearing 'Divide clock by 8' fuse bit.
Fixing low fuse setting ...
Attempting to enter programming mode ...

After this there is again no more output...

5V, 16 MHz external oscillator? Those fuses don't look right. Here's what I use. low_fuses=0xf7 high_fuses=0xde extended_fuses=0xfd

I have not had any problems with Nicks procedure, also use those as Crossroads mentioned.

Try connecting D9 from the programming board to the XTAL1 pin of the Atmega1284p.

CrossRoads: 5V, 16 MHz external oscillator? Those fuses don't look right. Here's what I use. low_fuses=0xf7 high_fuses=0xde extended_fuses=0xfd

Yes, running it on 5V and Resonatoren @16MHZ (CSTCE16M0V53-R0, Murata Electronics). I'm confused about the fuses too. They are def. wrong... [quote author=Nick Gammon date=1421364266 link=msg=2044924] Try connecting D9 from the programming board to the XTAL1 pin of the Atmega1284p. [/quote] That's hard caause it's fully SMD. The Atmega1284 is a TQFP-44. But I'll try tomorrow to solder a small Wire to the pin directly. What shall I do after this? Just start the Burn Bootloader oder Fuse Calculator again or Hex Uploader to set fuses?

Thank you for your help!

Doesn't it go to a crystal pin you can reach? If the fuses are changed to expect a clock, then a clock you must provide. The crystal/resonator should provide one, if you have them in the circuit.

I can reach the pin of the chip itself. It's tiny, but doable. The Resonator I have. I can't check if it's working corectly (no Osciloskope), but I hope so... I just wondered what to do after connecting D9 of my Nano (running your Sketches)? I found this sketch

void setup ()
  {
  // set up 8 MHz timer on pin 9
  pinMode (9, OUTPUT); 
  // set up Timer 1
  TCCR1A = _BV (COM1A0);  // toggle OC1A on Compare Match
  TCCR1B = _BV(WGM12) | _BV(CS10);   // CTC, no prescaling
  OCR1A =  0;       // output every cycle
  }
  
void loop () {}

to provide external 8mHz but missed "Alternate clock source" at the Bootloader description on your side. Ok, I'll try in the morning to solder a wire to XTAL1, connect it to D9 and then burn bootloader again. THX Nick.

Allright: I unsoldered the Resonator and soldered a wire to the pad, connected to D9 of programming Nano. I tried the Burn Bootloader sketch, this is the output:

Attempting to enter programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x97 0x05 
Processor = ATmega1284P
Flash memory size = 131072 bytes.
LFuse = 0xFF 
HFuse = 0x99 
EFuse = 0xFF 
Lock byte = 0xFF 
Clock calibration = 0x55 
Bootloader address = 0x1FC00
Bootloader length = 508 bytes.
Type 'Q' to quit, 'V' to verify, or 'G' to program the chip with the bootloader ...
Erasing chip ...
Writing bootloader ...
Committing page starting at 0x1FC00
Committing page starting at 0x1FD00
Written.
Verifying ...
No errors found.
Writing fuses ...
LFuse = 0xFF 
HFuse = 0xDE 
EFuse = 0xFD 
Lock byte = 0xEF 
Clock calibration = 0x55 
Done.
Programming mode off.

After this I pressed "C" and got

Attempting to enter programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x97 0x05 
Processor = ATmega1284P
Flash memory size = 131072 bytes.
LFuse = 0xFF 
HFuse = 0xDE 
EFuse = 0xFD 
Lock byte = 0xEF 
Clock calibration = 0x55 
Bootloader address = 0x1FC00
Bootloader length = 508 bytes.

Looks good so far. Can I try to solder a Crystal 16Mhz and 2 22pf Caps to the SMD pads from resonator and use chip normal?

Looks like it.

Hi Nick, i tried to Solder crystal and caps and then upload a sketch, didn’t work. I got out of sync errors all the time and also couldn’t enter programing mode again. Maybe the Crystal and caps aren’t soldered good enough.the pads and space is not that much…
Is there a way to use your tool and set it to 8mhz internal crystal? Would be enough for the moment and I can restart then with new layout and crystal instead of resonators.
I didn’t try to upload sketch from SD yet or use the nano to upload with programmer.
Shall I maybe send you the circuits to verifie other errors?

EDIT
Ok, with Board Detector Sketch I checked fuses again an they are set:

Signature = 1E 97 05 
Processor = ATmega1284P
Flash memory size = 131072 bytes.
LFuse = FF 
HFuse = DE 
EFuse = FD 
Lock byte = EF 
Clock calibration = 55 
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 1024 bytes starting at 1FC00

I checked these settings with http://www.engbedded.com/fusecalc and it says:

Ext. Crystal Osc.; Frequency 8.0- MHz; Start-up time: 16K CK + 65 ms; [CKSEL=1111 SUT=11]

Maybe it is possible to flash bootloader with LFuse F7 (hint by CrossRoads) which is

Full Swing Oscillator; Start-up time: 16K CK + 65 ms; Crystal Osc.; slowly rising power; [CKSEL=0111 SUT=11]

or “E2” which should be

Int. RC Osc.; Start-up time: 6 CK + 65 ms; [CKSEL=0010 SUT=10]

???
At Atmega_Board_Programmer.ino Line 325 I found 0xFF,        // fuse low byte: external clock, max start-up time is this the setting while burning bootloader and possible to change fuses there?

Thx again :wink:

The https://github.com/nickgammon/arduino_sketches/tree/master/Atmega_Hex_Uploader sketch lets you change fuses (you don't need the SD card for that).

You can change the fuse to use the internal clock, but the bootloader expects to run at 16 MHz not 8 MHz.

Hi, with the hex uploader sketch i can't change fuses. Even with D9 connected i can't enter programming mode. So i tried to change fuses to F7 and burn bootloader sketch . This worked and I can programm the 1284p with arduino as ISP. (Even with bad soldered crystal as said before.) I'm so happy. :D No I just have to get 2 other boards to work with these settings and resonator or internal Clock.

Nick: Thank you so much for your tool and thank you CrossRoads for the hint with the LFuse setting!

Maybe make a new entry in boards.txt file that has low fuse set to F7, call it 1284FullSwing.

Hi, Nick, I'm sry but I have to come back to you and ask for help: Within the Atmega_Board_Programmer Sketch you have the file bootloader_atmega1284.h which is the bootloader at 16mhz (if I got everything right). I want to burn a bootloader with 8mhz and internal clock. So I thought I can use the one providet by maniacbug, which is also based on optiboot. The file at ATmegaBOOT_1284P_8MHz.hex is the right one (tested with standalone one Breatboard), But I need to convert it to same format as you use. My knowledge of low level programming isn't good enough to do this, so I kindly ask for help doing this or information to do this by my own.

Greetings

The techniques for making a new bootloader include file are described in my post. Please state which part you are having difficulties with.

It is so frustrating... I got everything working. Burning Bootloaders, changeing fuses, even write a hole new bootloader with Nicks script it worked. But now I ordered 20 new Atmega1284P-AU and I can't upload sketches after burning Bootloaders. I checkted the chips, where the diffrens is and I found just one line:

Clock calibration = 0x99

The new Chips are Clock calibration = 0x58 The full output is:

Atmega chip programmer.
Written by Nick Gammon.
Version 1.28
Compiled on Apr 10 2015 at 17:11:50
Attempting to enter programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x97 0x05 
Processor = ATmega1284P
Flash memory size = 131072 bytes.
LFuse = 0xF7 
HFuse = 0xDE 
EFuse = 0xFD 
Lock byte = 0xEF 
Clock calibration = 0x58 
Bootloader address = 0x1FC00
Bootloader length = 1024 bytes.
Type 'Q' to quit, 'V' to verify, or 'G' to program the chip with the bootloader ...
Verifying ...
No errors found.
Done.
Programming mode off.
Type 'C' when ready to continue with another chip ...

Now the question again: how to recalibrate the Clock or how to fet the low fuse?

If nothing helps: I go back to wooden Trains and play with them. :P

Edit: The working chip has calibration 0x58. Not working chips have 0x8C or 0x99. If I try a brand new chip without any Crystal it has 0xC4 or 0x93 (XTAL by Nano on Pin 9)...

The clock calibration shouldn't matter when you're using an external crystal. And you can't change it, but you can write a different value to the oscillator calibration register (OSCCAL) at runtime. (the chip loads the factory-programmed calibration value into OSCCAL at reset, but you can replace it with another value later. Which shouldn't make any difference when using an external crystal, either.)

Ok, thanks. I expacted every chip and series has it’s own fixed values. But finding to chips from same serie with diffrent values confused me. Specially because it is the only diffrence and one chip i was able to programm, the other not… But then the problem has to be something else and I continue searching why this is…

Ok, just to confirm (because I often forget this): Nick's Script is working pretty good, even to good. The Ground lines from the programming ports are not connected. In Eagle Cad one is GND, the other GRD... Pretty stupid but even with this mistake I was able to flash the chip and burn a bootloader but not able to upload Sketches. By connecting 2 AirWires I was able to fix it and upload sketches. THX again for help and pointing into right direction.

By connecting 2 AirWires I was able to fix it and upload sketches.

Rather than saying this, why not say you left pins unconnected? Then new people will know what you are talking about.

.