Trouble Adding Bootloader to Custom Clone

Ok, so I'll start with the hardware that I'm using, how I've gone about it, then go on from there...

Hardware/Software:

  • Mac OS Catalina 10.15.4
  • Arduino 1.8.10
  • (2) Arduino Uno Rev3
  • (1) Elegoo Mega 2560 Rev3
  • (1) Custom board - based on the Mega 2560 (the board retains the ICSP pins near the 16u2 chip but the other ICSP pins and pins D50, D51, D52, D53)
  • (1) LC Technology USBasp V3

After many attempts to use one of the Unos to upload a bootloader to the custom board I decided to take a step back and try burning a bootloader to one of the other arduinos to verify that I am using the right process...

Setup 1
Using an Uno as an ISP to a target Uno

  • Jumpers connected to ICSP pins near the 328P chip on transmitting Uno (except for reset pin, which is connected to D10) to ICSP pins near the 328P chip on target Uno
  • Board: "Arduino Uno"
  • Port: "/dev/cu.usbmodem14201 (Arduino Uno)"
  • Programmer: "Arduino as ISP"
  • Burn Bootloader

This works fine.

Setup 2
Using an Uno as a ISP to a target Mega:

  • Jumpers connected to ICSP pins near the 328P chip on transmitting Uno (except for reset pin, which is connected to D10) to ICSP pins near the 2560 chip on target Uno
  • Board: "Arduino Mega or Mega 2560"
  • Processor: "ATmega 2560 (Mega 2560)"
  • Port: "/dev/cu.usbmodem14201 (Arduino Uno)"
  • Programmer: "Arduino as ISP"
  • Burn Bootloader

Again, Uno to Mega works fine.

Now returning to my original problem.

Setup 3
Using an Uno as a ISP to a target Mega (Custom clone):

  • Jumpers connected to ICSP pins near the 328P chip on transmitting Uno (except for reset pin, which is connected to D10) to ICSP pins near the 16u2 chip on target Uno
  • Board: "Arduino Mega or Mega 2560"
  • Processor: "ATmega 2560 (Mega 2560)"
  • Port: "/dev/cu.usbmodem14201 (Arduino Uno)"
  • Programmer: "Arduino as ISP"
  • Burn Bootloader

Which returns this:

/Users/------/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/Users/------/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -patmega2560 -cstk500v1 -P/dev/cu.usbmodem14201 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m 

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

         System wide configuration file is "/Users/------/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
         User configuration file is "/Users/------/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbmodem14201
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         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    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  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

Error while burning bootloader.
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9489 (probably m16u2)
avrdude: Expected signature for ATmega2560 is 1E 98 01
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

Troubleshooting:

  • The board is on
  • All signals from the ICSP pins make it to the proper location on the 2560 chip
  • The jumpers are correctly connected
  • Using the other set of ICSP pins on the Uno results in an error
  • Using the Uno's digital pins instead of the ICSP pins results in an error

To me, it seems as though the program knows that the board is connected and that it is attached to the ICSP pins that feed directly into the 16u2 chip. So:

  • Is there any way to program the board through the ICSP pins connected to the 16u2 chip?
  • Is there something that I might've missed that has resulted in these errors?

My apologies if I haven't properly formatted any of this (first post and all).
Any and all help is greatly appreciated. Thank you.

The ICSP pins connected to the 16u2 are used to program the 16u2. You need to use the ICSP pins for the atmega2560 to burn the bootloader onto that chip.
I'm not personally familiar with programming the 16u2, as far as I know it is usually done from the command line using avrdude.

Is there some class out there that is having their students design an "Arduino Mega" compatible board as a final project, or something?

There have been an awful lot of questions recently - people having trouble getting bootloader/firmware installed on their "custom 2560 Board."

(so far, all of the questions have been quite reasonable)

@david_2018 do you know of any way of programming the 16u2 via using the Uno as an ISP so that I am able to plug the USB in and burn the bootloader that way or is that not possible?

