I bought ATmega328p with bootloader and I can't erase it 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
Your connections to the ATmega328p are incomplete.
You are missing the connection of ground to pin 22, and you must supply power to AVCC on pin 20.
You should also place the capacitors much closer to the crystal with a very direct route to ground, and try to place the crystal itself closer to the chip.
Additionally you should use supply bypass capacitors.
Please see the minimum wiring at Arduino on a Breadboard, however this document itself is erroneous as it neglects to show the high frequency 0.1 uF bypass capacitors you should have directly across each pair of power pins.
That's not to say that there may not be additional issues as well - but you need to fix the circuit problems first.