Difference between revisions of "Gentoo: crossdev avr"

From Luky-Wiki
Jump to: navigation, search
(Problem to compile AVR target)
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== Cross compile ? ==
 
== Cross compile ? ==
Cross compile is name of build process which produce machine code for different architecture. For example I am also embed device developer and i am producing machine code for AVR platform on x86_64 workstation. Effectively I am doing cross compile on x86_64 to AVR target. I am writing source code in C language and partly in assembler.
+
Cross compile is name of build process which produce machine code for different architecture. For example I am also embed device developer and I produce machine code for AVR platform on x86_64 workstation. Effectively I am doing cross compile on x86_64 to AVR target. I am writing source code in C language and partly in assembler.
 
== Why sys-devel/crossdev ? ==
 
== Why sys-devel/crossdev ? ==
Because it is Gentoo specific tool to manage necessary software to perform cross compile (e.g. binutils, headers, libraries, and compiler). It is very simple to use so i save some of my time during installation of crossdev environment.
+
Because it is Gentoo specific tool to manage necessary software to perform cross compile (e.g. binutils, headers, libraries, and compiler). It is very simple to use and it save time.
 +
 
 
== Installation of AVR target ==
 
== Installation of AVR target ==
 
=== sys-devel/crossdev ===
 
=== sys-devel/crossdev ===
Line 12: Line 13:
 
If directory dont exist then create it
 
If directory dont exist then create it
 
<pre>mkdir -p /opt/local/portage</pre>
 
<pre>mkdir -p /opt/local/portage</pre>
crossdev is using new layout of /etc/portage/package.* . If you don't migrated to this layout then you should to it now. New layout is expecting /etc/portage/package.keywords/ (and all others) to be a directory and configuration in files inside of it. For example for AVR target you can find cross-avr there.
+
crossdev is using new layout of /etc/portage/package.* . If you don't migrated to this layout yet then you should to it now. New layout is expecting /etc/portage/package.keywords/ (and all others) to be a directory and configuration in files inside of it.
 +
 
 
=== installation of cross compile tools ===
 
=== installation of cross compile tools ===
 
Just invoke:
 
Just invoke:
Line 45: Line 47:
 
  * Emerging cross-gcc-stage2 ...                                            [ ok ]
 
  * Emerging cross-gcc-stage2 ...                                            [ ok ]
 
</pre>
 
</pre>
If this end with no problem then you can start compiling code for AVR platform using "avr-gcc".<br><br>
+
If no errors reported then you can start using AVR-GCC just by typing "avr-gcc" to command line.<br><br>
Just for reference i included name and version installed by crossdev tool:
+
Just for reference I included name and version installed by crossdev tool (this may be bit old right now):
 
<pre>
 
<pre>
 
# eix -c cross-avr/*
 
# eix -c cross-avr/*
Line 56: Line 58:
 
#
 
#
 
</pre>
 
</pre>
 +
 
=== de-installation of cross compile tools ===
 
=== de-installation of cross compile tools ===
 
If you whould like to remove AVR tools then simply enter following command:
 
If you whould like to remove AVR tools then simply enter following command:
Line 61: Line 64:
 
If crossdev is no longer required on machine then it can be removed using portage command:
 
If crossdev is no longer required on machine then it can be removed using portage command:
 
<pre>emerge -C crossdev</pre>
 
<pre>emerge -C crossdev</pre>
I don't recommend to remove crossdev if there are still present targets installed using crossdev.
+
I don't recommend to remove crossdev if there are still targets installed using crossdev.
 +
 
 
=== workarounds ===
 
=== workarounds ===
 
==== Problem with linker 1 ====
 
==== Problem with linker 1 ====
Line 81: Line 85:
 
# ln -s /usr/avr/lib/avr5/crtm328p.o /usr/avr/lib/crtm328p.o
 
# ln -s /usr/avr/lib/avr5/crtm328p.o /usr/avr/lib/crtm328p.o
 
</pre>
 
