embeded/AVR (ATmega,ATtiny)2015. 7. 30. 17:46

이러다가 조만간.. 메인 컴터를 리눅이로 갈아 탈듯 -_-

(게임도 안하는데 머...)



$ sudo apt-get install gcc-avr avr-libc avrdude 

[링크 : http://eiggerc.blogspot.kr/2013/03/ubuntu-avr.html]


올 ㅋ

pi@raspberrypi ~ $ avr-

avr-addr2line   avr-c++filt     avr-gcc-4.7.2   avr-gcov        avr-nm          avr-readelf

avr-ar          avr-cpp         avr-gcc-ar      avr-gprof       avr-objcopy     avr-size

avr-as          avr-g++         avr-gcc-nm      avr-ld          avr-objdump     avr-strings

avr-c++         avr-gcc         avr-gcc-ranlib  avr-man         avr-ranlib      avr-strip 


c++ 예제.파일 갯수가 여러개이니 왜 DDRA나 이런게 없냐고 하지 말자?

ATmega1284P.h

AvrBlinkenLed.cpp

IOPort.h

IOPort.cpp

Led.h

Led.cpp 

[링크 : http://10rem.net/.../gnu-cplusplus-blinkenled-part-1...]


project & makefile

$ avr-c++ -mmcu=atmega128 IOPort.cpp

[링크 : http://www.nongnu.org/avr-libc/user-manual/group__demo__project.html]


avr-gcc 기본 헤더 경로 확인

pi@raspberrypi ~/src/avr $ avr-gcc -print-file-name=include

/usr/lib/gcc/avr/4.7.2/include 

[링크 : http://ubuntuforums.org/showthread.php?t=1014673]


위의 예제는 직접 DDRA나 PORTA 등을 선언해서 쓴것이고

원래는 아래 경로의 io.h 를 끌어오면 알아서 mmcu에 맞춰서 하위 헤더를 끌어오게 된다.

pi@raspberrypi ~/src/avr $ sudo find / -name io.h

/usr/lib/avr/include/avr/io.h 


빌드는 성공! 굽는건 나중에 
pi@raspberrypi ~/src/avr $ make
avr-c++ -mmcu=atmega128 IOPort.cpp AvrBlinkenLed.cpp
In file included from IOPort.h:12:0,
                 from AvrBlinkenLed.cpp:10:
ATmega1284P.h:14:0: warning: "PINA" redefined [enabled by default]
In file included from /usr/lib/gcc/avr/4.7.2/../../../avr/include/avr/io.h:150:0,
                 from AvrBlinkenLed.cpp:9:
/usr/lib/gcc/avr/4.7.2/../../../avr/include/avr/iom128.h:135:0: note: this is the location of the previous definition
In file included from IOPort.h:12:0,
                 from AvrBlinkenLed.cpp:10:
ATmega1284P.h:15:0: warning: "DDRA" redefined [enabled by default]
In file included from /usr/lib/gcc/avr/4.7.2/../../../avr/include/avr/io.h:150:0,
                 from AvrBlinkenLed.cpp:9:
/usr/lib/gcc/avr/4.7.2/../../../avr/include/avr/iom128.h:138:0: note: this is the location of the previous definition
In file included from IOPort.h:12:0,
                 from AvrBlinkenLed.cpp:10:
ATmega1284P.h:16:0: warning: "PORTA" redefined [enabled by default]
In file included from /usr/lib/gcc/avr/4.7.2/../../../avr/include/avr/io.h:150:0,
                 from AvrBlinkenLed.cpp:9:
/usr/lib/gcc/avr/4.7.2/../../../avr/include/avr/iom128.h:141:0: note: this is the location of the previous definition



2009/04/07 - [embeded/AVR (ATmega/ATtiny)] - linux에서 AVR 컴파일하기



'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

키보드 DIY 자료  (0) 2015.09.23
avr-gcc -mmcu 관련 작동 내용  (0) 2015.08.02
USART UBRR error rate  (0) 2015.07.29
avr-libc 8bit AVR C++  (0) 2015.07.28
avr twi / i2c 예제 및 풀업관련  (0) 2015.07.19
Posted by 구차니