Go Down

Topic: Use Nano to flash Mega 2560 with Hex File on SD Card (Read 309 times) previous topic - next topic

marcel00

Hello,
 I could succesfully apply the ATmegaHexUploader from Nick Gammon in order to flash a Arduino Mega with a SD card module. However, it does not work with all Arduino Mega. So I used ATmegaselfreadSignature which is from Nick Gammon as well. I flashed the program to the Megas and I could see the following differences:
Fuses
1. LOW= FF  HIGH=D9 Ext= FD Lock= FF no bootlader used but installed. This works with SD card module
2. LOW = FF HIGH=D8 Ext= FD Lock= EF bootloader used. This doesn´t work and I get the error "Red x 3 = Cannot enter programming mode in target chip (Ch)"
On the other hand the Mega with working SD card module cannot be flashed via Arduino IDE. There I get AVR Dude  STK500 timeout.

Is it possible to adjust the fuse settings with an USB ISP Programmer like https://www.diamex.de/dxshop/USB-ISP-Programmer-fuer-Atmel-AVR-Rev2 and ATMEL Studio 7?

pert

I don't think it will provide any solution, but just to link information, it sounds like a variation of this issue:
https://github.com/arduino/Arduino/issues/388

marcel00

Hello pert

 thanks for the information. I see a relation to my issue regarding the setting of the high fuse from D8 to D9 as I could observe the same behaviour while trying to upload a sketch to the Mega. Is it possible to set the high fuse of the target Mega 2560 to D9 with the Arduino IDE in order to enable programming via SD card module.


pert

When you do a Tools > Burn Bootloader with the Arduino IDE, it actually does two things:
  • Set fuses according to the boards.txt definition for the board currently selected from the Tools > Board menu
  • Flash the bootloader to the microcontroller


So it is possible to set fuses via the Arduino IDE's Tools > Burn Bootloader. However, if the fuse configuration you want is not present in an existing board definition, you would need to either create your own custom board definition, or else modify an existing board definition (likely the "Arduino/Genuino Mega or Mega 2560" definition in this case"). If you only need to do this one time, it might actually be easier to just set the fuses from the command line using the avrdude tool the Arduino IDE uses for this purpose.

You will need an ISP programmer. I don't have any idea whether the one at the link you provided works with avrdude. My favorite AVR ISP programmer is the 6 pin USBasp, which you can buy on eBay for $2.15 w/ free shipping from China:
https://www.ebay.com/itm/271489740923
As you may have learned from the issue thread I linked to in my previous reply, the USBasp does have issues uploading to the ATmega2560 when using the stock USBasp firmware. That limitation is solved by updating the firmware to the 3rd party version produced by members of the Arduino community. Even with the old firmware, you can use the USBasp to set fuses or burn the bootloader on the ATmega2560, no problem. You can also use an extra Arduino board as an Arduino as ISP programmer:
https://www.arduino.cc/en/tutorial/arduinoISP


To make life easier, you can grab the avrdude command the Arduino IDE generates to set the fuses, modify it, and then run it from the command line:
File > Preferences
Check the box next to "Show verbose output during: upload".
Click the "OK" button.
Tools > Board > Arduino/Genuino Mega or Mega 2560
Tools > Programmer > select the appropriate programmer
Tools > Burn Bootloader

After the Burn Bootloader process finishes, scroll up the black console window at the bottom of the Arduino IDE window. There, you will find two avrdude commands. The one higher up in the output is the command to set the fuses. Copy and paste that command, modify it according to your preferences, then run it from the command line.

Go Up