</pre>
 +
 +
==== Problem to compile AVR target ====
 +
<pre>C compiler cannot create executables.</pre>
 +
or similar errors during compilation of AVR target. More details @ [https://forums.gentoo.org/viewtopic-t-1002994.html cross-avr/gcc fails to emerge]
 +
 +
Fix:
 +
<pre>echo "cross-avr/gcc -sanitize" > /etc/portage/package.use/avr-gcc-disable-sanitize</pre>

Latest revision as of 18:13, 13 February 2016

Cross compile ?

Cross compile is name of build process which produce machine code for different architecture. For example I am also embed device developer and I produce machine code for AVR platform on x86_64 workstation. Effectively I am doing cross compile on x86_64 to AVR target. I am writing source code in C language and partly in assembler.

Why sys-devel/crossdev ?

Because it is Gentoo specific tool to manage necessary software to perform cross compile (e.g. binutils, headers, libraries, and compiler). It is very simple to use and it save time.

Installation of AVR target

sys-devel/crossdev

I recommend latest version of sys-devel/crossdev so first of all put this ebuild to package.keywords. This package don't have USE flags so it is enough to perform:

emerge crossdev

required configuration

crossdev is using own local portage overlay to build target specific configuration. Following line is necessarily in /etc/make.conf. Of course you can use different location :)

PORTDIR_OVERLAY="/opt/local/portage"

If directory dont exist then create it

mkdir -p /opt/local/portage

crossdev is using new layout of /etc/portage/package.* . If you don't migrated to this layout yet then you should to it now. New layout is expecting /etc/portage/package.keywords/ (and all others) to be a directory and configuration in files inside of it.

installation of cross compile tools

Just invoke:

crossdev -t avr

And you should see following:

 * crossdev version:      20120721
 * 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:      /opt/local/portage
 * PORT_LOGDIR:           /var/log/portage
 * PORTAGE_CONFIGROOT:
 * Portage flags:
!!! WARNING - Cannot auto-configure CHOST avr
!!! You should edit /usr/avr/etc/portage/make.conf
!!! by hand to complete your configuration
 * 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 ]

If no errors reported then you can start using AVR-GCC just by typing "avr-gcc" to command line.

Just for reference I included name and version installed by crossdev tool (this may be bit old right now):

# eix -c cross-avr/*
[I] cross-avr/avr-libc [1] (1.8.0[?]@03.08.2012): C library for Atmel AVR microcontrollers
[I] cross-avr/binutils [1] (2.22.90[?]@03.08.2012): Tools necessary to build programs
[I] cross-avr/gcc [1] (4.6.3(4.6)[?]@03.08.2012): The GNU Compiler Collection
[N] cross-avr/gdb [1] ((~)7.4.1): GNU debugger
[1] /opt/local/portage
#

de-installation of cross compile tools

If you whould like to remove AVR tools then simply enter following command:

crossdev -C avr

If crossdev is no longer required on machine then it can be removed using portage command:

emerge -C crossdev

I don't recommend to remove crossdev if there are still targets installed using crossdev.

workarounds

Problem with linker 1

 /usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr5.x: No such file or directory 

Fix:

# locate ldscripts/avr5.x
/usr/lib64/binutils/avr/2.22.90/ldscripts/avr5.x

# ln -s /usr/lib/binutils/avr/2.22.90/ldscripts /usr/avr/lib/ldscripts

Problem with linker 2

/usr/libexec/gcc/avr/ld: cannot find crtm328p.o: No such file or directory 

Fix:

# locate crtm328p.o
/usr/avr/lib/avr5/crtm328p.o

# ln -s /usr/avr/lib/avr5/crtm328p.o /usr/avr/lib/crtm328p.o

Problem to compile AVR target

C compiler cannot create executables.

or similar errors during compilation of AVR target. More details @ cross-avr/gcc fails to emerge

Fix:

echo "cross-avr/gcc -sanitize" > /etc/portage/package.use/avr-gcc-disable-sanitize