LoginSignup
0
0

USBaspのファームウェアを更新する

Posted at

USBasp同士でファームウェアを更新できると聞き二つセットのUSBaspを買ったのですが、実際に手順に従ってみると、ファームウェアを更新するためにファームウェア更新済みのUSBaspが必要らしいメッセージが表示されました(誤解かもしれません。肝心のエラーをメモし忘れました)。

今回はArduino Uno R3にArduinoISPを書き込み、ArduinoISPで片方のUSBaspを更新してから、もう片方は更新したUSBaspでの更新を試みます。

目視で確認したところ、今回入手したUSBaspはATmega8Aを搭載しているようです。以下では執筆時点で最新のArduino IDE 2.3.2およびAVRDUDE v7.3を使用しています1

Arduino Uno R3を使用した書き込み

ArduinoISPのスケッチは、デフォルトでArduino IDEに収録されています。Arduino IDEの「ファイル」>「スケッチ例」>「11.ArduinoISP」>「ArduinoISP」を開き、Unoを選択して書き込みます。

続いてUSBaspのJ2をショートさせ、10ピンのコネクタの切り欠きを上にして以下のようにUnoに接続します。空白はNCです。冒頭のサイトに詳しいのでそちらを確認してください。

12 13 10 11
GND 5V

リセットを無効にするため、UnoのRESETとGNDの間にコンデンサを追加します。10uFとありますが0.1uFでも特に問題ありませんでした2

Try connecting a 10 uF capacitor between the reset and ground pins on the board you're using as an Arduino as ISP.

Arduino recently changed the protocol used by the Arduino as ISP programmer from stk500v1 to arduino in order to allow ATmega32U4 boards like the Leonardo to be used with Arduino as ISP. An unfortunate side effect of this change is that it makes it more likely that the reset disabling capacitor will be needed on boards where it was previously not necessary. This change has been reverted and a new "Arduino as ISP (ATmega32U4)" programmer added for compatibility with Leonardo, etc., but there has not been a new release since that time:

https://github.com/arduino/ArduinoCore-avr/commit/98c8a138c18592e7385feb800e30165a403802d9

コンデンサ未接続時の失敗例
> .\avrdude.exe -C .\avrdude.conf -P COM7 -b 19200 -c arduino -p m8 -U flash:w:..\usbasp.2011-05-28\usbasp.2011-05-28\bin\firmware\usbasp.atmega8.2011-05-28.hex

avrdude error: protocol expects OK byte 0x10 but got 0x14
avrdude error: cannot obtain SW version
avrdude error: initialization failed, rc=-3
        - double check the connections and try again
        - use -B to set lower the bit clock frequency, e.g. -B 125kHz
        - use -F to override this check
avrdude error: protocol expects sync byte 0x14 but got 0x01

avrdude done.  Thank you.

USBaspのサイトから最新のファームウェア(usbasp.2011-05-28.tar.gz)をダウンロードして展開します3

UnoをPCに接続し、avrdudeコマンドを実行します。ポート名やパス等は適宜変更してください。ダウンロードしたファームウェアに同梱されたReadme.txtに従い、続けてヒューズビットを変更しています。冒頭に挙げたサイトではファームウェアの前に設定していますが、avrdude.exe: verification error, first mismatch at byte 0x0000 0xd9 != 0xc9のエラーで書き込めませんでした4。ファームウェアの後に書き込むことはできるようです。

> .\avrdude.exe -C .\avrdude.conf -P COM7 -b 19200 -c arduino -p m8 -U flash:w:..\usbasp.2011-05-28\usbasp.2011-05-28\bin\firmware\usbasp.atmega8.2011-05-28.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9307 (probably m8)
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: processing -U flash:w:..\usbasp.2011-05-28\usbasp.2011-05-28\bin\firmware\usbasp.atmega8.2011-05-28.hex:i
avrdude: reading input file ..\usbasp.2011-05-28\usbasp.2011-05-28\bin\firmware\usbasp.atmega8.2011-05-28.hex for flash
         with 4700 bytes in 1 section within [0, 0x125b]
         using 74 pages and 36 pad bytes
