I can not burn programs using my custom circuit based on arduino Uno rev3

Hi,

I open a new topic in the forum because I have been with this problem for a month. My problem is that when I try to load a program to my circuit it stops the STK 500 error.

My circuit design is based on arduino Rev 3. Basically it is the same unless you change the packages of the atmega328P-PU by atmega328P-AU, 16U2 by 16U2-AU, and oscillators because they are easier to weld by hand.

I have tried everything I found in the forum about the STK500 error:

  • Install USB drivers.
  • Change PC.
  • Resetear Atmega 328P
  • Quitar cables a los pines Rx y Tx del atmega328P

The results never worked for me, so I did a couple of tests to see which of the two chips was the fault, the 328P or the 16U2. Of course, both had loaded bootloaders.

To do this, use an original rev3 arduino and cut the RX, Tx and DTR tracks between the 328P and the 16U2. I got the following results:

When I loaded the program from my board with the 16u2 to the original arduino (328P) the STK500 error appeared.

When I load the program from the original arduino with the 16U2 to my board (328P) the program loaded correctly.

With what I understand that the problem is in the chip16U2 of my board, so I tried to change the bootloader of the chip. To do this, perform the following tests:

My Board:

Test 1.1:
ATMEGA328P-AU -----> BOOTLOADER loaded from IDE Arduino Arduin0 / Genuino Uno card
16U2 -----> BOOTLOADER "UNO-dfu_and_usbserial_combined.hex" from FLIP with windows 10
VID: 2341
PID: 0001

Exactly the same result: STK500

Test 2.1:
ATMEGA328P-AU -----> BOOTLOADER loaded from IDE Arduino Arduin0 / Genuino Uno card
16U2 -----> BOOTLOADER "Genuino-usbserial-atmega16u2-Uno-R3.hex" from FLIP with windows 10
VID: 2341
PID: 0243

Exactly the same result: STK500

Test 3.1:
ATMEGA328P-AU -----> BOOTLOADER loaded from IDE Arduino Arduin0 / Genuino Uno card
16U2 -----> BOOTLOADER "Arduino-usbserial-uno.hex" from FLIP with windows 10
VID: 2341
PID: 0001

Exactly the same result: STK500

Test 4.1:
ATMEGA328P-AU -----> BOOTLOADER loaded from IDE Arduino Arduin0 / Genuino Uno card
16U2 -----> BOOTLOADER "Arduino-usbserial-atmega16u2-One-Rev3.hex" from FLIP with windows 10
VID: 2341
PID: 0043

Exactly the same result STK500

With Original Arduino UNO SMD:

Test 1.2:
ATMEGA328P-PU -----> BOOTLOADER Original
16U2 -----> BOOTLOADER "UNO-dfu_and_usbserial_combined.hex" from FLIP with windows 10
VID: 2341
PID: 0001

Exactly the same result, the program is loaded perfectly.

Test 2.2:
ATMEGA328P-PU -----> BOOTLOADER Original
16U2 -----> BOOTLOADER "Genuino-usbserial-atmega16u2-Uno-R3.hex" from FLIP with windows 10
VID: 2341
PID: 0243

Exactly the same result Load the program perfectly

Test 3.2:
ATMEGA328P-PU -----> BOOTLOADER Original
16U2 -----> BOOTLOADER "Arduino-usbserial-uno.hex" from FLIP with windows 10
VID: 2341
PID: 0001

Exactly the same result Load the program perfectly

Test 4.2:
ATMEGA328P-PU -----> BOOTLOADER Original
16U2 -----> BOOTLOADER "Arduino-usbserial-atmega16u2-One-Rev3.hex" from FLIP with windows 10
VID: 2341
PID: 0043

These results puzzled me and I decided to use an oscilloscope to see what difference there was between the signals sent by the two 16U2, since in principle they have the same loaded bootloader.

Attached two images, one with the signals of the pin Tx of the 16U2 in yellow (Rx 328P) and the pin Rx of the 16u2 in purple (TX 328P).

As you can see in the images it seems that the problem is in the boot sequence sent by the 16U2 of my board.

Since the width of the pulses at low level is of a duration of about 300us and that of high level is of 1ms. While in the 16U2 of the original arduino the pulses of low level are of 40us and the one of high level is of 0.5ms.

I check that the 16U2 clock signal on my board is 16MHz, it's actually exactly 16MHz, just like in the original Arduino uno.

Also check that the signals sent through the USB bus are similar, especially the ramps on the rising and falling flanks. the result was that they were practically the same in the original arduino uno and in my board.

I do not know if there is something missing to configure in the 16U2 of my board that can not be configured with a simle load of the bootloader through flip. Can someone help me with this problem?

Thanks in advance,
Gruben

[/list]

I see that there is no answer to this issue, I do not know if it is because it is already resolved in another post. If so, I am sorry to have repeated the subject and would be glad if someone told me where that post is because I can not find it.

I have reviewed this thread that had a similar problem to mine, only that its problem is that it did not cross the Rx and Tx signals between the USB chip and the atmega328P.

