You are here

Arduino on breadboard (ATMEGA328P 8MHz and 1MHz)

A one stop shop for using the ATMEGA328P standalone at 8MHz or 1MHz clock speed including compiled bootloader.  This is for use primarily on a breadboard, but also also directly on, say, a Uno R3.

Summary

I was unable to find any complete resources for configuring the AVR ATMEGA328P as an 8MHz Arduino.  Also I could find no resources at all to allow me to use the AVR ATMEGA328P microprocessor at 1MHz.  This frustration is shared by many.  Put the following files in your sketchbook to provide both 8MHz and 1MHz boards in the Arduino IDE which can be used for burning bootloaders or uploading sketches.  My sketchbook directory is /home/ewan/Arduino.  So put the hardware directory at /home/ewan/Arduino/hardware, etc.  Links to download all the required files are below.

breadboard/
breadboard/avr/
breadboard/avr/boards.txt
breadboard/avr/bootloaders/
breadboard/avr/bootloaders/atmega/
breadboard/avr/bootloaders/atmega/optiboot_atmega328_1MHz_4800.hex
breadboard/avr/bootloaders/atmega/optiboot_atmega328_pro_8MHz.hex

The fiddly stuff

I needed to build the 1MHz boot loader. To do this I modified the Makefile in the Arduino hardware bootloader directory /var/local/arduino-1.6.9/hardware/arduino/avr/bootloaders/optiboot:

atmega328_1: TARGET = atmega328
atmega328_1: MCU_TARGET = atmega328p
atmega328_1: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=4800'
atmega328_1: AVR_FREQ = 1000000L
atmega328_1: LDSECTIONS  = -Wl,--section-start=.text=0x7c00 -Wl,--section-start=.version=0x7ffe
atmega328_1: $(PROGRAM)_atmega328_1MHz_4800.hex
atmega328_1: $(PROGRAM)_atmega328_1MHz_4800.lst

The Arduino AVR binary directory was added to the path, then the bootloader built and copied to the Arduino sketchbook hardware directory.

PATH=/var/local/arduino-1.6.9/hardware/tools/avr/bin:$PATH
make atmega328_1
cp -p optiboot_atmega328_1MHz_4800.hex /home/ewan/Arduino/hardware/breadboard/avr/bootloaders/atmega

Note that my environment built a bootloader file that was slightly over 512 bytes in size. Hence I lowered the start address by 512 bytes and adjusted the fuses to allow for a 1kB bootloader.  Note that if you use the fuse calculator then all the bits are reversed (0 and 1)!  Always ensure that the high fuses are set to at least 0x80 to keep the reset pin enabled.

Setting up the atmega328p on the breadboard

The pin mapping is useful. Connect RESET Pin 1 via a 10 kOhm pull-up resistor to 5V. Provide power by connecting 5V to pin 7 and GND to pin 8. If you wish, connect PB5 pin 19 to the anode of a LED, via 150 Ohm resistor to GND. That really is all you need.

Burn bootloader (chip on Uno R3 board)

I used another Arduino Uno R3 prepared with the standard example ArduinoISP sketch loaded. Now, connect the ISP Arduino to the target Arduino (with the new chip) as normal, i.e. (ISP->Target Uno): 13->13, 12->12, 11->11, 10->RESET. Burn the bootloader using Arduino as ISP.

Burn bootloader (chip on breadboard)

Connect as follows (ISP->target chip pin): 13->19 (SCK), 12->18 (MISO), 11->17 (MOSI), 10->1 (RESET). Burn the bootloader using Arduino as ISP.

Upload sketch (chip on Uno R3 board)

Upload the sketch using the usual process in the IDE. This can take a considerable amount of time at 4800 baud when running at 1MHz.

Upload sketch (chip on breadboard)

If you need to visualise the serial activity then, for both pins 2 and 3 of the processor, wire to a LED cathode, via a current limiting resistor (say, 1k), to +5V. This way the LEDs will illuminate when Tx/Rx pins are grounded.

I use a CH340 USB to serial converter which does not have the ability to reset the micro processor. Connect CH340 5V to pin 7 (5V), GND to pin 8 (GND), Tx to pin 2 (Rx) and finally Rx to pin 3 (Tx). Now, short pin 1 (RESET) to GND. Click Upload in the Arduino IDE. When the progress bar fills all the way to the right, release the RESET from GND. That should synchronise the sketch upload with the reset of the boot loader.

Upload sketch using Arduino-Makefile (chip on breadboard)

To use Arduino-Makefile instead of the IDE, wire the serial port as above. For the correct timing, release RESET when you see the output show make reset. You will also need to change a couple of lines in the Makefile as appropriate, for example:

BOARDS_TXT=/home/ewan/Arduino/hardware/breadboard/avr/boards.txt
VARIANT=standard
BOARD_TAG=atmega328bb.menu.clock.1MHz
AVRDUDE_OPTS=""

Setting AVRDUDE_OPTS to blank reinstates the progress bar and the verification of the flash programming operation. These are useful options because the upload is slow and can be unreliable.

Classifications: 

Comments

Hi,

I have the .hex bootloader but I cannto find a way to add it to the bootloaders list on the Arduino IDE for Mac.
I thought I only needed to go to /Applications/Arduino.app/Contents/Java/hardware/arduino/avr and modify the boards.txt to all the new bootloader name bit it just wont appear. Any ideas? thanks!

Hi Martin, instead of updating the core files I would suggest you place the files in you local sketch book directory which I believe is ~/Documents/Arduino on the Mac. For example:

~/Documents/Arduino/hardware/breadboard/avr/boards.txt

and so on.

I did not build the 8 MHz bootloader, but downloaded it from the above link. I am not sure about the reliability at the higher BAUD rate so I will have to check the optiboot code and documentation when I have time.

Thanks for the clear guide.
I am a beginner here so I want to ask a clarifying question. In your post you mention 'ATMEGA328P standalone at 8MHz'. Since it is inteded for a standalone, would the bootloader work on a arduino nano that currently runs on 16MHz? I want to burn a 8mhz bootloader to my nano so it can run on 2 batteries.

According to my notes and the fuses I set, the 8 MHz bootloader uses the internal oscillator. Thus I would expect the nano will 'ignore' the external 16 MHz oscillator/crystal and run at 8 MHz. Let me know how you get on or if you need me to try (I have only a Uno to test with).

Hmm unfortunately it's not working for me, but it's unrelated to the .hex file.
I have a general error in bootloading the nano, tried to bootload the 'original' file as well provided by the IDE but that gave the same error, see below.

Arduino: 1.8.12 (Mac OS X), Board: "Arduino Nano, ATmega328P (Old Bootloader)"

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/cu.wchusbserial14120 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA: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 "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/../.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial14120
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=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x43
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x84
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe1
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xf5
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xa1
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x4a
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x53
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xf0
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x05

avrdude done. Thank you.

That is the wrong command line for that programmer. But also the wrong fuse values, and you don't want to 'brick' the nano. Have you tried selecting the correct programmer in the Arduino IDE and burning the bootloader from there? This should take care of these points for you.

Hmm, how is it the wrong command line. Within IDE, without using your files for now, I selected the nano as board and chose the old bootloader for ATMegra328p. All commands/fuses and other settings are executed by IDE itself. This should be the correct way to install the default bootloaders, right? So what is going wrong here.

And to use your bootloader, what would be the right program/command?

Yes, that would explain the different fuses. You choose the target board for the bootloader and burn it. But first you need to choose your programmer from the menu. This programmer will be used to burn the bootloader. You currently have the STK500 programmer selected but you need the Arduino as ISP to be selected instead. This will be in one of the menus. Let me know if you need me to find out which one.

Yea I understand, forgot to mention that in my previous one but programmer was set to Arduino as ISP. And then Examples --> ArduinoISP --> burn bootloader provides me with the aforementioned error...

