bootloading the ATMEGA328P-AU with internal clock

Hello, I have made a homemade PCB with the ATMEGA328P-AU (smd) and I want to burn the bootloader using a UNO as ISP. I have done this in the past using DIP microcontrollers with external 16MHz oscillators. This time I want to use the internal clock. I tried this method and selected the "ATmega328 on a breadboard (8 MHz internal clock)" as my board but I got this error:

avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

What board should I select to burn the bootloader on the SMD ATMEGA328P-AU using the internal clock? Thank you

You can select Uno, but change the fuse setting in boards.txt for the internal clock, and change the clock setting from 16000000 to 8000000 Low 4 bits of the Low Fuse byte set to 0010

9.6 Calibrated Internal RC Oscillator By default, the Internal RC Oscillator provides an approximate 8.0MHz clock. Though voltage and temperature dependent, this clock can be very accurately calibrated by the user. See Table 29-14 on page 311 for more details. The device is shipped with the CKDIV8 Fuse programmed. See ”System Clock Prescaler” on page 34 for more details. This clock may be selected as the system clock by programming the CKSEL Fuses as shown in Table 9-11. If selected, it will operate with no external components. During reset, hardware loads the pre-programmed calibration value into the OSCCAL Register and thereby automatically calibrates the RC Oscillator. The accuracy of this calibration is shown as Factory calibration in Table 29-14 on page 311.

Could you provide details about the changes I have to make? The boards.txt file on my Mac is in /Applications/Arduino.app/Contents/Resources/Java/boards.txt What should I change in this?

uno.name=Arduino Uno
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard

uno.bootloader.low_fuses=0xf2 // 0b11110010 uno.build.f_cpu=8000000L

I think that's all you need.

Sorry for the false alarm.
I used my multimeter and I found that the juper wire from the MISO pin was destroyed internally so it was not connected.
I selected the “ATmega328 on a breadboard (8 MHz internal clock)” before burning the bootloader with these fuse settings:

atmega328bb.name=ATmega328 (8 MHz internal clock)
atmega328bb.upload.protocol=stk500
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600
atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F
atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard

I have one more question. Could I reburn a different bootloader in the future?
I read that if your microcontroller has a bootloader that uses the external clock and you want to burn a bootloader that uses the internal clock, you have to connect the external oscillator while you are changing the bootloader. Is this the only limitation?

Not sure if you can burn a bootloader if MISO is not connected anymore.

2nd question, yes you need an external clock if the fuses are set for that, to change it to something else.
No other limit I know of (except for having unlocked lock bits).

I use a FTDI cable to upload my sketches. I get these errors:

avrdude: stk500_cmd(): protocol error

or

avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

but the weird thing is that the sketch seems to be uploaded and my board is working. What could these errors mean?

Got me there - I've not seen those errore before. Looks like the FT232 in the cable is not talking to the PC.

Strictly speaking, the tolerance spec on the internal RC oscillator is not close enough (±10% IIRC) to support asynchronous serial communication. Having said that, I've used Serial.print() at 9600 baud for debug statements on several ATmega328Ps running on the 8MHz RC oscillator, and all seemed to work fine! This leads me to believe they were running much closer than 10% (didn't try measuring them, but I should have). I haven't tried a bootloader though, so your mileage definitely may vary.

Greetings All! Thanks for your posts.

I need your help similar to this subject.

I have ATMEGA328P-AU (32pins) on a PCB i made. I am using external crystal 16Mhz, 22pf, atmel studio7 and AVRISPMKII as the programmer.

I have problem with clock delay i guess, MCU not responding fast, after after reset or turn on. I can program it with atmel studio using arduino code(arduino uno).

.................................................................... Device Signature:0x1E950F CPU AVR8 Flash size 32 KB EEPROM size 1 KB SRAM size 2 KB VCC range 1.8 - 5.5 V Maximum operating speed N/A ..................................................................... Extended Fuse : 0xFD High Fuse:0xDA Low Fuse: 0xFF

SUT_CKSEL: EXTXOSC_8MHZ_16KCK_14CK_65MS .....................................................................

The problems is that, it works but slow at start-up, and audio output from a midi device via TX is distorted at the start (not clear).

Supply voltage is 5v

I have tried the fuses below but still encountering same problem.

Extended Fuse : 0x05 High Fuse:0xDA and DE Low Fuse: 0xFF

Any clue to rectify this problem.

I would be grateful for a quick response

Thanks!