User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
mission:tech:odyssey:sku:software [2012/04/05 23:13] – [Software] chronomission:tech:odyssey:sku:software [2013/06/05 14:34] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== 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 ====
 +
 +<code bash>
 +mkdir -p /vault/virtual/icaros/base
 +</code>
 +
 +It's recommended to use a 64 bit version, when your host is running on 64bit.
 +
 +<code bash>
 +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
 +</code>
 +
 +create support scripts:
 +\\ 
 +
 +The $BEROOT variable:
 +
 +<code bash>
 +export BEROOT=/vault/virtual/icaros/armv5te-softfloat-linux-gnueabi/
 +</code>
 +
 +==== Create a new Build-Environment container ====
 +
 +From here on you should be able to use copy&paste
 +
 +<code bash>
 +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
 +</code>
 +
 +little helper to easily enter the build-env in the future
 +
 +<code>
 +vi $BEROOT/bin/chroot-setup
 +</code>
 +
 +<code bash>
 +#!/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
 +</code>
 +
 +Change the permission to make it execuatble
 +
 +<code>chmod 0700 $BEROOT/bin/chroot-setup</code>
 +
 +for more comfort your can change your bash prompt to see that you're chrooted
 +
 +<code bash>
 +echo "export PS1=\"\[\033[01;31m\][BE-CHROOT]\[\033[01;34m\] \W $\[\033[00m\] \"" >> $BEROOT/etc/bash/bashrc
 +</code>
 +
 +your gentoo base system is now almost ready to enter
 +
 +<code bash>
 +cp -L /etc/resolv.conf $BEROOT/etc/
 +mount -t proc proc $BEROOT/proc
 +mount -o rbind /dev $BEROOT/dev
 +</code>
 +
 +===chroot===
 +
 +<code bash>
 +chroot ${EGROOT} /bin/chroot-setup
 +</code>
 +
 +=== Update & Preparation of the Build-Environment ===
 +
 +<code bash>emerge --sync</code>
 +
 +Prepare the make.conf of the build-environment
 +
 +<code bash>
 +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
 +</code>
 +
 +Create the local portage overlay
 +
 +<code bash>
 +mkdir /usr/local/portage
 +mkdir /etc/portage
 +</code>
 +
 +
 +=== emerge crossdev ===
 +
 +setting up portage to choose latest crossdev
 +
 +<code>
 +nano /etc/portage/package.keywords
 +</code>
 +
 +content 
 +
 +<code>
 +sys-devel/crossdev **
 +</code>
 +
 +
 +Finally emerge the crossdev tools
 +
 +<code bash>emerge -av portage-utils crossdev dev-embedded/u-boot-tools</code>
 +
 +=== 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.
 +
 +<code>
 +crossdev -v -t armv5te-softfloat-linux-gnueabi
 +</code>
 +
 +
 +
 +The output will hopefully look similar to this:
 +
 +<code bash>
 + * 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 ]
 +</code>
 +
 +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: 
 +
 +<code bash>
 +[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.
 +
 +</code>
 +
 +==== set up the target infrastructure ====
 +
 +Next set up the target infrastructure
 +
 +<code bash>
 +mkdir ${SYSROOT}/etc
 +cp /etc/make.globals "${SYSROOT}/etc"
 +mkdir -p "${SYSROOT}/etc/portage/profile"
 +</code>
 +
 +
 +Prepare the make.conf of the target-environment
 +
 +<code>
 +nano ${SYSROOT}/etc/make.conf
 +</code>
 +
 +<code bash>
 +#
 +# 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=""
 +</code>
 +
 +original:
 +
 +lrwxrwxrwx 1 root root 30 Nov 22 08:18 /usr/armv5te-softfloat-linux-gnueabi/etc/make.profile -> /usr/portage/profiles/embedded
 +
 +
 +<code>
 +ln -s /usr/portage/profiles/default/linux/arm/10.0/ "${SYSROOT}/etc/make.profile"
 +</code>
 +
 +
 +xkmake: A cross kernel make wrapper
 +
 +<code>
 +nano /bin/xkmake 
 +</code>
 +
 +
 +<code bash>
 +#!/bin/sh
 +exec make ARCH="arm" CROSS_COMPILE="armv5te-softfloat-linux-gnueabi-" INSTALL_MOD_PATH="${SYSROOT}" "$@"
 +</code>
 +
 +=== Kernel ===
 +
 +<code>
 +USE="-* minimal unicode" armv5te-softfloat-linux-gnueabi-emerge -pv gentoo-sources
 +</code>
 +
 +
 +
 +<code bash>
 +cd /usr/armv5te-softfloat-linux-gnueabi/usr/src/linux
 +wget http://www.acmesystems.it/foxg20/download/linux/linux-2.6.35.4-foxg20-patches
 +</code>
 +
 +<code bash>
 +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
 +</code>
 +
 +Download example Kernel configuration file:
 +
 +<code bash>
 +$ wget http://www.acmesystems.it/foxg20/download/linux/linux-2.6.35.4-foxg20-config
 +$ mv linux-2.6.35.4-foxg20-config .config
 +</code>
 +
 +Download the **makefile** (with minus m) useful to simplify the compiling command:
 +
 +<code bash>
 +$ wget http://www.acmesystems.it/foxg20/download/linux/linux-2.6.35.4-foxg20-makefile
 +$ mv linux-2.6.35.4-foxg20-makefile makefile
 +</code>
 +
 +
 +to get pps working
 +
 +<code>
 +Device drivers -> PPS support
 +* Enable high-resolution timestamps
 +* Enable 'ktimer' and 'line discipline' as modules
 +</code>
 +
 +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:
 +
 +<code>
 +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
 +
 +</code>
 +
 +chrony-1.24
 +
 +setserial
 +
 +<code>
 +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
 +</code>
 +
 +{{tag>odyssey sku arm software development linux gentoo netus}}