Hi there,
I’ve been working days on it and I finally got some good results : my alpine linux for radxa zero is working. I don’t know yet if it’s fully functionnal but it seems to be.
Download link:
https://drive.google.com/file/d/1tB5_RyqbqCSyXyHErddy31e8iSM2pdvn/view?usp=sharing
Default id : root / no password
Since the image had been shrunk, don’t forget to expand the root partition to the whole sdcard/EMMC
Here is how I did it :
- Set up build environment
Create an Ubuntu VM and set up an build environment like this one :
$ sudo apt update
$ sudo apt install gcc-aarch64-linux-gnu device-tree-compiler libncurses5 libncurses5-dev bc python dosfstools flex build-essential libssl-dev mtools bison flex bison git wget
$ wget https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
$ sudo tar xvf gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz -C /opt
-
Build the U-Boot
Build the U-Boot using the official link : U-Boot . -
Build and pack Radxa Zero Kernel
Build a new kernel using also the official link : Radxa Zero Kernel
Note : Instead of using the raw Image kernel (inside the arch/arm64/boot/ directory. I used the compressed Image.gz or you can use the one inside the .deb you made (linux-image-5.10.69-999-amlogic_5.10.69-999-amlogic_arm64.deb) named : vmlinuz-5.10.69-999-amlogic). -
Create Initramfs
Now the tricky part : we have an U-Boot, a kernel and a dtb, we have to to create an Initramfs file.
Download the generic ARM Alpine linux image (GENERIC ARM), extract it, make a temp directory (or whatever you want to name it) and put inside this directory the file named Initramfs-lts. This file is found inside the boot directory of the GENERIC ARM extracted.
Extract this file using this command :
gunzip -c initrams-lts | cpio -i
Remove any folder in /lib/modules and put in it two folders:
- 5.10.69-999-amlogic: which can be found inside the .deb : linux-image-5.10.69-999-amlogic_5.10.69-999-amlogic_arm64.deb. This folder can be found inside /lib/modules
- firmware: Since my installation is a strictly minimal one, I extracted only the firmwares I needed. I took them from any armbian radxa-zero image (the folder you’ll want to find is /usr/lib/firmware. Pay attention to the folder path !). AND something important: I merge this folder with Radxa Zero Slarm64 image (thanks Mara).
When I got these two, I put them inside temp/lib/modules/. Make sure to be inside the temp folder and then recompile the Initramfs using this command :
find . | cpio -H newc -o | gzip -9 > /home/YOURNAME/initramfs-zero
I changed back to where I compiled the initraramfs-zero and ran the command:
mkimage -n initramfs-zero -A arm -O linux -T ramdisk -C none -d initramfs-zero initramfs-zero-v0
So your initramfs file is initramfs-zero-v0
-
Creating modloop File
The modloop file contains the following folders:- /modules/5.10.69-999-amlogic
- /modules/firmware
These two folders have already been using to compile the initramfs. So, make a new folder named squashfs-temp, copy them inside it and create the modloop:
mksquashfs squashfs-temp/ modloop-zero -b 1048576 -comp xz -Xdict-size 100%
- Flash U-Boot to microSD
bin=/path/to/ fip/radxa-zero/u-boot.bin.sd.bin
sudo dd if=$bin of=/dev/sdx conv=fsync,notrunc bs=1 count=444
sudo dd if=$bin of=/dev/sdx conv=fsync,notrunc bs=512 skip=1 seek=1
- Boot.cmd and .scr
I took it from the Radxa Zero Slarm64 topic (thanks Mara) and changed it. I removed the legacy kernel part I did not understand (if someone knows about this, I’ll happy to have his explanation). I added this bootargs :
setenv bootargs “earlyprintk /boot/Image modules=loop,squashfs,sd-mod,usb-storage modloop=/boot/modloop-zero console=${console}”
and recompiled with:
mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
-
Final step
On the SDcard, make a /boot folder, a /boot/dtb folder and copy inside it the following items:- /boot/dtb/meson-g12a-radxa-zero.dtb
- /boot/boot.scr
- /boot/uInitrd (your initramfs-zero_v0)
- /boot/modloop-zero
- /boot/Image (your image kernel named vmlinuz-5.10.69-999-amlogic)
Take the apks folder in the generic ARM image downloaded above and copy it the sdcard.
Your SD-Card will look as below.- /boot
- /apks
-
Upgraded Kernel
The kernel version I compiled is 5.16-12 (maybe I should have took the latest lts, anyway…). I took it from here: https://www.kernel.org/
It is exactly the same steps as the official page.
However don’t forget to copy the radxa_zero_defconfig into the following kernel folder arch/arm64/configs
Note: there are no overlay in the folder arch/arm64/boot/dts. That could be a problem later. I couldn’t figure it out yet (see what is not working) -
Optional step: flash it the EMMC
Make an image from the SDCard with dd and shrink it with piShrink
Put your zero into maskmode.
Flash it with the file radxa-zero-erase-emmc.bin
Run and rerun Balena Etcher until the zero is seen
Flash your .img you made from the dd command. -
Wifi workaround
The wifi wasn’t working out of the box. I ran into some problems and I found out a good way to make it work. Just follow theses steps:
rmmod brcmfmac && modprobe brcmfmac
ip link set wlan0 up
and then either run:
setup-interfaces
udhcp -i wlan0
or
setup-alpine
- Saving your changes
AFTER you ran setup-alpine, you can use lbu to save your changes. See the link: LBU
The useful command:
lbu commit -d
-
What is working:
- Since it’s the very first version, I did not made thorough tests but except the wifi (see wifi workarount) everything I tested worked.
-
What is not working:
- I haven’t managed yet to get the console and UART working. If someone can give me a hand, I’ll be happy. I tried this: Serial Console but I have nothing displayed on my screen. I tried 3 differents cables and none of them worked.
- The overlays ? I did add the overlays dtbo from the 5.10 kernel compilation to the my 5.16 kernel alpine linux image but I did not tested them. I will later but right know, I’ll say they’re not working. If someone can test, go ahead
Useful links :
https://wiki.alpinelinux.org/wiki/DIY_Fully_working_Alpine_Linux_for_Allwinner_and_Other_ARM_SOCs
https://www.alpinelinux.org/downloads/
https://forum.radxa.com/t/radxa-zero-slarm64-aarch64-unofficial-slackware/7011
Armbian images: https://discord.com/channels/855634073376260096/888960277788393553
The firmwares: https://drive.google.com/file/d/1lZS3TzMbFHcqe7jITcWSYfkEErI31dZ4/view?usp=sharing