2015年8月19日水曜日

AVR開発環境設定 for Ubuntu 15.04 (Part2) [ AVR ]

前回の設定だけではrootユーザでないと、AVRに書き込めないので makeで自動処理できなくて困る。
なので、Kenichiro MATOHARAさんのスライドに書いてあったように、udevの設定を行う。

しかし、うごかない。なんで??よーく見たら、=== をきちんと見てなかったみたい。で、直してみてもう一度・・・・
やっぱり、認識せんぞ??
ん??何か変だなこの設定ファイル・・・
お、間違いを発見!! 先頭のATTRが抜け落ちてますぜ。
で、修正したのがこれです↓
/etc/udev/rules.d/50-avr.rulesATTR{idVendor}=="03eb",ATTR{idProduct}=="2104",MODE="0660",GROUP="plugdev",SYMLINK+="avrisp_mk2"
この設定で、AVRISPmkIIを接続したら、上手く認識したみたい。。。
デバイスファイルを見てみる$ ls /dev/avr*
/dev/avrisp_mk2

ちなみに、lsusbコマンドで、idVendorとidProductは確認できるよ。
あとの細かいことは、SUSE Linuxのページに詳しく書いてある。

適当に、Makefileを作ってみる。
MakefilePROGRAM = hello

F_CPU = 1000000UL
CC = avr-gcc
CFLAGS = -g -O2 -mmcu=attiny2313 -std=c99

OBJCP = avr-objcopy
OFLAGS = -j .text -j .data -O ihex

AVRDUDE = avrdude
AFLAGS = -e -c avrisp2 -p t2313

.SUFFIXES: .c .elf
.PHONY: clean install

$(PROGRAM).hex: $(PROGRAM).elf
 $(OBJCP) $(OFLAGS) $< $@

.c.elf:
 $(CC) $(CFLAGS) -o $@ -DF_CPU=$(F_CPU) $<

install: $(PROGRAM).hex
 $(AVRDUDE) $(AFLAGS) -U flash:w:$(PROGRAM).hex

clean:
 rm -f *.o *.elf *.hex
makeを実行$ make install
avr-gcc -g -O2 -mmcu=attiny2313 -std=c99 -o hello.elf -DF_CPU=1000000UL hello.c
avr-objcopy -j .text -j .data -O ihex hello.elf hello.hex
avrdude -e -c avrisp2 -p t2313 -U flash:w:hello.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e910a
avrdude: erasing chip
avrdude: reading input file "hello.hex"
avrdude: input file hello.hex auto detected as Intel Hex
avrdude: writing flash (110 bytes):

Writing | ################################################## | 100% 0.07s

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

Reading | ################################################## | 100% 0.07s

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

avrdude: safemode: Fuses OK (E:FF, H:DF, L:64)

avrdude done.  Thank you.
はい、よくできましたぁ。
めでたし、めでたし・・・・

ふんどしの持ち主

0 件のコメント:

コメントを投稿