How do I burn bootloader and sketch to ATMega16U2 in QFN32 package

I need to burn a bootloader to a ATMega16U2 in a VQFN32 package. then I need to burn a sketch to it. Can someone tell me how to do it? The project it will go in does not have ICSP output so I have to do it before soldering the chip into the circuit. I am also not sure how I am going to solder that thing in since QFN32 has pins under the chip where QLP32 has then sticking out but I did not design the board or project.

Thank you.

VQFN sockets exist, and can be had from professional electronics supply houses, at eye-watering prices. (Farnell lists them in the 80-100 dollar range, for a socket, no PCB). They're priced for professional use, not hobbyists.

Is it expected that you'll use DFU to program them? Is the DFU pin broken out? (I would never design a board for an AVR without breaking out the ICSP pins - I did it a few times, and regretted it every one of them)

You solder a (V)QFN with hot air and solder paste. If the device doesn't have a ground pad in the middle, or if it has a pad, but the board was designed with a through-hole in the middle of the ground patch for this purpose, you can solder the ground patch (if present) with an iron from the bottom and then use drag soldering with flux on the pins - if the board was designed for hand assembly, the pads are often made longer than otherwise necessary, so that you can drag solder them more easily (because the copper pad conducts heat, helping you to heat up the pin and pad where they join with an iron), but it's still quite hard. Ideally, you would use solder paste, a stencil, and a reflow oven to solder these.

However, there's another problem - as far as I'm aware, there's no arduino core that supports writing a sketch for the atmega16u2... It's also not clear to me which bootloader you intend to write to it.

My first reaction is that you've picked up a project with some serious issues....

Here's the hardware package to add support to the Arduino IDE for ATmega16U2:

May be you can use an adapter like this , solder the chip, program it using the ICSP pins (also need to attach a crystal and caps), then remove it and solder it again at its permanent position.

Watcher:
May be you can use an adapter like this , solder the chip, program it using the ICSP pins (also need to attach a crystal and caps), then remove it and solder it again at its permanent position.

I actually have some of those QFN32 to dip adapters but my problem is getting the ATMega16U2 soldered down to the adapter since the pins are underneath the chip rather than sticking out from the chip so I could not drag solder it. Then the second problem would be getting the chip removed from that adapter/carrier without destroying it!

DrAzzy:
VQFN sockets exist, and can be had from professional electronics supply houses, at eye-watering prices. (Farnell lists them in the 80-100 dollar range, for a socket, no PCB). They're priced for professional use, not hobbyists.

I actually have one that I bought from some ebay seller. The problem is that they only made the adapter with 21 pins that mate with the chip itself and not all 32! And now the seller is refusing to make good on it claiming there is nothing wrong with it.

DrAzzy:
Is it expected that you'll use DFU to program them? Is the DFU pin broken out? (I would never design a board for an AVR without breaking out the ICSP pins - I did it a few times, and regretted it every one of them)

No, the DFU pins were not broken out so it has to be programmed before being soldered down.

DrAzzy:
You solder a (V)QFN with hot air and solder paste. If the device doesn't have a ground pad in the middle, or if it has a pad, but the board was designed with a through-hole in the middle of the ground patch for this purpose, you can solder the ground patch (if present) with an iron from the bottom and then use drag soldering with flux on the pins - if the board was designed for hand assembly, the pads are often made longer than otherwise necessary, so that you can drag solder them more easily (because the copper pad conducts heat, helping you to heat up the pin and pad where they join with an iron), but it's still quite hard. Ideally, you would use solder paste, a stencil, and a reflow oven to solder these.

How do you drag solder a chip that has the pins all underneath the chip?

DrAzzy:
However, there's another problem - as far as I'm aware, there's no arduino core that supports writing a sketch for the atmega16u2... It's also not clear to me which bootloader you intend to write to it.

I found a bootloader or two but I am not sure how to upload that bootloader and then upload a different sketch (see my question below about that).

DrAzzy:
My first reaction is that you've picked up a project with some serious issues....

The original run of boards was done by the designer and he used QLP32 chips and programmed them. This second run was made by someone else and instead of buying QLP32 footprint ATMega16U2's he bought the VQFN32 package with the pins all underneath (pronounced inaccessible). And no, ICSP pins were not brought out. And that seller does not know how to program them so I am on my own!

I had found a bootloader but am again running into a noobie question of how to program that chip. I ask that basic question on another forum here but the answer I keep getting is that I can burn the bootloader (using AVR ISP) but if I try to upload the sketch for the actual program then it erases the bootloader and that seems counter intuitive to me since I thought the bootloader went into protected space.

How do I upload a sketch to an AVR (ATMega328P or this ATMega16U2) that already has the bootloader on it or that I have just finished burning the bootloader?

Thank you.

Those QFNs that Atmels come in can be hand soldered, but if you have not done it before you may well waste quite a few before you get it right. I have soldered one of the QFN44 ATmega1284s, it went OK.

However if you dont have the experience then it would be an idea to pay someone else to solder them, unless its not important that the project is long term reliable.

srnet:
Those QFNs that Atmels come in can be hand soldered, but if you have not done it before you may well waste quite a few before you get it right. I have soldered one of the QFN44 ATmega1284s, it went OK.

How did you solder it? Did you use solder paste and a heat gun or did you use a toaster oven?

I am not scared of soldering smt but the fact that all the pins are under the chip and do not come out to solder is new territory for me. I did just order a couple of the ATMega16U2's from Digikey that are QLF32 as the board was apparently laid out for either and in fact the designer used the QLF package in his first run.

Southerner:
How did you solder it? Did you use solder paste and a heat gun.

solder paste and a heat gun

There must be zillions of online tutorials ...........................

Southerner:
I had found a bootloader but am again running into a noobie question of how to program that chip. I ask that basic question on another forum here but the answer I keep getting is that I can burn the bootloader (using AVR ISP) but if I try to upload the sketch for the actual program then it erases the bootloader and that seems counter intuitive to me since I thought the bootloader went into protected space.

As explained in the other thread, it overwrites the boot loader when you program the sketch via ICSP.

Southerner:
How do I upload a sketch to an AVR (ATMega328P or this ATMega16U2) that already has the bootloader on it or that I have just finished burning the bootloader?

As explained in the other thread, use USB.

Southerner's first post in the other thread: Upload Sketch using ISP - Is possible ? - #36 by Southerner - Microcontrollers - Arduino Forum