Use Arduino Mega 2560 as ISP to bootload Arduino Mega 2560

Hi

I've been using two Arduino Mega boards in a project for several weeks without problem. However, one of them is not longer recognized by the PC. When I connect the board to the USB port: 1) the PC does not make any sound (typical plugging sound) 2) the COM does not appear in the list of Device Manager 3) The option Port appears grey at the Arduino IDE. The board to program is not original, is SainSmart.

I've done some "Google" research and it looks that the firmware is corrupted and, the solution may be to reset the board through ISP from another arduino. Please, let me know if this could be the solution.

I follow this link to connect both Arduino Mega boards. Programming Arduino Mega using an Arduino Mega ICSP - Microcontrollers - Arduino Forum

See this connection with the following images:

I've done the following steps:
1-Make the connections as above
2-Connect the programmer board to PC through USB
3-Change program to "Arduino as ISP"
4-Select "Arduino ISP" code from Examples
5-Upload code
6-Burn bootloader

The following errors is shown:

Arduino: 1.8.8 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x70
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

Error while burning bootloader.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I'm doing the correct connections? I'm missing the right steps?

UPDATED: I've changed the cable 53 from the programmer board to the pin 10 (as many sources said) and, although I get the message "avrdude: stk500_recv(): programmer is not responding" again, the error windows does not appear in red. And, the programmed board blinks the L Led (pin 13). However, the USB from this board does not work when I connected to the PC (no beep, no COM, grayed PORT at Arduino IDE).