https://forum.arduino.cc/index.php?topic=565122.0

In that thread PERT commented the following:

"Unlike your pre-made Arduino clone, the breadboard circuit in that tutorial does not have an auto-reset circuit The microcontroller must be reset at just the right time to activate the bootloader so you can upload. is done automatically by the auto-reset circuit When you do not have an auto-reset circuit you need to manually reset the board just as the upload starts (after the compilation finishes) The auto-reset circuit is simply connecting the DTR pin on your FT232RL to the reset pin on the microcontroller via 0.1 uF ceramic capacitor A better breadboard tutorial is this one:
Gammon Forum : Electronics : Microprocessors : How to make an Arduino-compatible minimal board ".

Although I had already checked that the 328P atmega was reset correctly, since I have managed to load programs to my board using the usb chip of an original arduino uno.

Check with the oscilloscope that the reset complied with the times published on the web page. Attached capture with the oscilloscope.

The only thing that remains for me to try is to solder to my card a 16U2-AU buyed with the preloaded bootloader. Does anyone know where to buy one?.

in parallel with that solution, (if I can find an atmega 16U2-AU with the bootloader preloaded), I will buy the cable:

With the cable I will try to program and communicate through the usb port with the atmega 328P as it says on the website that PERT proposed.

If it works I will re-design my board to adapt it to the new solution and I'll send it back to manufacture.

Rubén

The only thing that remains for me to try is to solder to my card a 16U2-AU buyed with the preloaded bootloader. Does anyone know where to buy one?.

I don't use Flip, but maybe this will help. I think if you load this hex file to your 16u2 chip it will work.
Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex

I use Linux and just copy this file to my home directory and then use a simple avrdude command like this.

avrdude -p atmega16u2 -P usb -c usbasp -U flash:w:Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

This explains things better than I can. :slight_smile:

I don't use Flip, but maybe this will help. I think if you load this hex file to your 16u2 chip it will work.
Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex

I use Linux and just copy this file to my home directory and then use a simple avrdude command like this.

Thanks !, What you propose I have not tried it because when trying to load that file with flip, the error "Address is out of range" appears.

will try it and post if it worked or not.

On the other hand, yesterday I tried the solution with the wire "TTL-232R-5V" and it worked! I have been working on the re-design of the board eliminating the 16U2 chip and using the FTDI wire.

I got the same issue on ubuntu 18.04 with brand new nano board serial is ok and all looks good except I alwas go programming issue
I tryed all same workaround with no luck

I found what's wrong for me :
as it works under windows I setted in preference the verbose for upload time
I dont know how to change it in to IDE but issue for me was due to baudrate setting
the avrdude comand line for uploading on windows is :

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM10 -b57600 -D -Uflash:w:C:\Users\DV\AppData\Local\Temp\arduino_build_247080/AnalogReadSerial.ino.hex:i

and for linux one :

/home/oga/arduinoIDE/arduino-1.8.6/hardware/tools/avr/bin/avrdude -C/home/oga/arduinoIDE/arduino-1.8.6/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:/tmp/arduino_build_408142/AnalogReadSerial.ino.hex:i

if I change the baudrate it works ok

/home/oga/arduinoIDE/arduino-1.8.6/hardware/tools/avr/bin/avrdude -C/home/oga/arduinoIDE/arduino-1.8.6/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/tmp/arduino_build_408142/AnalogReadSerial.ino.hex:i

it look that windows is using the right baudrate but I dont know how to change this in the IDE so I must use command line for flashing under linux

proff:
I got the same issue on ubuntu 18.04 with brand new nano board serial is ok and all looks good except I alwas go programming issue
I tryed all same workaround with no luck

I found what's wrong for me :
as it works under windows I setted in preference the verbose for upload time
I dont know how to change it in to IDE but issue for me was due to baudrate setting
the avrdude comand line for uploading on windows is :

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM10 -b57600 -D -Uflash:w:C:\Users\DV\AppData\Local\Temp\arduino_build_247080/AnalogReadSerial.ino.hex:i

and for linux one :

/home/oga/arduinoIDE/arduino-1.8.6/hardware/tools/avr/bin/avrdude -C/home/oga/arduinoIDE/arduino-1.8.6/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:/tmp/arduino_build_408142/AnalogReadSerial.ino.hex:i

if I change the baudrate it works ok

/home/oga/arduinoIDE/arduino-1.8.6/hardware/tools/avr/bin/avrdude -C/home/oga/arduinoIDE/arduino-1.8.6/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/tmp/arduino_build_408142/AnalogReadSerial.ino.hex:i

it look that windows is using the right baudrate but I dont know how to change this in the IDE so I must use command line for flashing under linux

This is because on linux, you've updated the AVR board package. The latest AVR board package supports the new official unos that come with a bootloader that runs at 115200 baud - to use the old nanos, from tools -> processor, select the "old bootloader" version.

Your problem is different from the OP's.

OP, Can you post your schematic please?