Atmega2560 as Arduino Programming issue [Solved]

Hello,

I have Atmega2560 and I am able to burn bootloader code into this chip. I have followed this document http://soc.ninja/documentation/programming-atmega2560-with-arduino-uno-or-mega

mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD8

mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD9

So I changed 0xD8 to 0xD9 and after that I was able to download first Blinky code into board using FTDI. But now I am not able to download any other code into board.

Is changing fuse bits 0xD8 to 0xD9 is not correct?

Regards, HallMark

That fuse setting is correct for Upload Using Programmer but it won't work for standard uploads. For standard uploads you need to leave it at 0xD8. This is a known issue: https://github.com/arduino/Arduino/issues/388 (try to separate the two different topics, Arduino As ISP vs. USBasp that the conversation split into)

Luckily the Arduino as ISP problem was solved by updating the AVRDUDE version the Arduino AVR Boards uses. If you use a recent version of Arduino AVR Boards then you should be able to use the stock fuse setting with the Arduino as ISP and be able to do Upload Using Programmer or Upload.

Keep in mind that when you do Sketch > Upload Using Programmer the bootloader is erased so you always need to do Tools > Burn Bootloader after doing an Upload Using Programmer if you want to be able to go back to regular uploads again.

pert: That fuse setting is correct for Upload Using Programmer but it won't work for standard uploads. For standard uploads you need to leave it at 0xD8. This is a known issue: https://github.com/arduino/Arduino/issues/388 (try to separate the two different topics, Arduino As ISP vs. USBasp that the conversation split into)

Luckily the Arduino as ISP problem was solved by updating the AVRDUDE version the Arduino AVR Boards uses. If you use a recent version of Arduino AVR Boards then you should be able to use the stock fuse setting with the Arduino as ISP and be able to do Upload Using Programmer or Upload.

Keep in mind that when you do Sketch > Upload Using Programmer the bootloader is erased so you always need to do Tools > Burn Bootloader after doing an Upload Using Programmer if you want to be able to go back to regular uploads again.

If I leave 0xD8 as it is then I am able to download code any number of times in chip using FTDI Cable but the same code is not running automatically when I do Power Off and On.

Which version of AVRDUDE are you using?

You can find this by: File > Preferences > Show verbose output during: upload (check) > OK Do an upload or Burn Bootloader

After the process completes, examine the contents of the black console window at the bottom of the Arduino IDE window. You will need to scroll up to see it all. After the AVRDUDE command you should see something like this:

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53

pert: Which version of AVRDUDE are you using?

You can find this by: File > Preferences > Show verbose output during: upload (check) > OK Do an upload or Burn Bootloader

After the process completes, examine the contents of the black console window at the bottom of the Arduino IDE window. You will need to scroll up to see it all. After the AVRDUDE command you should see something like this:

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53

Yes,

here is avrdude version

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53

I can’t reproduce the issue. Please try this:

  • Exit all instances of the Arduino IDE
  • Make sure you have mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD8 in boards.txt
  • Start the Arduino IDE
  • Connect the Arduino as ISP to your ATmega2560
  • Tools > Burn Bootloader
  • Upload a sketch using your FTDI
  • Power the board on and off to verify the code runs

Note that after you change the fuse settings in boards.txt you need to restart the IDE for the changes to be recognized (the IDE only scans boards.txt on startup or when you run Boards Manager). You also need to do a Burn Bootloader to set the fuses (they are only set during Burn Bootloader, it doesn’t happen with Upload or Upload Using Programmer).

I do experience a ridiculously long delay between power on and the program starting (~8 seconds) but the program does run. I suspect that delay is actually coded into the bootloader because when I program my ATmega2560 with the Optiboot bootloader it has a very short delay on power on.

Thank you Pert ! Let me follow your step and try that one out and update you.

Ok, I just followed above step

pert:
I can’t reproduce the issue. Please try this:

  • Exit all instances of the Arduino IDE
  • Make sure you have mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD8 in boards.txt
  • Start the Arduino IDE
  • Connect the Arduino as ISP to your ATmega2560
  • Tools > Burn Bootloader
  • Upload a sketch using your FTDI
  • Power the board on and off to verify the code runs

Ok, I just followed above step. Still same issue.
With 0xD8 – If I leave FTDI connected then only code runs. If I disconnect FTDI it is not running.

If 0xD8 is changed to 0xD9 then code runs fine with or without FTDI but No more sketch upload working.

pert:
I do experience a ridiculously long delay between power on and the program starting (~8 seconds) but the program does run. I suspect that delay is actually coded into the bootloader because when I program my ATmega2560 with the Optiboot bootloader it has a very short delay on power on.

If I load optiboot then I can still upload sketch fine with FTDI? what is the procedure for Optiboot?

It's actually a modified version of Optiboot with ATmega2560 support added: https://github.com/majekw/optiboot

You can get it from that repository or it's also available from the excellent MegaCore, which makes it super easy to install: https://github.com/MCUdude/MegaCore

pert: It's actually a modified version of Optiboot with ATmega2560 support added: https://github.com/majekw/optiboot

You can get it from that repository or it's also available from the excellent MegaCore, which makes it super easy to install: https://github.com/MCUdude/MegaCore

Ok, I will try that one. Any idea about issue with arduino bootloader way I am trying?

I'm stumped on the issue because I can't reproduce it. Are you using the latest version of the ArduinoISP sketch (File > Examples > 11.ArduinoISP > ArduinoISP)?

There are some other forum members much more knowledgeable than myself on this topic. Hopefully one of them will have some ideas.

pert:
I’m stumped on the issue because I can’t reproduce it. Are you using the latest version of the ArduinoISP sketch (File > Examples > 11.ArduinoISP > ArduinoISP)?

There are some other forum members much more knowledgeable than myself on this topic. Hopefully one of them will have some ideas.

Yes, I am using Arduino IDE 1.8.5 so latest arduinoISP example as well. :frowning:

pert: I'm stumped on the issue because I can't reproduce it. Are you using the latest version of the ArduinoISP sketch (File > Examples > 11.ArduinoISP > ArduinoISP)?

There are some other forum members much more knowledgeable than myself on this topic. Hopefully one of them will have some ideas.

Pert ! I figure it out. There was 10K Pull-down needed on RX Pin to exit from bootloader to run main program.

Glad you got it working! I've never needed to add something like that so I guess my FTDI breakout board has the necessary resistor.

Enjoy!