Is the problem with the USB port? Is it physical (doesn't look/smell burned)? Drivers?

Thanks

the firmware in the 8u2 used as USB chip could be corrupted. that has the ISCP header near the USB connector

How can I fix it?

REM14:
How can I fix it?

https://www.arduino.cc/en/Hacking/DFUProgramming8U2

REM14:
UPDATED: I've changed the cable 53 from the programmer board to the pin 10 (as many sources said)

As long as you're using the unmodified ArduinoISP sketch, pin 10 is correct. You can easily modify the sketch to use a different pin but there's probably no reason to do so in this situation.

pert:
As long as you're using the unmodified ArduinoISP sketch, pin 10 is correct. You can easily modify the sketch to use a different pin but there's probably no reason to do so in this situation.

Per, he wants to fix the USB, the firmware in 16u2. I don't like the page I linked. Doesn't some better approach exist?

I was only confirming the correct way to do Arduino as ISP, not so much saying that I think burning the bootloader to the ATmega2560 will solve the problem. That information might be useful for the ATmega16U2 firmware (unless the DFU method is used) or it might just be something useful to know for future reference.

Juraj:
I don't like the page I linked. Doesn't some better approach exist?

I've seen a lot of people struggle with updating the firmware on the ATmega16U2 and very few had success. I have never actually done this, and have not looked closely at the available resources, but it does seem like there may be a lack of good documentation of the process. My instinct would be to go with the ISP instead of messing with DFU and FLIP but I'm biased in that direction because I'm already very comfortable using ISP programmers and not at all with DFU.

Thanks @Pert and @Juraj.

@Perp, I've already tried the ISP solution but it didn't solve my problem. Or I didn't do it correctly. At least the programmed board blinks the 13 pin LED.

On the chip near the USB I can barely see "MEGA8U2" (I didn't buy that board by myself, so I don't know which one is). I've done:

  1. installed Flip 3.4.7 on Windows 10. The version of 20MB
  2. Put a wire between ground and reset (near the USB port)
  3. Open flip
  4. Select Atmega 8u2 (also tried Atmega16u2)
  5. Upload the hex "Arduino-usbserial-mega.hex" file from arduino-usbserial folder located within Arduino IDE files in C:
  6. Select USB communication.

However, I get this error:

"AtLibUsbDfu.dll not found"

Any clue?

I could fix the problem of the error message by installing Atmel Studio 7 including all the drivers it includes. However, in the FLIP software doesn't appear the communication Port. I attach image. It makes sense because the PC didn't detect the Arduino initially. That's why I'm trying to reinstall the firmware. The Arduino is Rev3. How can I install the firmware if it is not detected by the PC?

I've tried to put the board in DFU mode using this procedure:

https://www.wayneandlayne.com/blog/2011/02/16/fixing-linux-firmware-issues-on-arduino-mega-2560/

However, the COM doesn't appear. I don't know how to solve this problem with this specific board. MEGA2560 R3 Sainsmart Atmel16u2.

REM14:
I've tried to put the board in DFU mode using this procedure:

Fixing Linux firmware issues on Arduino Mega 2560 | Wayne and Layne

However, the COM doesn't appear. I don't know how to solve this problem with this specific board. MEGA2560 R3 Sainsmart Atmel16u2.

you must go over ISP over the ICSP header of the 16u2.

I updated an atmega16u2 on an Uno Clone using Linux Mint and IDE1.8.5.

$ locate atmegaxxu2

I then cd into:

cd /home/kprims/ken/Downloads/arduino-1.8.5/hardware/arduino/avr/firmwares/atmegaxxu2

Check out the README.txt

I used the avrdude command for the Uno v3 and changed it to this.You may have to use the avrdude with the arduino IDE. Something like this:

/home/kprims/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/bin/avrdude -C/home/kprims/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino14/etc/avrdude.conf -v -p atmega16u2  -cstk500v1 -P/dev/ttyACM0 -b19200 -U flash:w:Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

Notice I changed the -p atmega16u2 , the -c usbasp and the Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex
If you are using arduino as isp you would use -cstk500v1 -P/dev/ttyACM0 -b19200

avrdude -p atmega16u2 -P usb -c usbasp -U flash:w:Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9489 (probably m16u2)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed

@Juraj I've just checked on the chip near the USB which is written MEGA8U2. Can I use the guide you've provided me? When I did the bootloader command, sending the character G, nothing happens and, if I use the Bootloader function from the Arduino IDE, appearing errors.

Is there difference with the procedure between 16U2 and 8U2?

@kprims do you recommend me to use Linux instead of Windows? Can I do it with VM?

I could bootload succesfully (I think) by setting up the baudrate to 115200. Here the log:

I've tried to put the board to DFU mode by insert a wire between the two pins near the USB port. But, nothing happens. The 13 Led works because of the default blink sketch. I'm missing another step?

REM14:
I could bootload succesfully (I think) by setting up the baudrate to 115200. Here the log:

I've tried to put the board to DFU mode by insert a wire between the two pins near the USB port. But, nothing happens. The 13 Led works because of the default blink sketch. I'm missing another step?

you wrote a bootloader to 2560. that is not what you need.

@kprims do you recommend me to use Linux instead of Windows? Can I do it with VM?

You can do it with Windows. Load a sketch on your good Mega and copy the pertinent parts needed to use on the Command line and add the order from the README.txt using -p atmega8u2 -cstk500v1 -P/dev/ttyACM0 -b19200 if using "Arduino as ISP.

I would use "MEGA-dfu_and_usbserial_combined.hex" if the Mega had a MEGA8U2 chip.

To burn (Mega 2560):

avrdude -p atmega8u2  -c stk500v1 -P/dev/ttyACM0 -b19200 -U flash:w:MEGA-dfu_and_usbserial_combined.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

Something like this from the CMD Line ----Win 10 Avrdude Notice the " " " "
###############################################################
C:”\Program Files (x86)”\Arduino\hardware\tools\avr/bin/avrdude -C”C:\Program Files (x86)”\Arduino\hardware\tools\avr/etc/avrdude.conf -v -p atmega8u2 -c stk500v1 -P/dev/ttyACM0 -b19200 -U flash:w:MEGA-dfu_and_usbserial_combined.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m[/code]

Thanks @kprims. Which sketch I upload to the good board? How is going to detect the bad board the command from CMD if there is no COM associated? Please, could you give more details. Thank you

I've done the following:

  1. Connect Arduino boards as my first post
  2. Open Arduino IDE where the good board is in COM4.
  3. Configure good board as "Arduino as ISP" and upload the example code "ArduinoISP"
  4. Open cmd.exe and execute the following code:
C:"\Program Files (x86)"\Arduino\hardware\tools\avr\bin\avrdude -C"C:\Program Files (x86)"\Arduino\hardware\tools\avr\etc\avrdude.conf -v -p atmega8u2  -c stk500v1 -P\dev\ttyACM0 -b19200 -U flash:w:MEGA-dfu_and_usbserial_combined.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

But this error appears:

C:\>C:"\Program Files (x86)"\Arduino\hardware\tools\avr\bin\avrdude -C"C:\Program Files (x86)"\Arduino\hardware\tools\avr\etc\avrdude.conf -v -p atmega8u2  -c stk500v1 -P\dev\ttyACM0 -b19200 -U flash:w:MEGA-dfu_and_usbserial_combined.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf"

         Using Port                    : \dev\ttyACM0
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: ser_open(): can't open device "\dev\ttyACM0": The system cannot find the path specified.


avrdude done.  Thank you.

The port should be COM4? I'm missing a step?

don't connect the boards like on your pictures. you must connect to the ICSP header of the 8u2

@Juraj, I've connected the boards as you said. Using the ICSP from the good board and the AREF from the bad board. At least is shown in the picture.

And, executing the previous command through windows terminal, I get this message:

C:\>C:"\Program Files (x86)"\Arduino\hardware\tools\avr\bin\avrdude -C"C:\Program Files (x86)"\Arduino\hardware\tools\avr\etc\avrdude.conf -v -p atmega8u2  -c stk500v1 -PCOm4 -b19200 -U flash:w:MEGA-dfu_and_usbserial_combined.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf"

         Using Port                    : COm4
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega8U2
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC6
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no        512    4    128  9000  9000 0x00 0x00
           flash         65     6   128    0 yes      8192  128     64  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0xffffff (probably .avr8x_mega) (retrying)

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0xffffff (probably .avr8x_mega) (retrying)

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0xffffff (probably .avr8x_mega)
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

Why is it failing?