Installing Gentoo Linux on ARM Allwinner V3S SoC / Lichee pi zero board

The Allwinner V3S SoC has become recently available, and although it is not a high-end ARM processor (ARMv7l core, 1.2GHz, 64MB DRAM), its advantage for the hobbyist is DRAM-on-chip and hand-solderable package. I am thus considering to employ it in some hobby projects which require more computing power/full network stack or so, which requires to run a full-blown embedded Linux.
To test the feasibility, I first purchased the Lichee pi zero board and - successfully - tried to run on it my favorite Linux distro, which is Gentoo. My own board with this processor is a second step for the future... It might be possible to use only a cheap 2-layer board, as one needs just 3 voltages (3V3, 1V8, 1V2) without any special power-on sequence and concerning faster transmission lines only SD card, USB2, and 100Mbit Ethernet.

Here I give just some notes on the Gentoo installation on this processor, for anyone interested and for myself as a reminder :-).

Cross-compilation toolchain for ARM Allwinner V3S

As usual in Gentoo, the toolchain should be generated using crossdev. I tried it, but due to some mistake of mine, the generated toolchain reported assembly incompatibilities when trying to cross-compile he kernel. Some other attempts failed in the crossdev toolchain build. Since trying this was a bit too much time consuming, I rather downloaded a binary toolchain from licheepizero.us, which worked flawlessly.

Cross-compilation of u-boot

I got u-boot sources using
git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-spi-experimental
Then configured as
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_defconfig
and compiled by
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
There were little troubles - tools/binman/binman had to be changed to "#!/usr/bin/python2.7" and in include/libfdt.h include/libfdt_env.h I had to change from "_LIBFDT_H" to "LIBFDT_H" to prevent conflict with host's include files. Otherwise everything went well.

Cross-compilation of the kernel

I took a recent kernel sources (at time of writing) 5.6.14-gentoo from the PC distribution. It turned out, that to activate eth0, I had to apply the patches https://lore.kernel.org/patchwork/patch/884654/ https://lore.kernel.org/patchwork/patch/884655/ https://lore.kernel.org/patchwork/patch/884656/
The patches change the platform device tree files and the source of the driver.
I took arch/arm/configs/licheepi_zero_defconfig from the kernel sources at https://licheepizero.us

Then everything was smooth:
make ARCH=arm licheepi_zero_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8

Preparing the SD card and installing Gentoo files

fdisk /dev/mmcblk0
/dev/mmcblk0p1 2048 1050623 1048576 512M c W95 FAT32 (LBA)
/dev/mmcblk0p2 1050624 3147775 2097152 1G 82 Linux swap / Solaris
/dev/mmcblk0p3 3147776 45090815 41943040 20G 83 Linux
/dev/mmcblk0p4 45090816 60506111 15415296 7.4G 83 Linux


mkfs.vfat, mkswap, mkfs.ext4...
dd if=/dev/zero of=/dev/mmcblk0p1 bs=1024 seek=8 count=512
dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0p1 bs=1024 seek=8
mount /dev/mmcblk0p1 /mnt/boot
vi boot.cmd:
setenv bootargs console=ttyS0,115200 panic=5 console=tty0 rootwait root=/dev/mmcblk0p3 earlyprintk rw
load mmc 0:1 0x41000000 zImage
load mmc 0:1 0x41800000 sun8i-v3s-licheepi-zero-dock.dtb
bootz 0x41000000 - 0x41800000
mkimage -C none -A arm -T script -d boot.cmd boot.scr
cp arch/arm/boot/dts/sun8i-v3s-licheepi-zero-dock.dtb /mnt/boot
cp arch/arm/boot/zImage /mnt/boot
cp ../u-boot/u-boot-sunxi-with-spl.bin /mnt/boot


That was all for /boot and for the root fs I downloaded stage3-armv7a_hardfp-20200509T210605Z.tar.xz and portage-latest.tar.bz2 from a gentoo server and installed them.
A little edit was needed of /etc/fstab and /etc/passwd and /etc/inittab to start agetty 115200 at /dev/ttyS0 for inital access. The Lichee Pi then booted, I got root shell and basically followed the Gentoo installation handbook for a native install, no crosscompilation any more.
One point worth noting was
cd /etc/portage; ln -s ../../usr/portage/profiles/default/linux/arm/17.0/desktop make.profile
Otherwise eselect profile list did not even work.

Of course, natively compiling even a small subset of Gentoo packages on Lichee Pi is an exercise in patience, I had to let it run for 3 days. It also turned out that activating a swap space was essential, during the compilation the swap space usage was over 100MB, more than the 64MB of physical RAM.

My Electronics page


My hobby page


My main page with e-mail contact


TOP of my family pages