AVR crosscompile

Crosscompile chain pro AVR na Gentoo (+update)

Code:

# USE="-nls -openmp -pch -sanitize -vtv" crossdev -t avr -s4 --without-headers
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 * crossdev version:      20151026
 * Host Portage ARCH:     amd64
 * Target Portage ARCH:   *
 * Target System:         avr
 * Stage:                 4 (C/C++ compiler)
 * ABIs:                  default

 * binutils:              binutils-[latest]
 * gcc:                   gcc-[latest]
 * libc:                  avr-libc-[latest]

 * CROSSDEV_OVERLAY:      /usr/local/portage-crossdev
 * PORT_LOGDIR:           /var/log/portage
 * PORTAGE_CONFIGROOT:
 * Portage flags:
  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~
 * leaving sys-devel/binutils in /usr/local/portage-crossdev
 * leaving sys-devel/gcc in /usr/local/portage-crossdev
 * leaving dev-embedded/avr-libc in /usr/local/portage-crossdev
 * leaving sys-devel/gdb in /usr/local/portage-crossdev
 * leaving metadata/layout.conf alone in /usr/local/portage-crossdev
  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~
 * Log: /var/log/portage/cross-avr-binutils.log
 * Emerging cross-binutils ...                                                                                                                                                                                                                                               [ ok ]
 * Log: /var/log/portage/cross-avr-gcc-stage1.log
 * Emerging cross-gcc-stage1 ...                                                                                                                                                                                                                                             [ ok ]
 * Log: /var/log/portage/cross-avr-avr-libc.log
 * Emerging cross-avr-libc ...                                                                                                                                                                                                                                               [ ok ]
 * Log: /var/log/portage/cross-avr-gcc-stage2.log
 * Emerging cross-gcc-stage2 ...                                                                                                                                                                                                                                             [ ok ]
# updatedb
# locate ldscripts/avr5.x
...
/usr/lib64/binutils/avr/2.26.1/ldscripts/avr5.x
# ln -s /usr/lib64/binutils/avr/2.26.1/ldscripts /usr/avr/lib/ldscripts

simple self test na ověření, že to aspoň nějak funguje: simple_self_test.sh a jeho zdroj

example build:

#!/bin/bash -x
# vim: fileencoding=utf-8:nomodified:nowrap:textwidth=0:foldmethod=marker:foldcolumn=4:syntax=sh:filetype=sh:ruler:showcmd:lcs=tab\:|- list
#|
if [ "$1" == "clean" ] ; then
  rm  *.elf *.asm *.dump  *.hdump  *.hex  *.o
  #*
  exit
fi

avr-gcc -c example.cpp -o example.o
avr-gcc -c lib_4DM8010.cpp -o lib_4DM8010.o
avr-gcc example.o lib_4DM8010.o -o example.elf
avr-objcopy -O ihex -R .eeprom example.elf example.hex
avr-gcc  -S -c  example.cpp -o example.asm
avr-objdump -DCfhlSwz example.elf >example.dump
avr-objdump -DCfhlSwz -m avr  example.hex >example.hdump

Update troubleshooting:

  • Nějak mi přestalo kompilování jít, projevovalo se to následující chybou (ostatně proto vzniknul simple_self_test.sh, viz výše)
ldscripts/avr5.xn:17: nonconstant expression for length
collect2: error: ld returned 1 exit status
  • Řešení: nakonec jsem zjistil, že mám v systému nejméně dvě verze těch crossutils (avr-*) nakonec jsem odinstaloval co se dalo, promazal ručně artefakty a znova nainstaloval, teď už to zase jde

  • Po reinstalaci a spuštění testu nastala tato chyba:
/usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr5.xn: No such file or directory
collect2: error: ld returned 1 exit status
  • Řešení:
ln -s /usr/x86_64-pc-linux-gnu/avr/lib/ldscripts /usr/avr/lib/ldscripts

Comments

Comments powered by Disqus