2560 R3 Aatmega 16 firmware

Hi everyone, I'm in the process of building a 3D printer which uses the Arduino 2560 R3 as the heart of the electronics. I have the hardware completed and I have finished the PCB layout. This circuit just combines the 2 commonly used board assemblies into one. The 2560 R3 uses 2 microcontrollers the ATmega 2560 and ATmega 16U. The 2560 is the main controller which uses the marlin code so I'm assuming the 16U is just acting as a USB interface. If this is true there must be some firmware for this device but I don't see any mention of it online anywhere. Is the atmega 16 just using the bootloader? Also do these two devices use the same bootloader? I'm kind of stuck since I don't want to have the boards made until I can figure this out. Any help is greatly appreciated. Thanks

Is the atmega 16 just using the bootloader?

No, the 16U2 rarely uses the bootloader. The bootloader is for re-flashing the USB interface which you virtually never need to do. The 16U2 uses the "main" code, which does the serial interface.

Also do these two devices use the same bootloader?

No, they are different chips for one thing. The 2560 needs a bootloader to upload new sketches, which you do often.

I don't want to have the boards made until I can figure this out.

Make sure you put ICSP headers on for both chips, then you can always reprogram them, and correct fuse settings.

Once you have an ICSP header you can use my bootloader programmer to install both bootloaders. I think the one for the 16U2 is the same as on the Uno chip.

I'm assuming the 16U is just acting as a USB interface. If this is true there must be some firmware for this device but I don't see any mention of it online anywhere.

Yes, naturally, or there would be no point having it there. I'm not sure which file it is in the "bootloaders" part of the download, it might be:

Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex

However that has Uno in the name. There is another file there called:

Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex

That is probably the one for the 16U2 on the Mega. I found that in:

/home/nick/Development/arduino-1.6.4/hardware/arduino/avr/firmwares/atmegaxxu2

The two files are virtually identical. If you installed the one from my bootloader installer probably the only issue would be that it would identify as a "Uno" on the list of serial ports.


Again, I emphasise to put on your board ICSP headers for both chips. They are virtually impossible to remove later, and that will make programming them easier once the board is assembled.

Sigh.

I am astounded and disappointed that, 3 years after my first post here, there is still no official description of how to re-initialize the Mega, including the 16U2. The closest thing is the README.txt here. Here is another thread describing the process. This is fairly obscure, especially for newbies. And if Nick Gammon isn't sure... :o

I was able to figure it out, but this obviously continues to be an issue. Yes, my board was an official Arduino board, purchased from Digi-Key, and it was basically empty. Yes, I understand the OP is building his own board.

BTW, the file I uploaded was

    Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex

...in the atmegaxxu2 subdirectory, not the COMBINED file. According to this, the COMBINED version includes DFU support, which is used when you want the reprogram the 16U2 over USB. Not really needed if you use an ISP and you have the ICSP headers for the 16U2.

YMMV.

The combined version would have the 16U2 bootloader, which does no particular harm. It means you can reflash it with a DFU uploader. However once you have the correct code on the chip you probably never need to.

there is still no official description of how to re-initialize the Mega, including the 16U2

There shouldn't need to be since those boards come with it flashed, and I've never personally needed to re-do the code, except as a tutorial. Still, it wouldn't hurt for it to be better documented, as in:

Arduino Uno Rev 3 has XXX on the Atmega328P and YYY on the Atmega16U2, as shipped.

Thanks for the info. This will help I'm sure. Just to be clear, I will be using new never before programmed chips so they will need to have the bootloaders installed. I am using the Arduino IDE which allows me to burn the bootloader for the 2560 but not the 16U, I'm not sure why. Anyway I bought an Arduino ISP just for the 16U, I just need to figure out how to get it done.

The Arduino IDE cannot (on its own) burn bootloaders because you need the SPI interface. A second Arduino can help (see Arduino as ISP), a stand-alone device, or use my sketch which has the bootloaders burned into its program memory. In all cases though, you need separate hardware, even if it is just another Arduino.