I am pretty new to programming Arduino, but I really enjoy it. I wanted to make my projects more permanent, and move them out of Arduino, by programming Atmega328 and independent circuit.
I bought Atmega328 (on the box it says Atmega328-PU, whereas on the chip Atmega328U), and - as I am not sure whether it contains bootloader - I tried to follow the following page: From Arduino to a Microcontroller on a Breadboard | Arduino
to burn it on chip.
When setting it up and trying to burn bootloader, it finishes with the following error:
Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files(x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM3 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
Using Port : COM3
Using Programmer : stk500v1
Overriding Baud Rate : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x03
avrdude done. Thank you.
Error while burning bootloader.
I double/triple checked wiring, it looks ok. I tried to use search, but the answers are not really matching. I can upload normal sketch to Arduino on the same COM3 port.
Am I doing anything obviously wrong?
Thank you in advance for help.
Programmer Type : STK500
Description : Atmel STK500 Version 1.x firmware
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
Error while burning bootloader.
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x1e9514 (probably m328)
avrdude: Expected signature for ATmega328P is 1E 95 0F
Double check chip, or use -F to override this check.
OK! This is actually good progress even though still not success.
The problem is that the tutorial is for the ATmega328P, but you have the ATmega328. Despite being very similar chips, they do have different signatures.
The easiest way to add support to the Arduino IDE for the ATmega328 is by using MiniCore. Please do this:
Install MiniCore by following these instructions: GitHub - MCUdude/MiniCore: Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB (NOTE: stop when you get to the part that says "Manual Installation", you only need to do the Boards Manager installation).
Select Tools > Board > ATmega328 from the menu.
Select Tools > Variant > 328 / 328A from the menu.
Select Tools > Programmer > Arduino as ISP (MiniCore) from the menu.
Click Tools > Burn Bootloader.
I'll also note that your breadboard layout is very far from being ideal. It might work, it might not work, it might work sometimes but not reliably.
You are missing the 0.1 uF capacitors on the ATmega328's power inputs. You can see here how those should be added:
The wires for your crystal circuit are way too long. You can see how it should be done here:
I would even recommend cutting the leads on the capacitors down to the necessary length.
Workaround:
In your Arduino folder, find the subfolder: ..\hardware\tools\avr\etc
Make a backup copy of the file: avrdude.conf
Open the file avrdude.conf in a text editor
Search for: “0x1e 0x95 0x0F” (this is the ATmega328P signature)
Replace it with: “0x1e 0x95 0x14” (this is the ATmega328 signature)
Save the file
Restart the Arduino IDE
Continue with the rest of the steps in the instructable, and once bootloading is complete restore the backup copy you made.
and it seems bit hacky, but it worked.
Just one more question - for uploading sketches - there isn't the way other than using FTDI Adapter so that the original Arduino chip doesn't need to be removed?
mrn86:
Just one more question - for uploading sketches - there isn't the way other than using FTDI Adapter so that the original Arduino chip doesn't need to be removed?
There are two options for uploading sketches to the ATmega328:
Via a USB to serial adapter. You can buy "FTDI" modules or cables for this or use an Arduino board.
Via an ISP programmer (Sketch > Upload Using Programmer). You could do this using the "Arduino as ISP" programmer you created from your Uno, or buy a dedicated ISP programmer like the USBasp
The advantage of using a serial adapter is that during development work you will usually want to have a serial connection to the chip anyway so you can print from the sketch to the Arduino IDE's Serial Monitor. So the serial adapter is able to provide all your communication needs between the computer and the ATmega328 with only a few wires.
The advantage of using an ISP programmer is that you can upload without having a bootloader installed on the ATmega328. Depending on which board you selected when you burned the bootloader (could have been Duemilanove, Nano, or Uno depending on how you interpreted the outdated Arduino tutorial or whether you followed the advice in the instructable), the bootloader is using up either 2 kB or 0.5 kB of the 32 kB of precious flash memory on the ATmega328. I think most people consider the convenience of the serial uploads to be well worth that real estate in the flash, but if it's the difference between your sketch fitting and not fitting, you might consider the no bootloader option to be interesting.