Gentoo-cross-compilation

From Qi-Hardware
Jump to: navigation, search

At the moment a chroot system is possible only. Also this article is in development. How to build Kernel (and output to lcd)? python/perl works! gcc should work.


Read also

http://www.gentoo.org/proj/en/base/embedded/cross-development.xml

http://www.gentoo.org/proj/en/base/embedded/handbook/ http://gentoo.mindzoo.de

http://en.gentoo-wiki.com/wiki/Crossdev

http://jlime.com/downloads/releases/muffinman/documentation/

which are helpful and necessary resources.

Basic knowledge of gentoo and portage is recommended and necessary. Documentation: http://www.gentoo.org/doc/en/

Contents

[edit] prebuild

[edit] install build root

For details about installation see also http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?full=1

Mirror list is at http://www.gentoo.org/main/en/mirrors2.xml

cd /mnt/toolchain-nano
wget portage-[date].tar.bz.md5sum
wget portage-[date].tar.bz
wget stage3-[arch]-[date].tar.bz2.DIGEST
wget stage3-[arch]-[date].tar.bz2
md5sum -c portage-[date].tar.bz.md5sum
md5sum -c stage3-[arch]-[date].tar.bz2.DIGEST
tar xvfjp stage3-[arch]-[date].tar.bz2
tar xvfjp portage-[date].tar.bz
mv portage usr/

[edit] chroot build root

once

cp /etc/resolv.conf  etc/

all times

LANG=C
mount --bind /proc /mnt/toolchain-nano/proc
chroot /mnt/toolchain-nano
env-update && source /etc/profile

[edit] update build root!

emerge --sync
emerge -pvDuN world

[edit] build toolchain

[edit] crossdev toolchain

Maybe installation of lzma-utils is needed (bugreport for adding dependency?). You will see.

echo "sys-devel/crossdev ~amd64" > /etc/portage/package.keywords/crossdev
echo "app-portage/layman git subversion cvs" > /etc/portage/package.use/layman
emerge layman crossdev 
echo "source /var/lib/layman/make.conf" >> /etc/make.conf
layman -S
layman -a embedded-cross

add

# PORTDIR_OVERLAY="/var/lib/layman/embedded-cross/ $PORTDIR_OVERLAY"  

create toolchain

LANG=C crossdev --without-headers --binutils 2.20.1-r1 --libc 2.11.2 --target mipsel-softfloat-linux-gnu

[edit] cross develepment system

Cross chain and mipsel development root is installed into /usr/mipsel-softfloat-linux-gnu/ please add your changes into /usr/mipsel-softfloat-linux-gnu/etc/portage and mail it to me.

[edit] cross chain gentoo configs

CHOST=mipsel-softfloat-linux-gnu
CBUILD=x86_64-pc-linux-gnu
ARCH="mipsel"
HOSTCC=x86_64-pc-linux-gnu-gcc
E_MACHINE=EM_MIPSEL
ROOT=/usr/${CHOST}/
USE="${ARCH} minimal -perl -fortran elibc_glibc"
MARCH_TUNE="-march=mips32 -mtune=mips32"
CFLAGS="-Os -pipe ${MARCH_TUNE}"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-L${ROOT}lib -L${ROOT}usr/lib"
FEATURES="sandbox buildpkg usepkg"
# Be sure we dont overwrite pkgs from another repo..
PKGDIR=${ROOT}packages/
PKG_CONFIG_PATH="${ROOT}/usr/lib/pkgconfig/"
PORTAGE_TMPDIR=${ROOT}tmp/
ACCEPT_KEYWORDS="mips" # Add ~mips here if you know what you do.
ROOT=/usr/${CHOST}/
# /embedded-cross-nano will be further published overlay
PKG_CONFIG_PATH="${ROOT}/usr/lib/pkgconfig/"
PORTDIR_OVERLAY="$location/embedded-cross-nano/embedded-cross/
                $location//embedded-cross-nano/nano-overlay/"
#                ${ROOT}/var/lib/layman/embedded-cross/"
               VIDEO_CARDS="fbdev dummy"
               INPUT_DEVICES="evdev keyboard mouse"
               LINGUAS="en"


[edit] create overlay

need help! fist time.

mkdir /embedded-cross-nano/nano-overlay -p 
cd /embedded-cross-nano/
ln -s /var/lib/layman/embedded-cross/ /embedded-cross-nano/parent
ln -s /embedded-cross-nano/nano-overlay/ make.profile
wget https://88.198.212.242/nanonote/nano-overlay.tar
tar xvfz https://88.198.212.242/nanonote/nano-overlay.tar
mkdir /usr/mipsel-softfloat-linux-gnu/etc/portage
cd /usr/mipsel-softfloat-linux-gnu/etc/portage
mkdir package.keywords
mkdir package.use
mkdir /embedded-cross-nano/nano-overlay/portage-flags-target/keywords -p
ln -s /embedded-cross-nano/nano-overlay/portage-flags-target/keywords /usr/mipsel-softfloat-linux-gnu/etc/portage/package.keywords/keywords
ln -s /embedded-cross-nano/nano-overlay/portage-flags-target/use/ /usr/mipsel-softfloat-linux-gnu/etc/portage/package.use/

