DIY ArduinoUnoR3 - Issues about DFU&Bootloader for both Atmega328p and 16u2

Dear Guys,
I am cloning a ArduinoUnoR3 right now and I ran into countless issues while figuring out the non-hardware part.
First, post a picture of the hardware that I am working on:

  1. Windows7 64bits
  2. STK500v2(I changed the file in Arduino to ISP500v2) http://www.sparkfun.com/products/8702
  3. ArduinoUnoR3 and my self-built one.
    http://www.facebook.com/photo.php?fbid=321806281246148&set=a.171059546320823.39936.100002503371305&type=1&theater

Progress:

  1. I soldered all the parts, no bridge no open circuit.(checked for a long time)
  2. I replaceed the blank atmega328 with a pre-programmed one (I pulled the one from a working arduino-uno), and it blinked while powered by the USB which means that basically related circuits work all right.
  3. I used Flip 3.4.5 to upload the hex file to the atmega16u2
  4. I used ArduinoIDE to burn the bootloader using ISP to the atmega328.

Problem:

  1. After all of that, I still can’t upload code to my own arduino and
    it said “avrdude: stk500_getsync(): not in sync: resp=0x00” in ArduinoIDE 1.0
  2. I tried to use AVR studio6.0 and i can’t find the atmega328 in the device list, why?

This is my first time posting question here in Arduino and let me know if I did anything wrong.
Appreciate any help. 8)

Updated:
Right now, I figured out how to use AVR studio 6 to upload hex file to the Flash or EEPROM of atmega328p and atmega16u2.
Since there are so many files in the hardware folder of Arduino. I really got confused. If any of you has done this before, could you please help me fill in the question below:

A-Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3
B-Arduino-usbserial-atmega16u2-Uno-Rev3
C-Arduino-usbserial-uno
D-UNO-dfu_and_usbserial_combined
E-ATmegaBOOT
F-ATmegaBOOT_168_atmega328
G-ATmegaBOOT_168_atmega328_bt
H-optiboot_atmega328

I - FLASH
II - EEPROM

I should upload ____ to the ____ of Atmega16u2, after that upload _____ to the _____ of Atmega328p.

thanks a lot!

Hi Guys,
It is such a pain of ass going through this, it just feels like my clone will never work. When I upload the blink to the board. The tx and rx do blink but the pin13 never behave as expected. Oh, what should I do.
Can anyone give me some resources to get started with the knowledge of bootloader.. so that I can study from the bottom.
Thanks a lot.

Is the board recognized by the computer?

Is the board presented to the computer as a serial port?

Does the board pass a loop-back test…
http://arduino.cc/forum/index.php/topic,73748.0.html

If “yes” is the answer to all questions then you are finished with the ATmega16u2.

Dear ..Coding Badly:
Appreciate your reply.
Right now, I have three ArduinoUnoR3 in my hand. One that is working perfectly, one that I screwed up by burning bootloaders and another one that I made by myself, of course doesn't work.
Here is what I have done.

Is the board recognized by the computer?
Yes.
The one that I screwed up was recognized as the Arduino Uno R3 in the device manager. COM7
The one that I made by myself is recognized as Serial Communication. COM5
(I don't know why they are different, but I use the file in ArduinoIDE as the install driver)

Is the board presented to the computer as a serial port?
Yes, they are, as what I mentioned in your first question.

Does the board pass a loop-back test...

Yes, all of these three pass the loop-back test perfectly.
More questions about your loopback test, why do you hold reset and ground all together? I read from the datasheet that "A low level on this pin for longer than the minimum pulse length will generate a Reset, even if the clock is not running.", does that mean you want to reset the chip once and then guarantee that no other reset will be triggered or ..reset the chip all the time? btw, that is a interesting test.

If "yes" is the answer to all questions then you are finished with the ATmega16u2.
Based on your instructions, I think I am done with ATmega16u2, but..why can't I still use USB to burn the code to my arduino.

Progress:
I use AVRstudio to read the hex file from the Flash and EEPROM of the working ArduinoUnoR3's atmega328P and atmega16u2. And then burn the four files into the arduinos that doesn't work. After copying the hex file, they can pass the looptest but still can't work.
with the common error: avrdude: stk500_getsync(): not in sync: resp=0x00

Need more information about how to handle that.
:grin:

After a whole day of playing around with the bootloader, I figured out that how to make that work.
I read the Flash and EEPROM file from a working ArduinoUno and then program the file to the atmega16u2 which needs that.
Then I burn the bootloader file <optiboot_atmega328> to the atmega328 and it worked.
But the issue is when I erase all the memory of the chips on arduino and do what I just described above, it only worked with the arduino board. It doesn’t work to my CLONE board which drove me crazy.
Right now I am pretty sure that the content of the memory in both Arduino board and my own board are exactly the same but I just can’t upload sketches to my own board.
I think there is something wrong with my hardware, maybe there is a tiny issue when I was soldering and now it punished me.

I power both of these boards and bridge their grounds. Then I use the multimeter to check whether the corresponding points of these two boards have the same voltage level.

it turned out to be the Gate pin of T1 (MOSFET which is next to the fuse) are 2.5V different. Since both the boards are powered by USB. I am wondering whether that maybe the reason whether my board doesn’t work.

btw, when I tried to upload sketches to my board. The led of RX blinked but the TX didn’t blink. When I assume both the RX and TX should blink the same pace. What is the problem?

biwa7636:
More questions about your loopback test, why do you hold reset and ground all together?

To hold the ATmega328 processor in reset. While held in reset, it does not run and the pins are all inputs (high impedance). The goal is to test everything up to but not including the processor.

does that mean you want to reset the chip once and then guarantee that no other reset will be triggered or

No.

..reset the chip all the time?

Yes.

btw, that is a interesting test.

Glad you like it. It was created by the community at large.

Based on your instructions, I think I am done with ATmega16u2,

Yes. The loop-back test is enough to prove the ATmega16u2 is working correctly.

biwa7636:
it turned out to be the Gate pin of T1 (MOSFET which is next to the fuse) are 2.5V different. Since both the boards are powered by USB. I am wondering whether that maybe the reason whether my board doesn't work.

Someone else will have to help with that problem.

I am pretty stuck with my own Arduino right now and I can't move on. But appreciate your help with the debug with Atmega16u2 though.
Thanks a lot!

Try posting just the MOSFET question in the General Electronics section.