Tag Archives: ATMega328

Arduino: Signature and stk500_getsync() not in sync resp=0x30 or 0x00 Issues

I recently built my own Arduino clone board. I even assembled it myself (QFN and all), but when it came down getting the Arduino GUI to actually download the sketch I ran into a few issues. Hopefully my work can help others since I was able to resolve those issues.
The Arduino UNO includes 2 microcontrollers (in the version I built): the ATMega8u2 which acts as a USB to serial converter and the ATMega328 which is the primary microcontroller.
Using a avrispmkii I tried to download the bootloader to the device. This is the piece of software that enables the ATMega328 to receive software through UART (via the ATMega8u2). Since I was using a newly bought part, I had to do this myself but I ran into the signature error:

Expected signature for ATMEGA328P is 1E 95 0F Double check chip, or use -F to override this.

Well, I did buy ATMega328 and I didn’t particualrly note that I bought a P version. Both parts are identical, differing AFAIK only in the signature. This is an easy fix. Simply look for ATMega328 in the avrdude.conf that’s in the Arduino GUI folders at
Arduino/hardware/tools/avr/etc

Then change the line 0x1e 0x95 0x0F to 0x1e 0x95 0x14

Once this was done, I used the DFU capability of the ATMega8u2 to upload the file:

Arduino/hardware/arduino/firmwares/arduino-usbserialArduino-usbserial-uno.hex

However, I quickly discovered the dreaded getsync error that seems quite widespread with Arduinos. After a lot of searching and trying, I resolved it. Basically if the RX LED blinks 3 times it means that the ATMega8u2 on the board is sending the data. However, when I looked in the logic analyzer at it, the baudrate was incorrect. The loopback test was running fine but the baudrate was still correct. Further, when I downloaded a sketch using a programmer that used the serial, I could see that the ATMega328 was sending data properly. Therefore the issue is the serial software in the ATMega8u2. Note that this is a brand new device. It did enter to DFU mode but the serial part is damaged. To resolve this, you must use a programmer such as AVRISP mkii to download the combined dfu and serial firmware called UNO-dfu_and_usbserial_combined.hex

You can use avrdude with the following command to download it:

C:\Arduino\hardware\tools\avr\bin> avrdude -p atmega8u2
-F -P usb -c avrispmkii -U flash:w:UNO-dfu_and_usbserial_combined.hex -U lfuse:w
:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m -C "C:\avrdude.conf"

Note that it will work inf the hex file is in the folder of the avrdude.exe (the bin folder). Point to the right place for your avrdude.conf file. If all is OK it will download successfully. And will show up as AT90USB82. Then remove the ICSP cable and let it boot up as the application (serial converter) by connecting and disconnecting the USB cable.
If it needs drivers, use those in the Arduino folder. In my case, the device showed up as Communications Port COM5. Then download the sketch as you would always do (select the Arduino UNO, then the right COM port).