avrdude: writing 4700 bytes flash ...
Writing | ################################################## | 100% 6.93 s
avrdude: 4700 bytes of flash written
avrdude: verifying flash memory against ..\usbasp.2011-05-28\usbasp.2011-05-28\bin\firmware\usbasp.atmega8.2011-05-28.hex
Reading | ################################################## | 100% 3.47 s
avrdude: 4700 bytes of flash verified

avrdude done.  Thank you.

> .\avrdude.exe -P COM7 -b 19200 -c arduino -p m8 -U hfuse:w:0xC9:m -U lfuse:w:0xEF:m
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9307 (probably m8)

avrdude: processing -U hfuse:w:0xC9:m
avrdude: reading input file 0xC9 for hfuse
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte hfuse ...
avrdude: 1 byte of hfuse written
avrdude: verifying hfuse memory against 0xC9
avrdude: 1 byte of hfuse verified

avrdude: processing -U lfuse:w:0xEF:m
avrdude: reading input file 0xEF for lfuse
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lfuse ...
avrdude: 1 byte of lfuse written
avrdude: verifying lfuse memory against 0xEF
avrdude: 1 byte of lfuse verified

avrdude done.  Thank you.

USBaspを使用した書き込み

もう片方のUSBaspは、更新済みUSBaspから更新を試みます。

更新した側・今度は書き込み機になるUSBaspのJ2のショートを解除し、更新される側のUSBaspのJ2を同様にショートさせます。二つをリボンケーブルで接続し、書き込み機をPCに接続します。

ZadigでUSPaspのドライバーを「libusbK (v3.0.7.0)」に変更します。冒頭のサイトに合わせましたが、「WinUSB (v6.1.7600.16385)」他でも問題ないかもしれません。

再びコマンドを実行します。USBaspで書き込むためにオプションを変更しています。

.\avrdude.exe -C .\avrdude.conf -P usb -b 19200 -c usbasp -p m8 -U flash:w:..\usbasp.2011-05-28\usbasp.2011-05-28\bin\firmware\usbasp.atmega8.2011-05-28.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9307 (probably m8)
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: processing -U flash:w:..\usbasp.2011-05-28\usbasp.2011-05-28\bin\firmware\usbasp.atmega8.2011-05-28.hex:i
avrdude: reading input file ..\usbasp.2011-05-28\usbasp.2011-05-28\bin\firmware\usbasp.atmega8.2011-05-28.hex for flash
         with 4700 bytes in 1 section within [0, 0x125b]
         using 74 pages and 36 pad bytes
avrdude: writing 4700 bytes flash ...
Writing | ################################################## | 100% 2.20 s
avrdude: 4700 bytes of flash written
avrdude: verifying flash memory against ..\usbasp.2011-05-28\usbasp.2011-05-28\bin\firmware\usbasp.atmega8.2011-05-28.hex
Reading | ################################################## | 100% 1.31 s
avrdude: 4700 bytes of flash verified

avrdude done.  Thank you.

> .\avrdude.exe -P usb -b 19200 -c usbasp -p m8 -U hfuse:w:0xC9:m -U lfuse:w:0xEF:m
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9307 (probably m8)

avrdude: processing -U hfuse:w:0xC9:m
avrdude: reading input file 0xC9 for hfuse
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte hfuse ...
avrdude: 1 byte of hfuse written
avrdude: verifying hfuse memory against 0xC9
avrdude: 1 byte of hfuse verified

avrdude done.  Thank you.

以上で二つのUSBaspのファームウェアを更新できました。ArduinoISPと異なり、USBaspはTPIに対応しておりATtiny10への書き込みに使用できます。

  1. v1系のArduino IDEにはAVRDUDEが同梱されていたようですが、v2系では見当たらない?

  2. 0.1uFに理由があるわけではなく、たまたま手元にあっただけです。

  3. 最近のWindowsは標準で*.tar.gzを展開できます。

  4. Amazonレビューに石がコンパチだとハマるような報告がありますが、詳細は不明です。AVRDUDEのバージョンが違うはずなので、オプションが間違っていた可能性もありそうです。

0
0
0

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
0
0