I've tried using avrdude to program the 16u2 and this is what I receive:

avrdude -p/dev/cu.usbmodem14201 -cstk500v1 -U flash:w:Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m
avrdude: AVR Part "/dev/cu.usbmodem14201" not found.

Valid parts are:
  uc3a0512 = AT32UC3A0512
  c128     = AT90CAN128
  c32      = AT90CAN32
  c64      = AT90CAN64
  pwm2     = AT90PWM2
  pwm216   = AT90PWM216
  pwm2b    = AT90PWM2B
  pwm3     = AT90PWM3
  pwm316   = AT90PWM316
  pwm3b    = AT90PWM3B
  1200     = AT90S1200
  2313     = AT90S2313
  2333     = AT90S2333
  2343     = AT90S2343
  4414     = AT90S4414
  4433     = AT90S4433
  4434     = AT90S4434
  8515     = AT90S8515
  8535     = AT90S8535
  usb1286  = AT90USB1286
  usb1287  = AT90USB1287
  usb162   = AT90USB162
  usb646   = AT90USB646
  usb647   = AT90USB647
  usb82    = AT90USB82
  m103     = ATmega103
  m128     = ATmega128
  m1280    = ATmega1280
  m1281    = ATmega1281
  m1284    = ATmega1284
  m1284p   = ATmega1284P
  m1284rfr2 = ATmega1284RFR2
  m128rfa1 = ATmega128RFA1
  m128rfr2 = ATmega128RFR2
  m16      = ATmega16
  m161     = ATmega161
  m162     = ATmega162
  m163     = ATmega163
  m164p    = ATmega164P
  m168     = ATmega168
  m168p    = ATmega168P
  m168pb   = ATmega168PB
  m169     = ATmega169
  m16u2    = ATmega16U2
  m2560    = ATmega2560
  m2561    = ATmega2561
  m2564rfr2 = ATmega2564RFR2
  m256rfr2 = ATmega256RFR2
  m32      = ATmega32
  m324p    = ATmega324P
  m324pa   = ATmega324PA
  m325     = ATmega325
  m3250    = ATmega3250
  m328     = ATmega328
  m328p    = ATmega328P
  m329     = ATmega329
  m3290    = ATmega3290
  m3290p   = ATmega3290P
  m329p    = ATmega329P
  m32m1    = ATmega32M1
  m32u2    = ATmega32U2
  m32u4    = ATmega32U4
  m406     = ATMEGA406
  m48      = ATmega48
  m48p     = ATmega48P
  m48pb    = ATmega48PB
  m64      = ATmega64
  m640     = ATmega640
  m644     = ATmega644
  m644p    = ATmega644P
  m644rfr2 = ATmega644RFR2
  m645     = ATmega645
  m6450    = ATmega6450
  m649     = ATmega649
  m6490    = ATmega6490
  m64rfr2  = ATmega64RFR2
  m8       = ATmega8
  m8515    = ATmega8515
  m8535    = ATmega8535
  m88      = ATmega88
  m88p     = ATmega88P
  m88pb    = ATmega88PB
  m8u2     = ATmega8U2
  t10      = ATtiny10
  t11      = ATtiny11
  t12      = ATtiny12
  t13      = ATtiny13
  t15      = ATtiny15
  t1634    = ATtiny1634
  t20      = ATtiny20
  t2313    = ATtiny2313
  t24      = ATtiny24
  t25      = ATtiny25
  t26      = ATtiny26
  t261     = ATtiny261
  t28      = ATtiny28
  t4       = ATtiny4
  t40      = ATtiny40
  t4313    = ATtiny4313
  t43u     = ATtiny43u
  t44      = ATtiny44
  t45      = ATtiny45
  t461     = ATtiny461
  t5       = ATtiny5
  t84      = ATtiny84
  t85      = ATtiny85
  t861     = ATtiny861
  t88      = ATtiny88
  t9       = ATtiny9
  x128a1   = ATxmega128A1
  x128a1d  = ATxmega128A1revD
  x128a1u  = ATxmega128A1U
  x128a3   = ATxmega128A3
  x128a3u  = ATxmega128A3U
  x128a4   = ATxmega128A4
  x128a4u  = ATxmega128A4U
  x128b1   = ATxmega128B1
  x128b3   = ATxmega128B3
  x128c3   = ATxmega128C3
  x128d3   = ATxmega128D3
  x128d4   = ATxmega128D4
  x16a4    = ATxmega16A4
  x16a4u   = ATxmega16A4U
  x16c4    = ATxmega16C4
  x16d4    = ATxmega16D4
  x16e5    = ATxmega16E5
  x192a1   = ATxmega192A1
  x192a3   = ATxmega192A3
  x192a3u  = ATxmega192A3U
  x192c3   = ATxmega192C3
  x192d3   = ATxmega192D3
  x256a1   = ATxmega256A1
  x256a3   = ATxmega256A3
  x256a3b  = ATxmega256A3B
  x256a3bu = ATxmega256A3BU
  x256a3u  = ATxmega256A3U
  x256c3   = ATxmega256C3
  x256d3   = ATxmega256D3
  x32a4    = ATxmega32A4
  x32a4u   = ATxmega32A4U
  x32c4    = ATxmega32C4
  x32d4    = ATxmega32D4
  x32e5    = ATxmega32E5
  x384c3   = ATxmega384C3
  x384d3   = ATxmega384D3
  x64a1    = ATxmega64A1
  x64a1u   = ATxmega64A1U
  x64a3    = ATxmega64A3
  x64a3u   = ATxmega64A3U
  x64a4    = ATxmega64A4
  x64a4u   = ATxmega64A4U
  x64b1    = ATxmega64B1
  x64b3    = ATxmega64B3
  x64c3    = ATxmega64C3
  x64d3    = ATxmega64D3
  x64d4    = ATxmega64D4
  x8e5     = ATxmega8E5
  ucr2     = deprecated, use 'uc3a0512'

