Skip to content

Instantly share code, notes, and snippets.

@adomenech73
Last active January 22, 2017 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adomenech73/2db8c9e577713fb51e7a943c1f62b1cc to your computer and use it in GitHub Desktop.
Save adomenech73/2db8c9e577713fb51e7a943c1f62b1cc to your computer and use it in GitHub Desktop.

PINE64 custom images creation

I need to create custom @longsleep images for Pine64 because with the existing ones I've got no overlay network on docker installation, so I wanted to try on and build my own images with CONFIG_VXLAN kernel option enabled, to check the possibilites to make it work.

According to @atzoum pull request more scheduler options needs to be enabled and extra configuration mut be done to make it work properly. My problem was that I didn't find most of the options

Create Loongsleep kernel & boot image

First step will be to build Longsleep BSP kernel + u-boot image. All the process will be done on a x86 laptop using cross compiling capabilities.

# Clone scripts repo
git clone https://github.com/longsleep/build-pine64-image
cd build-pine64-image
# Get U-Boot tree
git clone --depth 1 --branch pine64-hacks --single-branch https://github.com/longsleep/u-boot-pine64.git u-boot-pine64
# Compile u-boot
cd u-boot-pine64
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sun50iw1p1_config
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
# Get ARM Trust Firmware (ATF)
cd ..
git clone --branch allwinner-a64-bsp --single-branch https://github.com/longsleep/arm-trusted-firmware.git arm-trusted-firmware-pine64
# Compile ARM Trust Firmware (ATF)
cd arm-trusted-firmware
make clean
make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- PLAT=sun50iw1p1 bl31
# Get Sunxi pack tools
cd ..
git clone https://github.com/longsleep/sunxi-pack-tools.git sunxi-pack-tools
make -C sunxi-pack-tools
# Merge U-Boot with other parts
cd ../u-boot-postprocess
./u-boot-postprocess.sh

# Clone Kernel 3.10 from BSP
cd ..
git clone --depth 1 --branch pine64-hacks-1.2 --single-branch https://github.com/longsleep/linux-pine64.git linux-pine64

# Generate .config
cd linux-pine64
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- sun50iw1p1smp_linux_defconfig

# Modify .config to add VXLAN support
sed -i 's/^# CONFIG_VXLAN is not set/CONFIG_VXLAN=m/' .config

# extra modifications from PR
sed -i 's/^# CONFIG_RT_GROUP_SCHED is not set/CONFIG_RT_GROUP_SCHED=y/' .config
sed -i 's/^# CONFIG_IOSCHED_CFQ is not set/CONFIG_IOSCHED_CFQ=y/' .config
sed -i 's/^# CONFIG_CFQ_GROUP_IOSCHED is not set/CONFIG_CFQ_GROUP_IOSCHED=y/' .config
sed -i 's/^# CONFIG_XFRM_USER is not set/CONFIG_XFRM_USER=y/' .config
sed -i 's/^# CONFIG_IP_VS is not set/CONFIG_IP_VS=m/' .config


cat <<EOT >> .config
CONFIG_XFRM_ALGO=y
CONFIG_NETFILTER_XT_MATCH_IPVS=m
CONFIG_IP_VS_PROTO_TCP=y
CONFIG_IP_VS_PROTO_UDP=y
CONFIG_IP_VS_PROTO_AH_ESP=y
CONFIG_IP_VS_PROTO_ESP=y
CONFIG_IP_VS_PROTO_AH=y
CONFIG_IP_VS_PROTO_SCTP=y
CONFIG_IP_VS_RR=m
CONFIG_IP_VS_NFCT=y
EOT


# Compile BSP Kernel
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LOCALVERSION= clean
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j4 LOCALVERSION= Image
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j4 LOCALVERSION= modules

# Compile BSP Mali Kernel module
cd modules/gpu
LICHEE_KDIR=$(pwd)/../.. ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LICHEE_PLATFORM=Pine64 make build

# Create kernel tarball
cd ../../../kernel
./make_kernel_tarball.sh ../ ../linux-pine64

# Get Busybox tree
cd ..
git clone --depth 1 --branch 1_24_stable --single-branch git://git.busybox.net/busybox busybox

# Configure and build Busybox
cd busybox
cp ../kernel/pine64_config_busybox .config
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j4 oldconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j4

# Make initrd.gz
cd ../kernel
./make_initrd.sh

Create Ubuntu aarch64 rootfs

First we have to bootstrap the rootfs, this must me done in a pine64 development environment

# Clone sgjava scripts repo
git clone https://github.com/sgjava/pine64-debootstrap.git
cd pine64-debootstrap
vi minimal.sh
# Create rootfs
sudo ./start.sh
# Create package
sudo ./finish.sh
mv pine64-xenial-arm64.tar.gz ~

We can then get the rootfs package from our laptop

cd build-pine64-image
scp ubuntu@pine64-build:~/pine64-xenial-arm64.tar.gz .

SD card provision

Now we can go back to the laptop to provision u-boot + kernel + rootfs on the Sd card. The first step will be to burn autoboot loonslep image on the card

# Create longsleep simpleimage
cd simpleimage/
./make_simpleimage.sh ../pine64_vxlan.img 2048 ../linux-pine64-3.10.104-1.tar.xz

# Burn longsleep image
cd ..
cat ./pine64_vxlan.img|pv|sudo dd of=/dev/mmcblk0 bs=4M oflag=sync

In this point we can use gparted to extend the second partition on the SD card to use all the remaining space. After we reconect the SD card so it's mounted on our laptop to deploy the rootfs and the compiled kernel modules.

# Deploy rootfs
sudo tar -pzxf pine64-xenial-arm64.tar.gz -C /media/albert/rootfs
# Deploy compiled kernel modules
cd kernel
sudo ./install_kernel_modules.sh /media/albert/rootfs/ ../linux-pine64
sudo sync

Now we can umount the SD card and boot a Pine64 with it and check if we activated the new capacity properly

zgrep VXLAN /proc/config.gz 
CONFIG_VXLAN=m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment