====== Off-Board build-environment for ARM ====== To compile your own image you have to build a toolchain able to produce binary files that can run on the Netus G20. It's powered by a ARM926EJ-S™ ARM® Thumb® Processor, which means that you have to prepare a (cross)compiler for ARMV5TE architecture. Although it's possible to compile a lot of packages on the SKU itself, it's far more convenient and faster to compile the packages on a more powerful system ===== Prepare HBT-Environment ===== To improve structure and reduce the risk of of //contaminating// the host with wrong arch builds 3 environments will be created, a bit like a matroska doll. * The Host * The Build container * The Target container [[http://gcc.gnu.org/onlinedocs/gcc-4.5.1/gcc/ARM-Options.html#ARM-Options|GCC 4.5.1 ARM Options]] ==== Base Structure ==== mkdir -p /vault/virtual/icaros/base It's recommended to use a 64 bit version, when your host is running on 64bit. cd /vault/virtual/icaros/base wget http://ftp.uni-erlangen.de/pub/mirrors/gentoo/releases/amd64/current-stage3/stage3-amd64-20101118.tar.bz2 wget http://ftp.uni-erlangen.de/pub/mirrors/gentoo/snapshots/portage-latest.tar.bz2 create support scripts: \\ The $BEROOT variable: export BEROOT=/vault/virtual/icaros/armv5te-softfloat-linux-gnueabi/ ==== Create a new Build-Environment container ==== From here on you should be able to use copy&paste mkdir $BEROOT cd $BEROOT cp $BEROOT/../base/stage3-amd64-20101118.tar.bz2 $BEROOT cp $BEROOT/../base/portage-latest.tar.bz2 $BEROOT tar xfjpv stage3-amd64-20101118.tar.bz2 -C $BEROOT tar xfvj portage-latest.tar.bz2 -C $BEROOT/usr little helper to easily enter the build-env in the future vi $BEROOT/bin/chroot-setup #!/bin/bash echo "Setting up BE-ROOT environment" env-update && source /etc/profile export SYSROOT="/usr/armv5te-softfloat-linux-gnueabi" cd $HOME exec /bin/bash Change the permission to make it execuatble chmod 0700 $BEROOT/bin/chroot-setup for more comfort your can change your bash prompt to see that you're chrooted echo "export PS1=\"\[\033[01;31m\][BE-CHROOT]\[\033[01;34m\] \W $\[\033[00m\] \"" >> $BEROOT/etc/bash/bashrc your gentoo base system is now almost ready to enter cp -L /etc/resolv.conf $BEROOT/etc/ mount -t proc proc $BEROOT/proc mount -o rbind /dev $BEROOT/dev ===chroot=== chroot ${EGROOT} /bin/chroot-setup === Update & Preparation of the Build-Environment === emerge --sync Prepare the make.conf of the build-environment CFLAGS="-O2 -pipe" CXXFLAGS="${CFLAGS}" CHOST="x86_64-pc-linux-gnu" MAKEOPTS="-j6" USE="" GENTOO_MIRRORS="http://ftp.uni-erlangen.de/pub/mirrors/gentoo \ http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror" PORTDIR_OVERLAY=/usr/local/portage Create the local portage overlay mkdir /usr/local/portage mkdir /etc/portage === emerge crossdev === setting up portage to choose latest crossdev nano /etc/portage/package.keywords content sys-devel/crossdev ** Finally emerge the crossdev tools emerge -av portage-utils crossdev dev-embedded/u-boot-tools === build crossdev chain === Now it's start to set up the toolchain USE=-* crossdev -t armv5tejl-softfloat-linux-gnueabi The above didnt work in any combination, changing the target to armv5te-softfloat-linux-gnueabi however worked with default values like a charm. Need to test if the compiled code will work in the AT91 and if there are other complications. crossdev -v -t armv5te-softfloat-linux-gnueabi The output will hopefully look similar to this: * crossdev version: @CDEVPV@ * Host Portage ARCH: amd64 * Target Portage ARCH: arm * Target System: armv5te-softfloat-linux-gnueabi * Stage: 4 (C/C++ compiler) * binutils: binutils-[latest] * gcc: gcc-[latest] * headers: linux-headers-[latest] * libc: glibc-[latest] * PORTDIR_OVERLAY: /usr/local/portage * PORT_LOGDIR: /var/log/portage * PORTAGE_CONFIGROOT: * Forcing the latest versions of {binutils,gcc}-config/gnuconfig ... [ ok ] * Emerging cross-binutils ... [ ok ] * Emerging cross-linux-headers-quick ... [ ok ] * Emerging cross-glibc-headers ... [ ok ] * Emerging cross-gcc-stage1 ... [ ok ] * Emerging cross-linux-headers ... [ ok ] * Emerging cross-glibc ... [ ok ] * Emerging cross-gcc-stage2 ... [ ok ] At this point the cross toolchain is successfully installed, usually you can proceed without the next step but better to be safe than sorry, check if the toolchain works, simply launch: [EG-CHROOT] ~ $ armv5te-softfloat-linux-gnueabi-gcc --version armv5te-softfloat-linux-gnueabi-gcc (Gentoo 4.5.1-r1 p1.3, pie-0.4.5) 4.5.1 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ==== set up the target infrastructure ==== Next set up the target infrastructure mkdir ${SYSROOT}/etc cp /etc/make.globals "${SYSROOT}/etc" mkdir -p "${SYSROOT}/etc/portage/profile" Prepare the make.conf of the target-environment nano ${SYSROOT}/etc/make.conf # # make.conf for Netus G20 ARM Embedded System # CHOST=armv5tejl-softfloat-linux-gnueabi CBUILD=i686-pc-linux-gnu ROOT=/usr/local/${CHOST}/ ARCH="arm" MAKEOPTS="-j8" ACCEPT_KEYWORDS="~x86 arm ~arm" CFLAGS="-Os -pipe -march=armv5t -mtune=arm926ej-s -fomit-frame-pointer -I${ROOT}/usr/include/ -I${ROOT}/include/" CXXFLAGS="${CFLAGS}" LDFLAGS="-L${ROOT}/usr/lib -L${ROOT}/lib" USE="${ARCH} zlib bindist make-symlinks minimal" PKG_CONFIG_PATH="${ROOT}/usr/lib/pkgconfig/" FEATURES="-collision-protect sandbox buildpkg noman noinfo nodoc" PORTDIR_OVERLAY="/usr/local/portage" PKGDIR=${ROOT}/packages/ PORTAGE_TMPDIR=${ROOT}/tmp/ PORTAGE_WORKDIR_MODE=2775 PORTAGE_ECLASS_WARNING_ENABLE=0 CLEAN_DELAY=0 EPAUSE_IGNORE=1 EBEEP_IGNORE=1 GENTOO_MIRRORS="http://ftp.uni-erlangen.de/pub/mirrors/gentoo \ http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror" VIDEO_CARDS="" INPUT_DEVICES="" original: lrwxrwxrwx 1 root root 30 Nov 22 08:18 /usr/armv5te-softfloat-linux-gnueabi/etc/make.profile -> /usr/portage/profiles/embedded ln -s /usr/portage/profiles/default/linux/arm/10.0/ "${SYSROOT}/etc/make.profile" xkmake: A cross kernel make wrapper nano /bin/xkmake #!/bin/sh exec make ARCH="arm" CROSS_COMPILE="armv5te-softfloat-linux-gnueabi-" INSTALL_MOD_PATH="${SYSROOT}" "$@" === Kernel === USE="-* minimal unicode" armv5te-softfloat-linux-gnueabi-emerge -pv gentoo-sources cd /usr/armv5te-softfloat-linux-gnueabi/usr/src/linux wget http://www.acmesystems.it/foxg20/download/linux/linux-2.6.35.4-foxg20-patches patch -p1 < linux-2.6.35.4-foxg20-patches patching file arch/arm/mach-at91/board-foxg20.c patching file arch/arm/mach-at91/Kconfig patching file arch/arm/mach-at91/Makefile Download example Kernel configuration file: $ wget http://www.acmesystems.it/foxg20/download/linux/linux-2.6.35.4-foxg20-config $ mv linux-2.6.35.4-foxg20-config .config Download the **makefile** (with minus m) useful to simplify the compiling command: $ wget http://www.acmesystems.it/foxg20/download/linux/linux-2.6.35.4-foxg20-makefile $ mv linux-2.6.35.4-foxg20-makefile makefile to get pps working Device drivers -> PPS support * Enable high-resolution timestamps * Enable 'ktimer' and 'line discipline' as modules otherwise ldattach: cannot set line discipline: Invalid argument === create sd card === tune2fs -c 0 -i 0 /dev/xyz Why not jffs2 or ubifs What about file systems like jffs2 and ubifs, which are aware of flash card wearing? SD cards, according to SanDisk specs, should have wear leveling logic, which controls the number of writes and remaps blocks as needed. Wear-aware file systems might actually play against the logic of the card and are usually not recommendable. ==== Software ==== gpsd-2.95 before emerging chrony: cd /usr/include/ wget "http://gitweb.enneenne.com/?p=pps-tools;a=blob_plain;f=timepps.h;h=d2628d2d061ea2a3623e57990d9ada62623773cf;hb=master" -O timepps.h cd /usr/include/linux wget http://projects.qi-hardware.com/index.php/p/qi-kernel/source/file/jz-2.6.35/include/linux/pps.h chrony-1.24 setserial localhost ~ # setserial /dev/ttyS1 low_latency localhost ~ # ldattach 18 /dev/ttyS1 [ 419.370000] new PPS source atmel_serial1 at ID 0 [ 419.370000] PPS source #0 "/dev/ttyS1" added {{tag>odyssey sku arm software development linux gentoo netus}}