It seems as though it isn't finding the chip through avrdude as it does within the IDE. /dev/cu.usbmodem14201 is the location that the IDE gives me when I use the Uno as an ISP. Is there something that I'm missing here?

@kairos007

Please use the "report to moderator" with due regards to real issues.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

On a whim, I decided to change:

avrdude -p/dev/cu.usbmodem14201 -cstk500v1 -U flash:w:Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

to:

avrdude -p 0x14200000 -cstk500v1 -U flash:w:Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

which resulted in the new message:

avrdude: no programmer has been specified on the command line or the config file
         Specify a programmer using the -c option and try again

I assumed that -cstk500v1 was the programmer. Anyone have any idea on how I "specify a programmer" as I am completely lost.

Thank you.

Try it with -p m16u2
The programmer is stk500vi, which should not change. The -p parameter specified the part (chip type) you are programming.
That is what just worked on my board. Not sure of the fuse settings, I did not try writing those, but the lfuse, hfuse, and efuse match what is being read back.

By changing the 0x14200000 to m16u2, I again get:

avrdude: no programmer has been specified on the command line or the config file
         Specify a programmer using the -c option and try again

I suppose I should mention that just yesterday I updated to IDE 1.8.12 (although I was having this problem long before this), in case that may be pertinent information.

Thank you.

On a whim, I decided to change:

avrdude -p/dev/cu.usbmodem14201 -cstk500v1 -U flash:w:Arduino-COMBINED-dfu-usbserial-atmega16u2-

By changing the 0x14200000 to m16u2, I again get: [another error]

Stop doing things randomly “on a whim”, and read the documentation.
“-p” specifies the part number. Should be m16u2
“-P” specifies the comm port; probably “COM3” or “/dev/tty.usbmodem” or something.
“-c” specifies the programmer type “stk500v1” should work fine, IF you have the proper …
“-C” specifies the location of the config file containing all the information about parts, protocols, and programmers. It looks like you’ve been leaving this off. Since it’s not in a standard location, I think you MUST include it.