AVR開発環境をサーバ側に移行します。以前製作したAVRライタをLinuxで使うために、AVRDUDEをインストールしました。
参考にしたページ
追記分。
東京でセキュリティの仕事をしている小江戸民のブログ
ダウンロードとインストールは普通に完了しました。
[root@reisato ~]# wget http://download.savannah.gnu.org/releases/avrdude/avrdude-5.3.1.tar.gz [root@reisato ~]# tar zxvf avrdude-5.3.1.tar.gz [root@reisato avrdude-5.3.1]# ./configure (略) checking for parallel device... /dev/parport0 checking for serial device... /dev/ttyS0 configure: creating ./config.status config.status: creating windows/Makefile config.status: creating avrdude.spec config.status: creating Makefile config.status: creating avrdude.conf.tmp config.status: creating ac_cfg.h config.status: executing depfiles commands [root@reisato avrdude-5.3.1]# make [root@reisato avrdude-5.3.1]# make check make[1]: Entering directory `/root/avrdude-5.3.1' make[1]: `check-am' に対して行うべき事はありません。 make[1]: Leaving directory `/root/avrdude-5.3.1' [root@reisato avrdude-5.3.1]# make install make[1]: Entering directory `/root/avrdude-5.3.1' make[2]: Entering directory `/root/avrdude-5.3.1' test -z "/usr/local/bin" || mkdir -p -- "/usr/local/bin" /usr/bin/install -c 'avrdude' '/usr/local/bin/avrdude' Backing up avrdude.conf in /usr/local/etc test -z "/usr/local/etc" || mkdir -p -- "/usr/local/etc" /usr/bin/install -c -m 644 'avrdude.conf' '/usr/local/etc/avrdude.conf' test -z "/usr/local/man/man1" || mkdir -p -- "/usr/local/man/man1" /usr/bin/install -c -m 644 './avrdude.1' '/usr/local/man/man1/avrdude.1' make[2]: Leaving directory `/root/avrdude-5.3.1' make[1]: Leaving directory `/root/avrdude-5.3.1'
[root@reisato]# avrdude Usage: avrdude [options] Options: -p <partno> Required. Specify AVR device. -b <baudrate> Override RS-232 baud rate. -B <bitclock> Specify JTAG/STK500v2 bit clock period (us). -C <config-file> Specify location of configuration file. -c <programmer> Specify programmer type. -D Disable auto erase for flash memory -i <delay> ISP Clock Delay [in microseconds] -P <port> Specify connection port. -F Override invalid signature check. -e Perform a chip erase. -O Perform RC oscillator calibration (see AVR053). -U <memtype>:r|w|v:<filename>[:format] Memory operation specification. Multiple -U options are allowed, each request is performed in the order specified. -n Do not write anything to the device. -V Do not verify. -u Disable safemode, default when running from a script. -s Silent safemode operation, will not ask you if fuses should be changed back. -t Enter terminal mode. -E <exitspec>[,<exitspec>] List programmer exit specifications. -y Count # erase cycles in EEPROM. -Y <number> Initialize erase cycle # in EEPROM. -v Verbose output. -v -v for more. -q Quell progress output. -q -q for less. -? Display this usage. avrdude project: <URL:http://savannah.nongnu.org/projects/avrdude> [root@reisato]# man avrdude AVRDUDE(1) BSD General Commands Manual AVRDUDE(1) NAME avrdude - driver program for ‘‘simple’’ Atmel AVR MCU programmer SYNOPSIS avrdude -p partno [-b baudrate] [-B bitclock] [-c programmer-id] [-C config-file] [-D] [-e] [-E exitspec[,exitspec]] [-F] [-i delay] [-n] [-O] [-P port] [-q] [-s] [-t] [-u] [-U memtype:op:filename:filefmt] [-v] [-V] [-y] [-Y] (略) Options In order to control all the different operation modi, a number of options need to be specified to avrdude. -p partno This is the only option that is mandatory for every invocation of avrdude. It specifies the type of the MCU connected to the program- mer. These are read from the config file. If avrdude does not know about a part that you have, simply add it to the config file (be sure and submit a patch back to the author so that it can be incor- porated for the next version). See the sample config file for the format. Currently, the following MCU types are understood: Option tag Official part name c128 AT90CAN128 pwm2 AT90PWM2 pwm3 AT90PWM3 1200 AT90S1200 2313 AT90S2313 2333 AT90S2333 2343 AT90S2343 (*) 4414 AT90S4414 4433 AT90S4433 4434 AT90S4434 8515 AT90S8515 8535 AT90S8535 m103 ATmega103 m128 ATmega128 m1280 ATmega1280 m1281 ATmega1281 m16 ATmega16 m161 ATmega161 m162 ATmega162 m163 ATmega163 m164 ATmega164 m169 ATmega169 m2560 ATmega2560 (**) m2561 ATmega2561 (**) m32 ATmega32 m324 ATmega324 m329 ATmega329 m3290 ATmega3290 m48 ATmega48 m64 ATmega64 m640 ATmega640 m644 ATmega644 m649 ATmega649 m6490 ATmega6490 m8 ATmega8 m8515 ATmega8515 m8535 ATmega8535 m88 ATmega88 t12 ATtiny12 t13 ATtiny13 t15 ATtiny15 t2313 ATtiny2313 t25 ATtiny25 t26 ATtiny26 t45 ATtiny45 t85 ATtiny85 (*) The AT90S2323 and ATtiny22 use the same algorithm. (**) Flash addressing above 128 KB is not supported by all pro- gramming hardware. Known to work are jtag2, stk500v2, and bit-bang programmers. (略) -c programmer-id Use the pin configuration specified by the argument. Pin configura- tions are read from the config file (see the -C option). New pin configurations can be easily added or modified through the use of a config file to make avrdude work with different programmers as long as the programmer supports the Atmel AVR serial program method. You can use the ’default_programmer’ keyword in your ${HOME}/.avrduderc file to assign a default programmer to keep from having to specify this option on every invocation. (略) BSD February 10, 2007 BSD [root@reisato]# avrdude -p t2313 -c ? Valid programmers are: dasa3 = serial port banging, reset=!dtr sck=rts mosi=txd miso=cts [/usr/local/etc/avrdude.conf:757] dasa = serial port banging, reset=rts sck=dtr mosi=txd miso=cts [/usr/local/etc/avrdude.conf:744] siprog = Lancos SI-Prog <http://www.lancos.com/siprogsch.html> [/usr/local/etc/avrdude.conf:731] ponyser = design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts [/usr/local/etc/avrdude.conf:718] frank-stk200 = Frank STK200 [/usr/local/etc/avrdude.conf:683] blaster = Altera ByteBlaster [/usr/local/etc/avrdude.conf:670] ere-isp-avr = ERE ISP-AVR <http://www.ere.co.th/download/sch050713.pdf> [/usr/local/etc/avrdude.conf:660] atisp = AT-ISP V1.1 programming cable for AVR-SDK1 from <http://micro-research.co.th/> [/usr/local/etc/avrdude.conf:650] dapa = Direct AVR Parallel Access cable [/usr/local/etc/avrdude.conf:639] xil = Xilinx JTAG cable [/usr/local/etc/avrdude.conf:626] futurlec = Futurlec.com programming cable. [/usr/local/etc/avrdude.conf:609] abcmini = ABCmini Board, aka Dick Smith HOTCHIP [/usr/local/etc/avrdude.conf:599] picoweb = Picoweb Programming Cable, http://www.picoweb.net/ [/usr/local/etc/avrdude.conf:589] sp12 = Steve Bolt's Programmer [/usr/local/etc/avrdude.conf:578] alf = Nightshade ALF-PgmAVR, http://nightshade.homeip.net/ [/usr/local/etc/avrdude.conf:562] bascom = Bascom SAMPLE programming cable [/usr/local/etc/avrdude.conf:552] dt006 = Dontronics DT006 [/usr/local/etc/avrdude.conf:542] pony-stk200 = Pony Prog STK200 [/usr/local/etc/avrdude.conf:530] stk200 = STK200 [/usr/local/etc/avrdude.conf:514] bsd = Brian Dean's Programmer, http://www.bsdhome.com/avrdude/ [/usr/local/etc/avrdude.conf:503] pavr = Jason Kyle's pAVR Serial Programmer [/usr/local/etc/avrdude.conf:495] dragon_dw = Atmel AVR Dragon in debugWire mode [/usr/local/etc/avrdude.conf:488] dragon_hvsp = Atmel AVR Dragon in HVSP mode [/usr/local/etc/avrdude.conf:480] dragon_pp = Atmel AVR Dragon in PP mode [/usr/local/etc/avrdude.conf:472] dragon_isp = Atmel AVR Dragon in ISP mode [/usr/local/etc/avrdude.conf:464] dragon_jtag = Atmel AVR Dragon in JTAG mode [/usr/local/etc/avrdude.conf:456] jtag2dw = Atmel JTAG ICE mkII in debugWire mode [/usr/local/etc/avrdude.conf:448] jtag2isp = Atmel JTAG ICE mkII in ISP mode [/usr/local/etc/avrdude.conf:440] jtag2 = Atmel JTAG ICE mkII [/usr/local/etc/avrdude.conf:432] jtag2fast = Atmel JTAG ICE mkII [/usr/local/etc/avrdude.conf:424] jtag2slow = Atmel JTAG ICE mkII [/usr/local/etc/avrdude.conf:416] jtagmkII = Atmel JTAG ICE mkII [/usr/local/etc/avrdude.conf:408] jtag1slow = Atmel JTAG ICE (mkI) [/usr/local/etc/avrdude.conf:401] jtag1 = Atmel JTAG ICE (mkI) [/usr/local/etc/avrdude.conf:393] jtagmkI = Atmel JTAG ICE (mkI) [/usr/local/etc/avrdude.conf:385] avr911 = Atmel AppNote AVR911 AVROSP [/usr/local/etc/avrdude.conf:379] avr109 = Atmel AppNote AVR109 Boot Loader [/usr/local/etc/avrdude.conf:373] butterfly = Atmel Butterfly Development Board [/usr/local/etc/avrdude.conf:367] usbasp = USBasp, http://www.fischl.de/usbasp/ [/usr/local/etc/avrdude.conf:361] avr910 = Atmel Low Cost Serial Programmer [/usr/local/etc/avrdude.conf:355] stk500hvsp = Atmel STK500 V2 in high-voltage serial programming mode [/usr/local/etc/avrdude.conf:349] stk500pp = Atmel STK500 V2 in parallel programming mode [/usr/local/etc/avrdude.conf:343] stk500v2 = Atmel STK500 Version 2.x firmware [/usr/local/etc/avrdude.conf:337] stk500v1 = Atmel STK500 Version 1.x firmware [/usr/local/etc/avrdude.conf:331] stk500 = Atmel STK500 [/usr/local/etc/avrdude.conf:325] avrisp2 = Atmel AVR ISP mkII [/usr/local/etc/avrdude.conf:315] avrispmkII = Atmel AVR ISP mkII [/usr/local/etc/avrdude.conf:309] avrispv2 = Atmel AVR ISP V2 [/usr/local/etc/avrdude.conf:303] avrisp = Atmel AVR ISP [/usr/local/etc/avrdude.conf:297]
ChaN氏のライタにの為の設定をダウンロードし、もともとの設定ファイルに追加します。
[root@reisato ~]# wget http://elm-chan.org/works/avrx/avrdude.conf.txt [root@reisato ~]# cat avrdude.conf.txt # unknown (avrsp) # reset=dtr sck=rts mosi=txd miso=dsr programmer id = "avrsp"; desc = "serial port banging, reset=dtr sck=rts mosi=txd miso=dsr"; type = serbb; reset = 4; sck = 6; mosi = 3; miso = 5; ; [root@reisato ~]# cp /usr/local/etc/avrdude.conf /usr/local/etc/avrdude.conf.bak [root@reisato ~]# cat avrdude.conf.txt >> /usr/local/etc/avrdude.conf [root@reisato ~]# avrdude -p t2313 -c avrsp /dev/parport0: tcgetattr: Invalid argument ioctl("TIOCMGET"): Invalid argument avrdude done. Thank you.
あぁ、接続ポートがパラレルポート(parport0)っぽい。シリアルポートなので./configureしたときに/dev/ttyS0と出たのでそれを指定してみます。
[root@reisato ~]# avrdude -p t2313 -c avrsp -P /dev/ttyS0 avrdude: AVR device not responding avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. avrdude done. Thank you.
ん?検索してみるとOKAZAKI氏のページ(AO diary)にAVRライタ製作集 [elm-chan.org] で配布されているコンフィグレーションファイル avrdude.conf.txt [elm-chan.org] では動作しなかった.
とあるので、設定が適切ではないみたいです。
そのまま書き換えてみる。
[root@reisato ~]# emacs /usr/local/etc/avrdude.conf [root@reisato ~]# cat /usr/local/etc/avrdude.conf | tail programmer id = "avrsp"; desc = "serial port banging, reset=dtr sck=rts mosi=txd miso=dsr"; type = serbb; reset = 4; sck = 7; mosi = 3; miso = 6; ; [root@reisato ~]# avrdude -p t2313 -c avrsp -P /dev/ttyS0 avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.00s avrdude: Device signature = 0x1e910a avrdude: safemode: Fuses OK avrdude done. Thank you. [root@reisato ~]#
お、見えましたね。
avrsp -rの結果にあるDevice Signature = 1E-91-0Aと一致したので良しとしましょう。
[追記]
そうだ、コンパイラ忘れてたと思ってさらに調べてみると…
これらのツールは通常はすべてを /usr/local ディレクトリにインストールしようとします。AVRツールを基本的なプログラムから分離しておくために、通常は /usr/local/avr にAVR開発環境のすべてをインストールする方がよいでしょう。
ふむ、そうしたほうがいいか。
まずAVRDUDEの仕切りなおし。make uninstallが使えたのでラッキー。
[root@reisato ~]# cd avrdude-5.3.1 [root@reisato avrdude-5.3.1]# make uninstall make[1]: Entering directory `/root/avrdude-5.3.1' rm -f '/usr/local/bin/avrdude' rm -f '/usr/local/man/man1/avrdude.1' rm -f '/usr/local/etc/avrdude.conf' make[1]: Leaving directory `/root/avrdude-5.3.1' [root@reisato avrdude-5.3.1]# cd [root@reisato ~]# rm -rf avrdude-5.3.1
どばどばっとダウンロードして展開します。
[root@reisato ~]# wget http://ftp.gnu.org/gnu/binutils/binutils-2.17.tar.bz2 [root@reisato ~]# wget ftp://ftp.iij.ad.jp/pub/gcc/releases/gcc-4.1.1/gcc-4.1.1.tar.bz2 [root@reisato ~]# wget http://download.savannah.gnu.org/releases/avr-libc/avr-libc-1.2.6.tar.bz2
あとはavr-gccで遊ぶで紹介されている方法をそのまま実行しました。