Paludis/AVR Crossdev

From Gentoo Linux Wiki
Jump to: navigation, search

Contents

[edit] Note

I suggest using crossdev as intended for crossdev environments. Paludis seems to somewhat cope with it, i.e. it doesn’t conflict with it so one can just install stuff using it. There is no alternative script for it and maintaining this stuff by hand is PITA. Paludis specific fixes seems to still apply, though. Or maybe they even are not paludis specific, but who knows, that’s Gentoo for you.

[edit] End of note

This is a small HOWTO for installing an AVR toolchain with Paludis.

AVR is a 8-bit microcontroller. [1] [2] You can compile programs for it with avr-gcc.

Paludis doesn't have a crossdev-like tool, but it is simple to make toolchains through.

[edit] Cross repository

First you need to create new repo for cross packages.

File: /etc/paludis/repositories/cross-repo.conf
master_repository = gentoo
format = ebuild
location = /usr/local/cross-overlay/
names_cache = /var/cache/paludis/names
write_cache = /var/cache/paludis/metadata

Next make directory /usr/local/cross-overlay and there cross-avr, make symlinks for needed packages and create profiles/repo_name and profiles/categories.

mkdir /usr/local/cross-overlay

cd /usr/local/cross-overlay mkdir cross-avr mkdir profiles cd cross-avr ln -s /usr/portage/sys-devel/binutils . ln -s /usr/portage/sys-devel/gcc . ln -s /usr/portage/dev-embedded/avr-libc . cd .. echo "cross-repo" > profiles/repo_name echo "cross-avr" > profiles/categories

paludis --sync cross-repo

[edit] bashrc

You need to add this to /etc/paludis/bashrc:

Code:
if [[ "${CATEGORY}" == "cross-avr" ]]
then
    if [[ "${PN}" != "gcc" && "${PN}" != "binutils" ]]
    then
        CBUILD=${CHOST}
        CHOST=avr
        CFLAGS="-Os"
    fi
fi

[edit] Install packages

Now you need to install cross-avr/binutils, cross-avr/gcc and cross-avr/avr-libc.

paludis --install cross-avr/binutils cross-avr/gcc cross-avr/avr-libc

[edit] Post-install

The ebuild for binutils does not properly create a required symlink. Try this command:

avr-ld -m avr5

If you are affected by this bug, you will see the following error:

Code: output of previous command
avr-ld: cannot open linker script file ldscripts/avr5.x: No such file or directory

To correct it, we need to create a symlink to the ldscripts directory.

For a 32-bit system:

ln -s /usr/i686-pc-linux-gnu/avr/lib/ldscripts /usr/i686-pc-linux-gnu/avr/binutils-bin/2.20/ldscripts

For a 64-bit system:

ln -s /usr/x86_64-pc-linux-gnu/avr/lib/ldscripts /usr/x86_64-pc-linux-gnu/avr/binutils-bin/2.20/ldscripts

Another command that was previously mention is as follows (for a 64-bit system). (Note, that this did NOT work for me with binutils-2.20 and gcc-4.3.4.)

ln -s /usr/x86_64-pc-linux-gnu/avr/lib/ldscripts /usr/libexec/gcc/avr/ldscripts

[edit] Problems you might face

There seems to be some problems when having libmudflap enabled.

configure: error: in `/var/tmp/paludis/cross-avr-gcc-4.4.4-r2/work/build/avr/libmudflap': configure: error: C compiler cannot create executables

If you run into this error, just disable the use-flag with

echo "cross-avr/gcc -mudflap" >> /etc/paludis/use.conf

Also, if you accidentally tried to install binutils with crossdev, there might be some cruft left which is not overwritten. What I did was look for leftover directories named avr* and deleted them. Then installing worked.

If you get errors like "Error: illegal opcode movw for mcu avr3" when building GCC, then you need to install cross-avr/binutils newer than 2.18.50.

Disabling nptl may also be necessary to avoid compile errors.

If you get "Link tests are not allowed after GCC_NO_EXECUTABLES while checking for symbol versioning support" while checking for symbol versioning support try to disable the fortran use flag.

Personal tools