LoginSignup
2

More than 5 years have passed since last update.

ArduinoISP

Last updated at Posted at 2014-05-14

"ArduinoISP"というスケッチをAVRライタとして使うメモ。

Arduino IDE 1.0.5と
これ
http://make.kosakalab.com/make/electronic-work/arduino-ide-arduinoisp/
をセットアップして使います。

配線は上のURLの通り。
Blinkのスケッチをブレッドボードの生AVRに書き込んで動作確認しておく。

Fuseを確認する

書き込んだり、設定したりするためのコマンドラインツール"avrdude"がArduino.appのなかに入っている。

% avrdude -C /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -P /dev/tty.usbserial-A9005bvI -c avrisp -p m88p -b 19200 -v

avrdude: Version 5.11, compiled on Sep  2 2011 at 18:52:52
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/takeru/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/tty.usbserial-A9005bvI
         Using Programmer              : avrisp
         Overriding Baud Rate          : 19200
         AVR Part                      : ATMEGA88P
         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        512    4      0  3600  3600 0xff 0xff
           flash         65     6    64    0 yes      8192   64    128  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 AVR ISP
         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.06s

avrdude: Device signature = 0x1e930f
avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as DD
avrdude: safemode: efuse reads as 7

avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as DD
avrdude: safemode: efuse reads as 7
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

追加でインストールしたアレにより、
「ブートローダーを書き込む」とするとfuseが書かれるらしい。
読み込んだfuseの値は、boards.txtの中の設定と一致している。
ちゃんと書かれているようだ。

avr88p.name=ATmega88P / Int.8MHz
avr88p.upload.maximum_size=8192
avr88p.bootloader.low_fuses=0xe2
avr88p.bootloader.high_fuses=0xdd
avr88p.bootloader.extended_fuses=0x07
avr88p.bootloader.path=dummy
avr88p.bootloader.file=dummy.hex
avr88p.bootloader.unlock_bits=0x3F
avr88p.bootloader.lock_bits=0x3F
avr88p.build.mcu=atmega88p
avr88p.build.f_cpu=8000000L
avr88p.build.core=arduino:arduino
avr88p.build.variant=atmega_int

Fuseを書く

(ArduinoIDEを使って書くこともできる http://qiita.com/takeru@github/items/b6bd851ed8727d6c8862)

% avrdude -C /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -P /dev/tty.usbserial-A9005bvI -c avrisp -p m88p -b 19200 -U lfuse:w:0xF7:m -U hfuse:w:0xDD:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude: Device signature = 0x1e930f
avrdude: reading input file "0xF7"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.05s

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

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

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

Writing | ################################################## | 100% 0.05s

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

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

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

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

avrdudeでhexを書き込む

% avrdude -C /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -P /dev/tty.usbserial-A9005bvI -c avrisp -p m88p -b 19200 -U flash:w:cdcio.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude: Device signature = 0x1e930f
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 "cdcio.hex"
avrdude: input file cdcio.hex auto detected as Intel Hex
avrdude: writing flash (3686 bytes):

Writing | ################################################## | 100% 6.47s

avrdude: 3686 bytes of flash written
avrdude: verifying flash memory against cdcio.hex:
avrdude: load data flash data from input file cdcio.hex:
avrdude: input file cdcio.hex auto detected as Intel Hex
avrdude: input file cdcio.hex contains 3686 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 4.27s

avrdude: verifying ...
avrdude: 3686 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2