Your above log shows that for some reason the stk500 is still being used: "Using Programmer : stk500v1". What does it read above the "Burn Bootloader" menu? For example, "Programmer: AVR ISP".

That is strange. The command line you posted had this option : "-cstk500v1" and so avrdude is expecting to find a "Atmel STK500 Version 1.x firmware" programmer. For Arduino as ISP the option should actually be "-cavrisp" IIRC. With this in mind, can you try again?

Ok I was not aware of this. I completely uninstalled Arduino IDE, rebooted and reinstalled. Configured IDE with the previous mentioned settings and tried to burn the bootloader again. Unfortunately I got the same results. 

Can it be due to the following line "User configuration file does not exist or is not a regular file, skipping" 

Arduino: 1.8.12 (Mac OS X), Board: "Arduino Nano, ATmega328P (Old Bootloader)"

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/cu.wchusbserial1410 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA: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 "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/<Sebex>/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.wchusbserial1410
         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=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x43
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x84
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe1
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xf5
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xa1
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x4a
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x53
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xd0
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x07

avrdude done.  Thank you.

Error while burning bootloader.

 

I have always had that line, and it's nothing to worry about since the IDE sets all the configuration options avrdude needs. I tried the same board and got the same error as you. So it is probably something else causing this. I'll need to set up the hardware to perform further testing, but that will take a while. Could you recheck the wiring and chosen serial port?

Ok that's interesting that you get the same error.
Rechecked the wiring another time, everything is connected accordingly. Reset works as well before burn as indicating from the leds.
For the port I only have 1 option too choose, so can't really go wrong there.

I get the error without the arduino connected, so that's why I suspect a wiring issue. Until I wire it myself I will not be able to confirm one way or the other.

Okay, I wired from a Uno to another arduino via the ICSP exactly as your link shows, and the result was a success. The only way I could recreate the error you have was when I did not program the Uno with the ArduinoISP sketch. Can you confirm you uploaded this sketch to the Uno that acts as the programmer? To check the programmer, open the serial monitor at 19200 BAUD, type 1 then SPACE and SEND. You should see AVR ISP returned.

Ah mate thanks man. I was under the impression that the ArduinoISP sketch was meant to be used for 'burn bootloader'. I never uploaded the sketch to the Uno so the errors make sense. I'm glad you helped me through this, rookie mistake on my side. I'm gonna try and use your 8MHz bootloader now, i'll let you know if it works! Thanks you again!

Ok so after figuring out the mistake of not having uploaded the ArduinoISP sketch, burning the bootloader of the nano went smooth.
Now do I need to take into account anything for uploading a sketch on the Nano? I've selected the nano, ATMega 328p, Programmer: AVRISP MKII and tried uploading the sketch but it encounters an error. Tried multiple settings. With the listed settings I get the

Using Port : /dev/cu.wchusbserial1420
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

Please ensure you choose the board configured especially for 8 MHz in the boards.txt. I configured the 8 MHz bootloader for 57600 BAUD. Please lower from 115200 to 57600 and retry.

Ok, do I only need to alter the baudrate of the original boards.txt? Or should I also copy the build. uploader. & bootloader. settings to the orginal boards.txt?

After only changing the uploadspeed (baudrate) I get "the selected serial port does not exist or your board is not connected" with the below logs. When selecting the ATMega328P old bootloader which runs standard on the 57600 rate I get the same.

Arduino: 1.8.12 (Mac OS X), Board: "Arduino Nano, ATmega328P"

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 "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/../.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial1420
Using Programmer : arduino
Overriding Baud Rate : 57600
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : Arduino
Description : Arduino

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x90

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc
Hardware Version: 57455931
Firmware Version: -329895792.32766
Topcard : STK502

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x94
Vtarget : 3265.2 V
Varef : 3.2 V
Oscillator : 0.001 Hz
SCK period : 35553.4 us

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x20

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc
avrdude: stk500_initialize(): (b) protocol error, expect=0x10, resp=0x84
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x8c

