Burned Bootloader onto MCU & Updated Firmware on USB - Still Not Working?

Hello,

I essentially built my own ATMega2560 board with a blank ATMEGA2560-16AUR as the MCU and a blank ATMEGA16U2-MUR as the USB-MCU interface.

I managed to upload the bootloader onto the MCU using an UNO as an ISP. This worked well. I am able to upload code onto the MCU as long as I keep the UNO connected to the MCU's SPI ports and "Upload as Programmer".

Then, I flashed "Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex" onto the ATMEGA16U2 using Flip and I believe this worked because whenever I plug in my board, the USB name says ATMEGA2560. The issue is whenever I try to upload code through the ATMEGA16U2, I get timeout errors. I made sure that the board is Arduino MEGA2560, Port is Arduino MEGA2560, and Programmer is AVRISP mkII.

Am I missing a step?

Is the bootloader still there? Uploading sketch via ISP overwrites the botloader.
Another thing is USB/serial transceiver based on ATmega16U2. Try the loop-back test: connect Rx with Tx and with any terminal APP any typing must be received.

Budvar10:
Is the bootloader still there? Uploading sketch via ISP overwrites the botloader.
Another thing is USB/serial transceiver based on ATmega16U2. Try the loop-back test: connect Rx with Tx and with any terminal APP any typing must be received.

So what I did was:

  1. Burn bootloader via Arduino as ISP
  2. Upload sketch via Arduino as ISP
  3. Flash .hex to my MEGA16U
  4. Upload sketch via MEGA16U -> timeout errors

Due to Step 2, I overwrote the bootloader and made my MEGA16U unable to upload a sketch?
So instead, I should skip step 2 and try again?

Edit: I did Step 1, 3, 4. I still get timeout errors. Did I upload the wrong hex file to my ATMEGA16U?

Due to Step 2, I overwrote the bootloader and made my MEGA16U unable to upload a sketch?

Yes. I am writing about ATMega2560. Uploading sketch via ISP overwrites/erase the botloader.

Budvar10:
Yes. I am writing about ATMega2560. Uploading sketch via ISP overwrites/erase the botloader.

I did Step 1, 3, 4 and I still get timeout errors.
I did the loopback test and succeeded. This tells me that the ATMEGA16U was flashed properly?
Is there a chance I used the incorrect .hex file?

I did the loopback test and succeeded. This tells me that the ATMEGA16U was flashed properly?

Exactly. The 16U2 is just USB/serial transceiver between PC and ATmega2560. If the loopback test works the this part should be OK.

Budvar10:
Exactly. The 16U2 is just USB/serial transceiver between PC and ATmega2560. If the loopback test works the this part should be OK.

So my problem is with uploading the bootloader.
I followed this tutorial to upload thebootloader -> http://soc.ninja/documentation/programming-atmega2560-with-arduino-uno-or-mega/

What am I doing wrong?

Muhmmbles:
So my problem is with uploading the bootloader.
I followed this tutorial to upload thebootloader -> http://soc.ninja/documentation/programming-atmega2560-with-arduino-uno-or-mega/

What am I doing wrong?

This step here overwrites the bootloader with whatever sketch you are uploading. You'll need to upoad the bootloader again.

Muhmmbles:
2. Upload sketch via Arduino as ISP

@BJHenry
He wrote: "I did Step 1, 3, 4. I still get timeout errors. Did I upload the wrong hex file to my ATMEGA16U?" so I'll suppose that the bootloader is loaded.

You should check reset signal also - use LED or DMM. Post the schematics or picture.
On standar Arduino you can observe uploading process on L, Rx and TX LEDs, except of reset signal but it is easy to add LED for reset signal check (or DMM).
The RESET is normally tied to VCC. Reset signal should be visible. Reset signal cause that the MCU start bootloader code.
Standard bootloader blinks with L 3x at its beginning. Next the prompt for uploading follows - Rx blinks 3x significantly and if everything is OK, the uploading starts at this point.
Small recap what is needed:

  1. HW - minimal circuit: USB/serial transceiver (ATmega16U2), reset circuit, main MCU (ATmega2560) with decoupling
  2. bootloaded ATmega2560
  3. ATmega16U2 with loaded FW

Budvar10:
@BJHenry
He wrote: "I did Step 1, 3, 4. I still get timeout errors. Did I upload the wrong hex file to my ATMEGA16U?" so I'll suppose that the bootloader is loaded.

Sorry, my brain automatically filled in the '2'.

Budvar10:
Post the schematics or picture.

I have added a schematic of my MCU to the top post. As you can see, it's already connected to a bunch of other things and at the moment, I do not have the ability to remove it from those. If you look to the left, you'll see J4 which represents headers so I can connect to the SPI ports. This is how I'm uploading the bootloader. I am not sure why the bootloader is not uploading properly since I am able to upload sketches onto it using this method.

Budvar10:
Reset signal cause that the MCU start bootloader code.
Standard bootloader blinks with L 3x at its beginning. Next the prompt for uploading follows - Rx blinks 3x significantly and if everything is OK, the uploading starts at this point.

Sorry I did not understand this part. When I upload the bootloader, the Arduino compiler says it uploaded correctly.

Budvar10:

  1. HW - minimal circuit: USB/serial transceiver (ATmega16U2), reset circuit, main MCU (ATmega2560) with decoupling.

Where does it require decoupling? If you look at the schematic, I have a 0.1uF capacitor between Vcc and GND, as well as Aref and GND.

Budvar10:
3. ATmega16U2 with loaded FW

I believe the firmware is uploaded onto the ATMEGA16U correctly as I did the loopback test and succeeded. Now the issue is getting the bootloader to upload.