I bought an online deal which had 10x ATmega328p with bootloader installed. I thought I can erase the bootloader once I got the order (I want to write custom task without a bootloader) but my programmer does not seem to find the ATmega328p. I know it is the problem of the microcontroller because I have another ATmega328p which works fine and I can upload code to it. Is there a flag or switch I am missing when trying to overwrite the bootloader on the microcontroller?
Here are the components I am using:
- ATmega328p with bootloader
- SparkFun Pocket AVR Programmer (usbtiny)
Here are the commands I am using:
- To compile:
avr-gcc -std=c11 -mmcu=atmega328 -O -o main.o main.c
- To generate hex:
avr-objcopy -O ihex main.o main.hex
- To upload:
sudo avrdude -c usbtiny -p m328p -U flash:w:main.hex
Here is the output of the avrdude
command:
avrdude: Using SCK period of 10 usec
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.
Anyone encountered similar situation before? How did youu managed to fix it? I appreciate any help :)
Thank you
Edit #1 I tried setting the -B
flag to various values but nothing seems to solve the problem.
Edit #2 Here is the circuit I am using while programming the ATmega328p
- 2x Capacitors 22pf
- 1x Crystal oscillator 16Mhz
- 1x Resistor 10K ohm
- 1x ATmega328p
- 1x SparkFun Pocket AVR Programmer