Monday, April 15, 2013

ARMv4t --> ARMv6j porting started!

UPDATE 17-APR-2013: batch compile of all packages just finished! Quite fast! Results ( here the full list ) are very good, more than 80% of packages was build successfully. Lot of errors says something like "... No such file or directory ...",it's just mean that package must be builded without "-jx" option (or by putting "-j1")...

RPi-TC distro is based on Debian armel Wheezy, Debian for ARMEabiPort is supported on ARMv4t and higher architecture. So, basically, all ARM board (like RaspberryPi) that use Debian armel as OS just use binary compiled with old instruction sets (RaspberryPi is an ARMv6j).
Will ARMv6j binary be more fast than ARMv4t? Sure, but there is no ARMv6j Debian porting! So how we can make some benchmark? We can rebuild Debian! Not the whoooole Debian repository (about 35.000 pakage) but just the package needed by RPi-TC distro (about 400 package)
So, how we can do that? Rebuilding a single package under RaspberryPi take lot of time, 400 will thake my whole life... QEMU chroot is the best choice IMHO but there is some bugs (like msgmerge) and about 80% pakages rebuild will fail. After few test i choose to use a develop arm board and use distcc to re-distribuite the building process of apt-build across network to other pc. Ok, it's hard to explain but easy to do, here an howto:

Forgot to mention that this can be used to port Ubuntu in RaspberryPi :)

What we need:
- Master: RaspberryPi with Debian armel. Or other better performance ARM board (we cannot redistribuite perl xdoc python work...), i use my 4Core,1Gb RAM ODROID-X dev board.
- Master: al least 30Gb of space for source file, build folders and package.
- Helper (ip: A PC with debian/ubuntu distro installed (i use my i920 with 6Gb RAM home pc).

##HELPER CONFIGURATION, as root create an ARMv6j crosstool:
chmod 777 /tmp
apt-get update && apt-get upgrade
apt-get install bison flex gperf gawk libtool automake libncurses5-dev texinfo patch unzip bzip2 make
bunzip2 crosstool-ng-1.18.0.tar.bz2
tar xvf crosstool-ng-1.18.0.tar
cd crosstool-ng-1.18.0
./configure;make -j10;make install

#as user:
mkdir crosstool
cd crosstool
wget -O .config
ct-ng build
#depending on system it's take up to 1hour...
cd ~/x-tools/arm-unknown-linux-gnueabi/bin
wget -O link
chmod +x link
rm link

#as root
apt-get update && apt-get upgrade
apt-get install distcc
#modify the following lines in /etc/default/distcc: 
ALLOWED_NETS="" #this is your subnet
STARTDISTCC="true" #start distcc as service
JOBS="8" #concurrent jobs, is based on how many core you have

#modify /etc/init.d/distcc to add in PATH the builded crosstools:
PATH=/home/USERNAME/x-tools/arm-unknown-linux-gnueabi/bin:$PATH #replace USERNAME with your user!
#Now start distcc daemon:
/etc/init.d/distcc start

##MASTER CONFIGURATION (ODROID-X or RaspberryPi or other board):
apt-get update && apt-get upgrade
apt-get install distcc  
#edit /etc/distcc/hosts we have to put all the ipaddress and the concurrent jobs for every distcc host
#our localhost is an ODROID-X 4 cores, we leave 1 core for distcc client our helper is an Ubuntu x64 with 8cores
#Now we hato to tell the compiler to use distcc:
export PATH="/usr/lib/distcc:$PATH"
export MAKEFLAGS="-j11" # 11 is the sum of concurrent jobs available 3 on odroid-x + 8 on PC

apt-get update && apt-get upgrade
apt-get install apt-build
apt-build update
#use this customized version of apt-build:
wget -O /usr/bin/apt-build
cat <<END > /etc/apt/apt-build.conf
build-dir = /opt/build
repository-dir = /opt/repository
options = " -O3 -march=armv6j -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=softfp"

#re-reconfigure to accept new configuration:
mkdir /opt/
dpkg-reconfigure apt-build #just always shot enter...
#test re-build bash:
apt-build install --noupdate bash

If everything is ok apt-build script will download all the necessary package an the source file to rebuild bash and recreating the .deb package with the ARMv6j architecture, to check if binary/libs are ok just:
dpkg -x dash_0.5.7-3+RPiTC1_armel.deb /tmp/
readelf -A /tmp/bin/bash
File Attributes
  Tag_CPU_name: "6J"
  Tag_CPU_arch: v6
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_FP_arch: VFPv2
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: SP and DP
  Tag_DIV_use: Not allowed

RPi-TC Package list is here i'll keep it updated with building results!


  1. Do you need additional CPU and Memory Resources? Could add my i7 2600 and build the whole day coupled with VPN?

    1. Seem that my configuration is good enought to build up everything in rasonable time, lot of package didn't compile just because i use -jX option.
      Also other package like multiarch or cpp isn't needed or we just can use ARMv4t architecture version.

  2. Would it be possible to run Rpi-TC on Allwinner A10 (cubieboard) or, say, rk3066 (minix neo x5) or even Compaq Armada 510 (cubox) ? Would that require only kernel recomile or whole system recompile since all these are armv7?

    1. Yes, but is better to recompile package for armv7 architecture. ARMv7 is about 20% faster than ARMv6

  3. Why can this be used To port ubuntu To the raspberry?
    Thought ubuntu only Runs in armv7 architecture ?

    1. Yes, you have "just" to rebuild from source all the package needed. Ubuntu team support only (means the binary release is for) armv7 architecture but... source code is source code and you can use it to compile it for different architecture, 1 source package for lot of architecture (i386, x64, armv7 etcetc).
      For example you can build Firefox for Debian armel armv6j starting from "ubuntu" source code also if there is no Firefox package in Debian arm* repository

  4. Can I optimize the RPiTC in Raspberry Model B just to run RDP? I realize a change of applications clicking on task bar and my mouse it stops to responding commands for a few milliseconds, today use:
    xfreerdp /f /u:teste /p:teste /cert-ignore +compression /v:servidor


Note: Only a member of this blog may post a comment.