avrdude done. Thank you.

the selected serial port
does not exist or your board is not connected

I believe this may be causing you problems: Board: "Arduino Nano, ATmega328P". I would suggest trying to use the Pro Mini 8 MHz board first before changing anything.

Getting closer, I used your method to burn the 1 MHz bootloader and then upload the blink sketch and it all worked. But doing the same with the 8 MHz bootloader gave errors. So I think I will need to compile a custom 8 MHz bootloader and update the boards.txt. Let me see how much effort that will be...

I double checked and no need to recompile. To recap, I burnt the bootloader as ATmega328p on breadboard, Internal 8MHz 3.3V+ using the Arduino as ISP. Next I removed all wiring from the ICSP, plugged in just the 8 MHz arduino using USB, then uploaded the blink sketch through the IDE as usual (keeping the board unchanged). So it should work even with the 16 MHz oscillator still on the board. Am I doing anything differently to you?

I did the exact same thing, and also tried uploading the blink sketch on the, now, 8MHz arduino Nano which results in the error.

Something else, in the bootloader folder I came across 'ATmegaBOOT_168_atmega328_pro_8MHz.hex'. would that one be an option for the Nano ATMega328p to run on 8MHz as well, or is that a no go?

The 168 is a different processor, so don't use it. What board and clock speed have you selected, how is the nano wired up, and what method (e.g. which menu) do you use to upload the blink sketch?

Ok clear.
Selected Board: Nano
Clockspeed? If you mean baudrate it is adjusted to 57600, if not than I haven’t changed here anything.
Nano is wired up via usb to my macbook
I upload the blink sketch via the default sketch viewer of Arduino IDE, clicking the second button on the top ‘Upload’

With the 8 MHz bootloader flashed, you can no longer select the nano as your device. The fuses will start the processor at 8 MHz but the timings will be wrong in the code. When you instead choose the breadboard arduino from my boards.txt you will see a new menu which will allow you to choose a clock speed of 1 MHz or 8 MHz. As long as your Uno is completely disconnected, the remainder of the wiring seems correct.

So, change from Nano to ATmega328p on breadboard, then use the new menu to choose the 8 MHz speed.

Yea I actually tried that the first time around but had no luck either. Logs below:

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 "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/../.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial1420
Using Programmer : arduino
Overriding Baud Rate : 57600
avrdude: stk500_getsync(): can't communicate with device: resp=0xfc

avrdude done. Thank you.

An error occurred while uploading the sketch

Was the Arduino ISP disconnected at this time? Can you share the avrdude command lines for the bootloader burn that was successful and this failed blink sketch upload?

Only the Nano was connected and programmer AVRISP mkII was used.
Regarding the successful bootloader burn logs, can I find them somewhere in a historical log? Otherwise I will execute the burn again and report back.

btw, the captcha to post here is quite a challenge everytime haha

The programmer is used just to write the bootloader. You don't want any programmer connected since now the upload will be over serial USB via the new bootloader. I don't believe the avrdude command line history is stored anywhere. The captcha still does not slow down the spammers unfortunately.

Ah I see, so when uploading the sketch the programmer is not used at all, it's not like you can turn it off right?

Furthermore I tried uploading the sketch again with the previous settings, it seems I get mixed results. Either I get the previous log or the log below, it seems to be at random.
I'm going to redo the bootloader and post the code here in a moment.

Arduino: 1.8.12 (Mac OS X), Board: "ATmega328p on breadboard, Internal 8MHz 3.3V+"

