Arduino using ATmega328p with internal 8MHz Crystal with Bus Pirate

I am working in a robotics project where keeping the cost low is crucial. So in order to reduce costs and make the robot easy to program and connect to various types of sensors easily, I choose to use an ATmega328p so I can use the Arduino enviroment but using the internal 8MHz clock.

Here are the steps I made to program the bootloader into the ATmega328p chip using the all-mighty Bus Pirate froam Dangerous Prototypes:

Connect the BP to the microcontroller according to this (add link) table.

in a terminal check the connection between the BP and the microcontroller using

avrdude -c buspirate -p m328p -v -P /dev/ttyUSB0

unlock bootloader section on the chip using

avrdude -c buspirate -p m328p -P /dev/ttyUSB0 -U lock:w:0x3f:m

go to the folder where you installed arduino with

$cd /whatever/arduino/hardware/arduino/bootloaders/atmega

and use this command to write the correct bootloader to the chip

avrdude -c buspirate -p m328p -P /dev/ttyUSB0 -U efuse:w:0x05:m -U hfuse:w:0xDA:m -U lfuse:w:0xE2:m -U flash:w:ATmegaBOOT_168_atmega328_pro_8MHz.hex

then lock again the bootloader section with

avrdude -c buspirate -p m328p -P /dev/ttyUSB0 -U lock:w:0x0F:m

now test with a ftdi chip to program with the arduino IDE

Advertisements

About Gary

I build robots for fun! View all posts by Gary

2 responses to “Arduino using ATmega328p with internal 8MHz Crystal with Bus Pirate

  • Juan

    Hi there, i tried but didnt works, keep having the error rc-2 :

    C:\Users\Juan>avrdude -c buspirate -p m328p -P com31 -U efuse:w:0x05:m -U hfuse:
    w:0xDA:m -U lfuse:w:0xE2:m -U flash:w:ATmegaBOOT_168_atmega328_pro_8MHz.hex

    Detecting BusPirate…
    **
    ** Bus Pirate v3a
    ** Firmware v5.10 (r559) Bootloader v4.4
    ** DEVID:0x0447 REVID:0x3046 (24FJ64GA002 B8)
    ** http://dangerousprototypes.com
    **
    BusPirate: using BINARY mode
    avrdude: initialization failed, rc=-2
    Double check connections and try again, or use -F to override
    this check.

    avrdude done. Thank you.

    C:\Users\Juan>

    can you help me? thanka

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: