Gentoo

There are some sunxi or A10 portage overlays floating around the net.

= Introduction = First a warning, if you are building on a system that has 'lensfun' installed, you cannot build u-boot. [] for example. OpenWRT has the same issue with u-boot.

sunxi-bsp
As descriped in the FirstSteps guide, Gentoo can be used just fine to build the sunxi-bsp. There are some dependencies however. Besides the obvious, git, a cross-compiler is needed. It is possible to use the pre-compiled linaro toolchain, but why would you?

Crosscompiler
Gentoo has the magnificent Embedded Handbook which describes in detail how to setup a cross compiler. The jist of it is emerge crossdev. Once crossdev is installed, it's time to build a crosscompiler. crossdev -S -P -v -t arm-pc-linux-gnueabi

If you wish to use uclibc instead of regular gnu-libc, you can do easily by replacing gnu with uclibc. crossdev -S -P -v -t arm-pc-linux-uclibceabi

This will build a cross-compiler using regular libc and the Embedded ABI (eabi) and by default uses hardfloat. If you wish to use softfloat, call crossdev with 'softfloat' in the vendor field. In the below example we use pc_softfloat but just softfloat is sufficient. crossdev -S -P -v -t arm-pc_softfloat-linux-gnueabi While building gcc with soft-float support is understandable, the A10 has hardfloat support, so usage of softfloats isn't necessary.

Any other combination of course is also possible, like using abi instead of eabi. See crossdev -t help for more information.

The resulting links will be installed into /usr/bin. On the case of an x86_64 host, you can find them on /usr/x86_64-pc-linux-gnu/arm-pc-linux-gnueabi/gcc-bin/

Dependencies
Besides the cross-compiler, u-boot-tool is needed to be able to build u-boot. It is optional for the kernel or any rootfs. Installing the final result onto an SD-Card requires sudo (even when running the final step as root) and sfdisk to partition the SD-Card from the script. Also partprobe is required to be able autodetect the newly created partitions, as sfdisk -R doesn't seem to work on Gentoo.

qemu-user
To be able to chroot from an x86 based machine into the arm image, qemu-user is needed. There is an excellent Gentoo Manual. Quickly summarized; USE=static emerge -b1 app-emulation/qemu-user /etc/init.d/qemu-binfmt start Note, the last step only succeeds when CONFIG_BINFMT_MISC is either a module or compiled into the kernel.

If trying to use the currently stable 1.0, the following is needed. 1.4.0 does not suffer from this.

Qemu-user appears to not compile due to bug #454984.

As a workaround, we extract the qemu-user statically linked library from the debian package. As example for a x86_64 host, download the .deb from a mirror: http://packages.debian.org/sid/amd64/qemu-user-static/download

Since the qemu-user binary is the only thing of interest to us, lets extract it manually. ar x qemu-user-static_1.1.2+dfsg-6a_amd64.deb data.tar.gz tar xzf data.tar.gz ./usr/bin/qemu-arm-static tar xzf data.tar.gz ./usr/share/binfmts/qemu-arm

Building sunxi-bsp
For the rest the FirstSteps guide can be used as you would, just remember to pass CROSS_COMPILE=arm-pc-linux-gnueabi- to any make as a variable, e.g. make CROSS_COMPILE=arm-pc-linux-gnueabi- Equally it is possible to edit the default in the Makefile for the compiler used (not recommended) or install the toolchain as arm-linux-gnueabihf (not recommended either).

Debian
While Gentoo is an awesome distribution, and even using embedded Gentoo is quite possible, it isn't quite the easiest way. Also, having Gentoo natively on the A10 allows either to build all packages on a buildhost and turn Gentoo into a binary distro on the A10 or build natively, which is silly in terms of time used to compile, space required, etc. On the other hand, running embedded Debian isn't so bad, and even on Gentoo, we can use cross-deboostrap!

debootstrap
Debootstrap can be emerged quite easily on Gentoo. It is advised to remove the '-nls' USE flag to save some dependencies. If nls is heavily really required for deboostrap (I don't think the final rootfs is limited by it, but need to confirm) do set the flag of course.

Within the sunxi-bsp, go to the ''rootfs' directory; then: mkdir debfs-armhf dd if=/dev/zero of=debfs-armhf.img bs=1M count=1536 mkfs.ext4 -F debfs-armhf.img mount -o loop debfs-armhf.img debfs-armhf

This should yield a empty image loopback mounted. Running deboostrap on it: debootstrap --verbose --no-check-gpg --arch armhf --variant=minbase --foreign sid debfs-armhf http://ftp.debian.org/debian Now cd into the partially filled image and copy the statically linked qemu-user binary.