Wiki » History » Revision 5

« Previous | Revision 5/6 (diff) | Next »
Kamikaze, 03/05/2018 12:01 AM


Getting ArchLinux ARM running on the Nexbox A95x

Common steps

Format the SD Card

Insert the SD Card you will be booting from.

fdisk /dev/mmcblk0

# create two partitions (or more if you want)
# first partition should be bootable, W95 FAT32, 512MB
# second partition should be your rootfs, f2fs is a good choice.
# write partition data.
# make sure it gets picked up by the kernel before you continue.

# format your partitions:
# mkfs.vfat -n boot /dev/mmcblk0p1
# mkfs.f2fs -l rootfs /dev/mmcblk0p2

Setup the rootfs.

We can copy the compiled modules and firmware later when we choose a kernel.

cd /tmp

sudo su - 
mount LABEL=rootfs /mnt/
bsdtar -xpf /tmp/ArchLinuxARM-aarch64-latest.tar.gz -C /mnt/
sudo umount /mnt/

Prep your device to boot from SDCard

I used the toothpick method and it worked fine. (unplug the power press the reset key hidden under the AV plug with a toothpick and plug the power keeping the reset key pressed until it loads)

It should now boot up your new ArchLinux ARM installation, with a fresh kernel.

Method 1: using balbes150 kernel

Note: I had too many stability problems with kernel 4.12.9 and the 4.13-rc. 4.13-rc would hang in some conditions (fairly frequently) and 4.12.9 would stacktrace in the network driver and the network would not recover. I am not sure yet whether this is my device, or buggy code/drivers in the balbes150 kernel. Will be trying an amlogic one next (4.9.26)

Build the kernel, DTBs, modules, and setup the boot partition

#Get balbes kernel source
cd /tmp
git clone
cd Amlogic_s905-kernel

#Checkout a stable tag
git checkout tags/v20170828_4.12.9

export CROSS_COMPILE=aarch64-linux-gnu-
export ARCH=arm64

make clean
make mrproper

# Download the .config attached to this page, or get one with:
#   wget "" 
# Copy it to /tmp/Amlogic_s905-kernel/.config

make oldconfig

make menuconfig  #do any tweaks to the config

make -j4 Image dtbs
make -j4 modules

# Install the modules and firmware to a sub-directory. We will copy them to rootfs later.
make INSTALL_MOD_PATH=build-${ARCH}-modules INSTALL_MOD_STRIP=1 modules_install
make INSTALL_MOD_PATH=build-${ARCH}-modules INSTALL_MOD_STRIP=1 firmware_install

# Copy the DTB to the SDCard boot partition as 'dtb.img'
cp arch/arm64/boot/dts/amlogic/meson-gxl-s905x-nexbox-a95x.dtb /run/media/someuser/boot/dtb.img

# Copy the kernel image to the SDCard boot partition
cp arch/arm64/boot/Image /run/media/someuser/boot/

# Create a s905_autostart script, this is used to tell u-boot how to execute the kernel, and with what command line params.
cat > /run/media/someuser/boot/s905_autostart.booti.txt <<EOF
setenv kernel_loadaddr "0x01080000" 
setenv hdmimode "1080p60hz" 
setenv display_bpp "24" 
setenv init_hdmi "hdmimode=${hdmimode} m_bpp=${display_bpp} vout=${hdmimode},enable" 
setenv condev "console=ttyS0,115200n8 console=tty0 no_console_suspend consoleblank=0" 
setenv bootargs "root=/dev/mmcblk1p2 rootwait rw ${condev} ${init_hdmi} net.ifnames=0" 
setenv boot_start booti ${kernel_loadaddr} - ${dtb_mem_addr}
if fatload mmc 0:1 ${kernel_loadaddr} Image; then if fatload mmc 0:1 ${dtb_mem_addr} dtb.img; then run boot_start; else store dtb read ${dtb_mem_addr}; run boot_start;fi;fi;

# Compile the autostart script to a usable u-boot format:
cd /run/media/someuser/boot/
mkimage -A arm -O linux -T script -C none -d s905_autostart.booti.txt s905_autoscript

Continue setting up the rootfs, copy the compiled modules and firmware

cd /tmp
sudo mount LABEL=rootfs /mnt/

[[ -d /mnt/lib/firmware ]] && echo Removing existing firmware drivers from rootfs && rm -rf /mnt/lib/firmware
rsync -av /tmp/Amlogic_s905-kernel/build-arm64-modules/lib/firmware /mnt/lib/
rsync -av /tmp/Amlogic_s905-kernel/build-arm64-modules/lib/modules/* /mnt/lib/modules/

Insert your SDCard into the Nexbox A95x and reboot into your new ArchLinux installation.

Using Amlogic 4.9.26 kernel

Get the kernel.

git clone
cd amlogic-kernel-4.9.26.git

Apply this patch to compile with latest GCC cross compile toolchain:

cat >turn-off-warnings-as-errors.patch <<EOF
--- Makefile
+++ Makefile-no-warnings
@@ -301,7 +301,7 @@

 HOSTCC       = gcc
 HOSTCXX      = g++
-HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
+HOSTCFLAGS   = -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89

 ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
@@ -395,11 +395,10 @@


-KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
+KBUILD_CFLAGS   := -Wundef -Wstrict-prototypes -Wno-trigraphs \
            -fno-strict-aliasing -fno-common \
            -Werror-implicit-function-declaration \
            -Wno-format-security \
-           -Werror    \
            -std=gnu89 $(call cc-option,-fno-PIE)


patch < turn-off-warnings-as-errors.patch

Build your kernel.


Note: I'm fairly sure there are some broken modules within the amlogic branches, so not all things can be enabled.

I used this config as a basis to avoid dealing with broken code on compile:

cd /tmp/amlogic-kernel-4.9.26.git
make clean && make mrproper
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

cd /tmp
cp config_20180219 /tmp/amlogic-kernel-4.9.26.git/.config

cd amlogic-kernel-4.9.26.git
make oldconfig
make menuconfig  #set your params

If you want to use an init ramdisk, best to start with an existing one and modify it to suit your needs. I downloaded a full ArchLinux image from here:

It's a full disk image. Use the following to have loopdev activate partitions on the image:

losetup -Pf <image>

Copy off the initrd and dtb.img

sudo mount -o ro /dev/loop2p1 /mnt/
cp /mnt/dtb.img /tmp/
cp /mnt/uInitrd /tmp/

Extract out the initrd:

mkdir /tmp/initrd-out
cd /tmp/initrd-out
dd if=/tmp/uInitrd bs=1 skip=64 | gunzip -c > /tmp/uInitrd.cpio
cpio -idv < /tmp/uInitrd.cpio

Copy in whatever modules you need in your ramdisk. Don't forget to rename /lib/modules/<kernel_name> to appropriate name.

Rebuild the initrd:

cd /tmp/initrd-out
find . | cpio --create --format='newc' | gzip > ../newramdisk.img
cd ..
mkimage -A arm64 -O linux -T ramdisk -C none -a 0x13000000 -n "initrd with f2fs" -d newramdisk.img newInitrd.img

Updated by Kamikaze over 2 years ago · 5 revisions