Warning: Board arduino:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB
Sketch uses 2272 bytes (7%) of program storage space. Maximum is 32256 bytes.
Global variables use 190 bytes of dynamic memory.
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.wchusbserial1420 -b57600 -D -Uflash:w:/var/folders/r3/20vkvwds6332hmqjkjg7ps3c0000gn/T/arduino_build_946378/Blink_v01.ino.hex:i

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 "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/../.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial1420
Using Programmer : arduino
Overriding Baud Rate : 57600
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : Arduino
Description : Arduino

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc
Hardware Version: 143365435
Firmware Version: -415805296.32766
Topcard : STK502

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x94

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x20

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x0c
Vtarget : 3267.5 V
Varef : 3.2 V
Oscillator : 0.001 Hz
SCK period : 35553.4 us

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x34

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x10
avrdude: stk500_initialize(): (b) protocol error, expect=0x10, resp=0x20
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xfc

avrdude done. Thank you.

the selected serial port
does not exist or your board is not connected

For readability a new comment.

Below the logs of successfully bootloading the Nano.

Two generic notes/questions.
(1) I see the following warning, is this a problem: Warning: Board arduino:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB

(2) My usb port is renamed to the port name + ATMega on breadboard. Not sure why this is happening.
dev/cu.wchusbserial1420 (ATMega328p on Breadboard)

Logs:

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 "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/robinoosterholt/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial1420
Using Programmer : stk500v1
Overriding Baud Rate : 19200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

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

Reading | ################################################## | 100% 0.08s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3F:
avrdude: load data lock data from input file 0x3F:
avrdude: input file 0x3F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0x05"
avrdude: writing efuse (1 bytes):

Writing | ***failed;
################################################## | 100% 0.22s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: input file 0x05 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: WARNING: invalid value for unused bits in fuse "efuse", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xfd instead of 0x05 (double check with your datasheet first).
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xDC"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDC:
avrdude: load data hfuse data from input file 0xDC:
avrdude: input file 0xDC contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xE2"
avrdude: writing lfuse (1 bytes):

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/cu.wchusbserial1420 -b19200 -Uflash:w:/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/bootloaders/atmega/optiboot_atmega328_pro_8MHz.hex:i -Ulock:w:0x0F:m
Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xE2:
avrdude: load data lfuse data from input file 0xE2:
avrdude: input file 0xE2 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude done. Thank you.

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 "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/../.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial1420
Using Programmer : stk500v1
Overriding Baud Rate : 19200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

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

Reading | ################################################## | 100% 0.08s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/bootloaders/atmega/optiboot_atmega328_pro_8MHz.hex"
avrdude: writing flash (32768 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 32768 bytes of flash written
avrdude: verifying flash memory against /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/bootloaders/atmega/optiboot_atmega328_pro_8MHz.hex:
avrdude: load data flash data from input file /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/bootloaders/atmega/optiboot_atmega328_pro_8MHz.hex:
avrdude: input file /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/bootloaders/atmega/optiboot_atmega328_pro_8MHz.hex contains 32768 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 32768 bytes of flash verified
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.08s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude done. Thank you.

I get the same warning. I think it's because I built the boards.txt ages ago and the standard has changed slightly since then. It doesn't affect the functionality. I suspect the VID/PID of the Nano match the signature of the breadboard in the boards.txt. Hence the IDE labels the port for you. This doesn't affect the functionality either. The writing of the bootloader and the fuses looks good. Can you now post the same for the blink sketch?

Logs when uploading blink sketch:

Arduino: 1.8.12 (Mac OS X), Board: "ATmega328p on breadboard, Internal 8MHz 3.3V+"

Warning: Board arduino:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB
Sketch uses 2272 bytes (7%) of program storage space. Maximum is 32256 bytes.
Global variables use 190 bytes of dynamic memory.
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.wchusbserial1420 -b57600 -D -Uflash:w:/var/folders/r3/20vkvwds6332hmqjkjg7ps3c0000gn/T/arduino_build_75790/Blink_v01.ino.hex:i

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 "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/../.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial1420
Using Programmer : arduino
Overriding Baud Rate : 57600
avrdude: stk500_getsync(): can't communicate with device: resp=0x90

avrdude done. Thank you.

An error occurred while uploading the sketch

Great, hopefully blinking at the correct rate as well? I think your internal oscillator cannot support the upload speed. Let me look into what's needed to lower that speed.

Pages