INICIO   Otros temas


Instalación desde los fuentes del GNU ToolChain AVR

Autor: Fernando Rafael Filipuzzi

E-mail: fernando_6867@yahoo.com.ar



  1. Dependencias y Requerimientos:

    En el sitio http://www.nongnu.org/avr-libc/user-manual/install_tools.html se dan las instrucciones precisas para compilar el toolchain para los avr.

    Las características del host:

    	host:/# uname -a
    	Linux hp 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux
    	host:/# cat /etc/debian_version
    	7.2
    	host:/# cat /proc/cpuinfo
    	...
    	model name	: Intel(R) Core(TM)2 Duo CPU     T5470  @ 1.60GHz
    	...
    	host:/# cat /etc/issue
    	Debian GNU/Linux 7 \n \l
    
    	host:/# aptitude install lsb-release
    	host:/# lsb_release -a
    	No LSB modules are available.
    	Distributor ID:	Debian
    	Description:	Debian GNU/Linux 7.2 (wheezy)
    	Release:	7.2
    	Codename:	wheezy
    

    Aquí [enlace] comento la instalación de un entorno chroot

    Son necesarios algunos paquetes generales para construir los fuentes:

    	host:/# aptitude install make gcc build-essential
    	host:/# gcc -v
    	Using built-in specs.
    	COLLECT_GCC=gcc
    	COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
    	Target: x86_64-linux-gnu
    	Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
    	Thread model: posix
    	gcc version 4.7.2 (Debian 4.7.2-5) 
    

    Para comenzar con la construcción e instalación primero es necesario definir algunas variables:

    	host:/# PREFIX=$HOME/local/avr
    	host:/# export PREFIX
    	host:/# PATH=$PATH:$PREFIX/bin
    	host:/# export PATH
    

  2. GNU Binutils:

    Dependencias para la versión 2.24.

    	autoconf 2.64
    	automake 1.11
    	libtool 2.2.6
    	gettext 0.14.5
    

    Instalando las dependencias desde los repositorios de Wheezy:

    Para el caso de Etch o Lenny talvez los requerimientos de versiones no se cumplan, se pueden resolver estas dependencias bajando los fuentes y contruirlos, por ejemplo para libtool y gettext:

    Completadas las dependencias para binutils:

    	host:/usr/src/avrbinutil# wget http://ftp.gnu.org/pub/gnu/binutils/binutils-2.24.tar.gz
    	host:/usr/src/avrbinutil# tar zxvf binutils-2.24.tar.gz
    	host:/usr/src/avrbinutil# cd binutils-2.24
    	host:/usr/src/avrbinutil/binutils-2.24#	mkdir obj-avr && cd obj-avr
    	host:/usr/src/avrbinutil/binutils-2.24/obj-avr# ../configure --prefix=$PREFIX --target=avr --disable-nls
    	host:/usr/src/avrbinutil/binutils-2.24/obj-avr# make
    	host:/usr/src/avrbinutil/binutils-2.24/obj-avr# make install
    	host:/usr/src/avrbinutil/binutils-2.24/obj-avr# cd ../../..
    

    Los binarios como el enlazador, el ensamblador, etc se encontrar´n según el valor de PREFIX.


  3. GNU GCC

    Instalando algunas depedencias:

    	host:/usr/src# mkdir avrgcc && cd avrgcc
    	host:/usr/src/avrgcc# wget http://ftp.gnu.org/pub/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2
    	host:/usr/src/avrgcc# tar jxvf gcc-4.8.2.tar.bz2
    
    	host:/usr/src/avrgcc/gcc-4.8.2# mkdir obj-avr && cd obj-avr
    	host:/usr/src/avrgcc/gcc-4.8.2/obj-avr# ../configure --prefix=$PREFIX --target=avr --enable-languages=c,c++ \
    	> --disable-nls --disable-libssp --with-dwarf2
    	host:/usr/src/avrgcc/gcc-4.8.2/obj-avr# make
    	host:/usr/src/avrgcc/gcc-4.8.2/obj-avr# make install
    	host:/usr/src/avrgcc/gcc-4.8.2/obj-avr# cd ../../..
    

  4. AVR LibC

    	host:/usr/src# mkdir avrlibc && cd avrlibc
    	host:/usr/src/avrlibc# wget http://download.savannah.gnu.org/releases/avr-libc/avr-libc-1.8.0.tar.bz2
    	host:/usr/src/avrlibc# tar jxvf avr-libc-1.8.0.tar.bz2
    	host:/usr/src/avrlibc# cd avr-libc-1.8.0
    	host:/usr/src/avrlibc/avr-libc-1.8.0# ./configure --prefix=$PREFIX --build=`./config.guess` --host=avr
    	host:/usr/src/avrlibc/avr-libc-1.8.0# make
    	host:/usr/src/avrlibc/avr-libc-1.8.0# make install
    	host:/usr/src/avrlibc/avr-libc-1.8.0# cd ../..
    	host:/usr/src/avrlibc#
    

    Bajando la documentación:

    	host:/usr/src/avrlibc# wget http://download.savannah.gnu.org/releases/avr-libc/avr-libc-user-manual-1.8.0.tar.bz2
    

  5. AVRDUDE

    AVRDUDE es un programa para actualizar y leer la memoria flash y la memoria EEPROM de los microcontroladores de Atmel. En el sitio http://www.nongnu.org/avr-libc/user-manual/using_avrprog.html está su completa descripción.

    Completando las dependencias para la construcción de los fuentes:

    	host:/usr/src# aptitude install libusb-1.0-0-dev libusb-dev libftdi1 libftdi1-dbg libftdi-dev
    

    Construcción e instalación:

    	host:/usr/src# mkdir avrdude
    	host:/usr/src# cd avrdude
    	host:/usr/src/avrdude# wget http://download.savannah.gnu.org/releases/avrdude/avrdude-6.0.1.tar.gz
    	host:/usr/src/avrdude# tar zxvf avrdude-6.0.1.tar.gz
    	host:/usr/src/avrdude# cd avrdude-6.0.1
    	host:/usr/src/avrdude/avrdude-6.0.1# mkdir obj-avr && cd obj-avr
    	host:/usr/src/avrdude/avrdude-6.0.1/obj-avr# ../configure --prefix=$PREFIX
    

    Algunas dependencias necesarias se pueden ver despues del configure:

    	host:/usr/src/avrdude/avrdude-6.0.1/obj-avr# ../configure --prefix=$PREFIX
    	...
    	Configuration summary:
    	----------------------
    	DON'T HAVE libelf
    	DON'T HAVE libusb
    	DON'T HAVE libusb_1_0
    	DON'T HAVE libftdi1
    	DON'T HAVE libftdi
    	DON'T HAVE libhid
    	DO HAVE    pthread
    	DISABLED   doc
    	ENABLED    parport
    	DISABLED   linuxgpio
    

    Las otras no est´n en los repositorios.

    	host:/usr/src/avrdude/avrdude-6.0.1/obj-avr# make
    	host:/usr/src/avrdude/avrdude-6.0.1/obj-avr# make install
    	host:/usr/src/avrdude/avrdude-6.0.1/obj-avr# cd ../../..
    	host:/usr/src# 
    

    En el fichero de configuracion se puede encontrar información de los grabadores soportados por avrdude, este se encuentra en el fichero:

    	host:/usr/src# nano ~/local/avr/etc/avrdude.conf
    

    Bajando la documentación:

    	host:/usr/src# wget http://download.savannah.gnu.org/releases/avrdude/avrdude-doc-6.0.1.tar.gz
    

  6. GNU GDB

    Dependencias:

    	host:/usr/src/gdbavr/# aptitude install libncurses5-dev
    

    Continuando:

    	host:/usr/src# mkdir avrgdb && cd avrgdb
    	host:/usr/src/avrgdb# wget http://ftp.gnu.org/pub/gnu/gdb/gdb-7.6.tar.bz2
    	host:/usr/src/avrgdb# tar jxvf gdb-7.6.tar.bz2
    	host:/usr/src/avrgdb# cd gdb-7.6
    	host:/usr/src/avrgdb/gdb-7.6# mkdir obj-avr && cd obj-avr
    	host:/usr/src/avrgdb/gdb-7.6/obj-avr# ../configure --prefix=$PREFIX --target=avr
    	host:/usr/src/avrgdb/gdb-7.6/obj-avr# make
    	host:/usr/src/avrgdb/gdb-7.6/obj-avr# make install
    	host:/usr/src/avrgdb/gdb-7.6/obj-avr# cd ../../..
    

  7. SimulAVR

    	host:/usr/src# mkdir simulavr
    	host:/usr/src# cd simulavr
    	host:/usr/src/simulavr# wget http://download.savannah.gnu.org/releases/simulavr/simulavr-0.1.2.7.tar.gz
    	host:/usr/src/simulavr# tar zxvf simulavr-0.1.2.7.tar.gz
    	host:/usr/src/simulavr# cd simulavr-0.1.2.7
    	host:/usr/src/simulavr/simulavr-0.1.2.7# mkdir obj-avr
    	host:/usr/src/simulavr/simulavr-0.1.2.7# cd obj-avr
    	host:/usr/src/simulavr/simulavr-0.1.2.7/obj-avr# ../configure --prefix=$PREFIX
    	host:/usr/src/simulavr/simulavr-0.1.2.7/obj-avr# make -i
    	host:/usr/src/simulavr/simulavr-0.1.2.7/obj-avr# make -i install
    	host:/usr/src/simulavr/simulavr-0.1.2.7/obj-avr# cd ../../..
    

  8. AVaRICE

    	host:/usr/src# mkdir avarice
    	host:/usr/src# cd avarice
    	host:/usr/src/avarice# wget http://sourceforge.net/projects/avarice/files/avarice/avarice-2.13/avarice-2.13.tar.bz2
    	host:/usr/src/avarice# tar jxvf avarice-2.13.tar.bz2
    	host:/usr/src/avarice# cd avarice-2.13
    	host:/usr/src/avarice/avarice-2.13# mkdir obj-avr
    	host:/usr/src/avarice/avarice-2.13# cd obj-avr
    	host:/usr/src/avarice/avarice-2.13/obj-avr# ../configure --prefix=$PREFIX
    	host:/usr/src/avarice/avarice-2.13/obj-avr# make
    	host:/usr/src/avarice/avarice-2.13/obj-avr# make install
    	host:/usr/src/avarice/avarice-2.13/obj-avr# cd ../../..
    

  9. Binarios instalados:

    	host:~# tree ~/local/avr/bin
    	/root/local/avr/bin
    	├── avarice
    	├── avr-addr2line
    	├── avr-ar
    	├── avr-as
    	├── avr-c++
    	├── avr-c++filt
    	├── avr-cpp
    	├── avrdude
    	├── avr-elfedit
    	├── avr-g++
    	├── avr-gcc
    	├── avr-gcc-4.8.2
    	├── avr-gcc-ar
    	├── avr-gcc-nm
    	├── avr-gcc-ranlib
    	├── avr-gcov
    	├── avr-gdb
    	├── avr-gprof
    	├── avr-ld
    	├── avr-ld.bfd
    	├── avr-man
    	├── avr-nm
    	├── avr-objcopy
    	├── avr-objdump
    	├── avr-ranlib
    	├── avr-readelf
    	├── avr-run
    	├── avr-size
    	├── avr-strings
    	├── avr-strip
    	├── ice-gdb
    	├── ice-insight
    	├── kill-avarice
    	├── simulavr
    	├── simulavr-disp
    	└── start-avarice
    
    	0 directories, 36 files
    

    Es necesario agregar esta al PATH la localización de estos binarios.

    	host:~# export PATH=$PATH:"~/local/avr/bin"
    

  10. Problemas:

    1. Al ejecutar el configure de gcc:
      host:/usr/src/avrgcc/gcc-4.8.2/obj-avr# ../configure --prefix=$PREFIX --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2
      ...
      
      checking for objdir... .libs
      checking for the correct version of gmp.h... no
      configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
      Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
      their locations.  Source code for these libraries can be found at
      their respective hosting sites as well as at
      ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also
      http://gcc.gnu.org/install/prerequisites.html for additional info.  If
      you obtained GMP, MPFR and/or MPC from a vendor distribution package,
      make sure that you have installed both the libraries and the header
      files.  They may be located in separate packages.
      ...
      

      Solución: instalando las librerias GMP 4.2+, MPFR 2.4.0+ y MPC 0.8.0+ en esas versiones o superiores se arregla el problema.


    2. Al construir Simul AVR:
      	...
      	Making all in disp-vcd
      	make[3]: se ingresa al directorio `/usr/src/toolchain_avr/simulavr1/simulavr-0.1.2.7/obj-avr/src/disp-vcd'
      	gcc -DHAVE_CONFIG_H -I. -I../../../src/disp-vcd -I../../src    -Wall -Winline -Werror -I../../../src -I../../../src/getopt -Werror=unused-function -MT disp.o -MD -MP -MF .deps/disp.Tpo -c -o disp.o ../../../src/disp-vcd/disp.c
      	../../../src/disp-vcd/disp.c: In function ‘disp_parse_packet’:
      	../../../src/disp-vcd/disp.c:246:34: error: variable ‘areg’ set but not used [-Werror=unused-but-set-variable]
      	cc1: all warnings being treated as errors
      	make[3]: *** [disp.o] Error 1
      	make[3]: se sale del directorio `/usr/src/toolchain_avr/simulavr1/simulavr-0.1.2.7/obj-avr/src/disp-vcd'
      	make[2]: *** [all-recursive] Error 1
      	make[2]: se sale del directorio `/usr/src/toolchain_avr/simulavr1/simulavr-0.1.2.7/obj-avr/src'
      	make[1]: *** [all] Error 2
      	make[1]: se sale del directorio `/usr/src/toolchain_avr/simulavr1/simulavr-0.1.2.7/obj-avr/src'
      	make: *** [all-recursive] Error 1
      

      agregando areg=areg+0;

      	nano ../src/disp-vcd/disp.c
      

    3. 	...
      	mv -f .deps/config_parser.Tpo .deps/config_parser.Po
      	gcc -DHAVE_CONFIG_H -I. -I../../../src/disp-vcd -I../../src    -Wall -Winline -Werror -I../../../src -I../../../src/getopt -g -O2 -MT config_scanner.o -MD -MP -MF .deps/config_scanner.Tpo -c -o config_scanner.o ../../../src/disp-vcd/config_scanner.c
      	config_scanner.c:1188:12: error: ‘input’ defined but not used [-Werror=unused-function]
      	cc1: all warnings being treated as errors
      	make[3]: *** [config_scanner.o] Error 1
      	make[3]: se sale del directorio `/usr/src/toolchain_avr/simulavr1/simulavr-0.1.2.7/obj-avr/src/disp-vcd'
      	make[2]: *** [all-recursive] Error 1
      	make[2]: se sale del directorio `/usr/src/toolchain_avr/simulavr1/simulavr-0.1.2.7/obj-avr/src'
      	make[1]: *** [all] Error 2
      	make[1]: se sale del directorio `/usr/src/toolchain_avr/simulavr1/simulavr-0.1.2.7/obj-avr/src'
      	make: *** [all-recursive] Error 1
      

      Ignoré todos los errores con la opción -i

      	host:/usr/src/simulavr/simulavr-0.1.2.7# make -i
      	host:/usr/src/simulavr/simulavr-0.1.2.7# make -i install
      

    4. Error al construir gdb
      	...
      	host:/usr/src/avrgdb/gdb-7.6/obj-avr# ../configure --prefix=$PREFIX --target=avr
      	host:/usr/src/avrgdb/gdb-7.6/obj-avr# make
      	...
      	checking for library containing gethostbyname... none required
      	checking for library containing socketpair... none required
      	checking for library containing zlibVersion... no
      	checking for library containing dlgetmodinfo... no
      	checking for iconv... yes
      	checking for iconv declaration... install-shextern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
      	checking for library containing waddstr... no
      	configure: WARNING: no enhanced curses library found; disabling TUI
      	checking for library containing tgetent... no
      	configure: error: no termcap library found
      	make[1]: *** [configure-gdb] Error 1
      	make[1]: se sale del directorio `/usr/src/avrgdb/gdb-7.6/obj-avr'
      	make: *** [all] Error 2
      	...
      

      Solución:

      	host:/usr/src/gdbavr/# aptitude install libncurses5-dev
      


  11. Enlaces y referencias:

    1. Enlaces y referencias


INICIO   Otros temas