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?
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:
(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.
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.
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
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
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.
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?
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.
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.