now it is possible to add keywords without touching/usr/mipsel-softfloat-linux-gnu/etc/portage/keywords/package-xyz

cat /embedded-cross-nano/nano-overlay/portage-flags-target/keywords/ncurses 
sys-libs/ncurses         ~mips

[edit] Build System

[edit] cross compile system

[edit] install libs into toolchain

emerge-mipsel-softfloat-linux-gnu -bk sys-libs/zlib dev-libs/openssl

[edit] build nanonote system

Install everything into /nano

ROOT=/nano/ emerge-mipsel-softfloat-linux-gnu -bk binutils net-misc/dropbear sys-apps/baselayout udev sys-libs/zlib coreutils -bkNpv
USE=make-symlinks ROOT=/nano/ emerge-mipsel-softfloat-linux-gnu -bk busybox -bkNpv
cp -a /dev/ /nano
mkdir /nano/sys /nano/proc /nano/root

[edit] kernel

[edit] prebuild kernel

More or less copy and paste of http://jlime.com/downloads/releases/muffinman/documentation/kernel-nn.txt

install u-boot-tools (mkimage)

emerge u-boot-tools

- Download the toolchain - Download the .config kernel file : config-nn-2.6.34.txt

git clone http://projects.qi-hardware.com/index.php/p/qi-kernel/source/tree/master/
git clone git://projects.qi-hardware.com/qi-kernel.git
git checkout -b jlime remotes/origin/jz-2.6.34
cp config-nn-2.6.34.txt .config

[edit] build kernel

make ARCH=mips CROSS_COMPILE=mipsel-softfloat-linux-gnu- clean
make ARCH=mips CROSS_COMPILE=mipsel-softfloat-linux-gnu- menuconfig
make ARCH=mips CROSS_COMPILE=mipsel-softfloat-linux-gnu- vmlinux.bin
make ARCH=mips CROSS_COMPILE=mipsel-softfloat-linux-gnu- modules
make ARCH=mips CROSS_COMPILE=mipsel-softfloat-linux-gnu- modules_install

[edit] install kernel & modules

Get the set entry point for mkimage command (-e)

echo 0x$(nm vmlinux 2>/dev/null | grep " kernel_entry" | cut -f1 -d ' ')
cd arch/mips/boot
rm vmlinux.bin.gz uImage
gzip -9 vmlinux.bin

You get the value for -e with the echo command

mkimage -A mips -O linux -T kernel -C gzip -a 0x80010000 -e [Entry Point] -n 'MIPS' -d vmlinux.bin.gz uImage
mkdir /nano/boot
cp uImage /nano/boot
cp -a /lib/modules /nano/lib/

[edit] scratchpad

[edit] libs and strage dep's

e.g flex/ncurses (and other libs) need to be installed first into toolchain _and_ then like glibc to ROOT (else it will fail - logic; please also note that emerge into toolchain will result into file collisions). If failing to compile use qfile (app-portage/portage-utils) first to find to which package it belongs and build it for CHOST and toolchain;

e.g.

mkdir /nano
ROOT=/nano/ emerge-mipsel-softfloat-linux-gnu bash

_should_ need a

emerge-mipsel-softfloat-linux-gnu sys-libs/ncurses

first


ROOT=/nano/ emerge-mipsel-softfloat-linux-gnu  app-shells/bash net-misc/dropbear sys-apps/baselayout sys-apps/coreutils sys-apps/iproute2 sys-apps/net-tools sys-apps/sysvinit sys-devel/binutils sys-kernel/linux-headers sys-libs/glibc

or

emerge-mipsel-softfloat-linux-gnu system

[edit] gcc/mpfr

mpfr will always fail see (solution there does not work) http://bugs.gentoo.org/192352

/usr/lib/libgmp.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[1]: *** [libmpfr.la] Fehler 1
make[1]: Leaving directory `/usr/mipsel-softfloat-linux-gnu/tmp/portage/dev-libs/mpfr-3.0.0/work/mpfr-3.0.0'
/usr/lib/libgmp.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[1]: *** [libmpfr.la] Error 1
make[1]: Leaving directory `/usr/mipsel-softfloat-linux-gnu/tmp/portage/dev-libs/mpfr-3.0.0/work/mpfr-3.0.0'

workaround

mv /usr/lib/libgmp.so /root

[edit] file/python

>=dev-lang/python-2.6.5
>=dev-lang/python-3.1.2

is bad; mask it

Personal tools
Namespaces
Variants
Actions
Navigation
interactive
Toolbox
Print/export