[OS] Alpine Linux 3.12.2 for C4 with 5.10.0 kernel

Post Reply
PhracturedBlue
Posts: 4
Joined: Wed Dec 16, 2020 5:54 am
languages_spoken: english
ODROIDs: C4
Has thanked: 0
Been thanked: 3 times
Contact:

[OS] Alpine Linux 3.12.2 for C4 with 5.10.0 kernel

Post by PhracturedBlue »

The following documents the steps I used to build an Alpine Linux 3.12.2 image for the Odroid C4 with mainline U-Boot and a 5.10.0 kernel.

Download link for Alpine Linux 3.12.2 wth 5.10.0 kernel builf for Odroid-C4:
https://mega.nz/file/R04ADCiJ#1dClOn_Lv ... voYhnWdurA

The conceptual process is:
1) get u-boot and kernel from LibreElec image. I used the LibreElec image because they build a mainline kernel with relevant Amlogic patches and use a mainline u-boot and it is faster/easier than compiling the kernel from source
2) Get an aarch64 Alpine-linux image
3) create an updated initramfs
4) Create modloop
5) Build an image using LE Kernel and u-boot and Alpine initramfs and filesystem

Commands:

Code: Select all

wget https://chewitt.libreelec.tv/testing/9.80/LibreELEC-AMLGX.arm-9.80.7-odroid-c4.img.gz
wget https://dl-cdn.alpinelinux.org/alpine/v3.12/releases/aarch64/alpine-uboot-3.12.2-aarch64.tar.gz
mkdir -p /tmp/alpine/le_img /tmp/alpine/le_rootfs /tmp/alpine/alpine_img /tmp/alpine/alpine_initramfs
zcat LibreELEC-AMLGX.arm-9.80.7-odroid-c4.img.gz > alpine-odroid-c4.img
tar -C /tmp/alpine/alpine_img -xf alpine-uboot-3.12.2-aarch64.tar.gz
export LOOP=`sudo losetup --partscan --show --find alpine-odroid-c4.img`
sudo mount -o uid=`id -u $USER` ${LOOP}p1 /tmp/alpine/le_img
mkdir /tmp/alpine/le_img/boot
sudo mount /tmp/alpine/le_img/SYSTEM /tmp/alpine/le_rootfs
mksquashfs /mnt/alpine/le_rootfs/usr/lib/kernel-overlays/base/lib/ /tmp/alpine/le_img/boot/modloop-odroid-c4 -b 1048576 -comp xz -Xdict-size 100%
sudo umount /mnt/alpine/le_rootfs
rm /tmp/alpine/le_img/SYSTEM*
mv /tmp/alpine/le_img/KERMEL* /tmp/alpine/le_img/boot/
pushd /tmp/alpine/alpine_initramfs
zcat ../alpine_img/boot/initramfs-lts | cpio -idmv
rm -rf lib/modules lib/firmware
find . | cpio -o -H newc ../le_img/boot/initramfs-odroid-c4
cd ../alpine_img
cp -prf alpine.apkovl.tar.gz apks ../le_img/
cat > ../le_img/extlinux/extlinux.conf << EOF
TIMEOUT 20
PROMPT 1
DEFAULT odroid-c4

LABEL odroid-c4
  MENU LABEL Linux lts
  LINUX /boot/KERNEL
  INITRD /boot/initramfs-odroid-c4
  FDT /meson-sm1-odroid-c4.dtb
  APPEND console=ttyAML0,115200n8 console=tty0 debug_init
EOF
popd
sudo umount /tmp/alpine/le_img
sudo losetup -d $LOOP
I would expect similar steps to work for any Amlogic SBC supported by LibreElec
These users thanked the author PhracturedBlue for the post (total 2):
jgmdev (Wed Dec 16, 2020 10:44 am) • eyduh (Wed May 11, 2022 3:25 am)

chewitt
Posts: 177
Joined: Mon Aug 12, 2019 12:27 pm
languages_spoken: english
Has thanked: 1 time
Been thanked: 132 times
Contact:

Re: [OS] Alpine Linux 3.12.2 for C4 with 5.10.0 kernel

Post by chewitt »

All the FIP sources needed for creating signed boot firmware for H2/C4 are here: https://github.com/LibreELEC/amlogic-boot-fip .. I wouldn't guarantee the LE images will be in that folder much longer.

PhracturedBlue
Posts: 4
Joined: Wed Dec 16, 2020 5:54 am
languages_spoken: english
ODROIDs: C4
Has thanked: 0
Been thanked: 3 times
Contact:

Re: [OS] Alpine Linux 3.12.2 for C4 with 5.10.0 kernel

Post by PhracturedBlue »

@chewitt, thank you for all your work supporting Amlogic on mainline. It is hugely appreciated. I actually started by building the whole thing from source because I wanted to understand the procedure. If needed I can post those instructions. But since LE is now building Amlogic from mainline kernel/u-boot, I figured it will likely be added to LE mainline (I see most of the code is already there) so maybe we'll get official images some day? Anyhow, it saves a lot of time to base this on the LE pre-compiled kernel/u-boot, so I'll do so as long as possible.

chewitt
Posts: 177
Joined: Mon Aug 12, 2019 12:27 pm
languages_spoken: english
Has thanked: 1 time
Been thanked: 132 times
Contact:

Re: [OS] Alpine Linux 3.12.2 for C4 with 5.10.0 kernel

Post by chewitt »

https://chewitt.libreelec.tv/testing/9.80/u-boot/ <= u-boot.bin.sd.bin files, usually working (when I don't stuff things up)

Jhonny14
Posts: 59
Joined: Sat Nov 14, 2020 11:29 pm
languages_spoken: english, italian
ODROIDs: odroid c4
Has thanked: 2 times
Been thanked: 0
Contact:

Re: [OS] Alpine Linux 3.12.2 for C4 with 5.10.0 kernel

Post by Jhonny14 »

PhracturedBlue wrote:
Wed Dec 16, 2020 7:46 am
The following documents the steps I used to build an Alpine Linux 3.12.2 image for the Odroid C4 with mainline U-Boot and a 5.10.0 kernel.

Download link for Alpine Linux 3.12.2 wth 5.10.0 kernel builf for Odroid-C4:
https://mega.nz/file/R04ADCiJ#1dClOn_Lv ... voYhnWdurA

The conceptual process is:
1) get u-boot and kernel from LibreElec image. I used the LibreElec image because they build a mainline kernel with relevant Amlogic patches and use a mainline u-boot and it is faster/easier than compiling the kernel from source
2) Get an aarch64 Alpine-linux image
3) create an updated initramfs
4) Create modloop
5) Build an image using LE Kernel and u-boot and Alpine initramfs and filesystem

Commands:

Code: Select all

wget https://chewitt.libreelec.tv/testing/9.80/LibreELEC-AMLGX.arm-9.80.7-odroid-c4.img.gz
wget https://dl-cdn.alpinelinux.org/alpine/v3.12/releases/aarch64/alpine-uboot-3.12.2-aarch64.tar.gz
mkdir -p /tmp/alpine/le_img /tmp/alpine/le_rootfs /tmp/alpine/alpine_img /tmp/alpine/alpine_initramfs
zcat LibreELEC-AMLGX.arm-9.80.7-odroid-c4.img.gz > alpine-odroid-c4.img
tar -C /tmp/alpine/alpine_img -xf alpine-uboot-3.12.2-aarch64.tar.gz
export LOOP=`sudo losetup --partscan --show --find alpine-odroid-c4.img`
sudo mount -o uid=`id -u $USER` ${LOOP}p1 /tmp/alpine/le_img
mkdir /tmp/alpine/le_img/boot
sudo mount /tmp/alpine/le_img/SYSTEM /tmp/alpine/le_rootfs
mksquashfs /mnt/alpine/le_rootfs/usr/lib/kernel-overlays/base/lib/ /tmp/alpine/le_img/boot/modloop-odroid-c4 -b 1048576 -comp xz -Xdict-size 100%
sudo umount /mnt/alpine/le_rootfs
rm /tmp/alpine/le_img/SYSTEM*
mv /tmp/alpine/le_img/KERMEL* /tmp/alpine/le_img/boot/
pushd /tmp/alpine/alpine_initramfs
zcat ../alpine_img/boot/initramfs-lts | cpio -idmv
rm -rf lib/modules lib/firmware
find . | cpio -o -H newc ../le_img/boot/initramfs-odroid-c4
cd ../alpine_img
cp -prf alpine.apkovl.tar.gz apks ../le_img/
cat > ../le_img/extlinux/extlinux.conf << EOF
TIMEOUT 20
PROMPT 1
DEFAULT odroid-c4

LABEL odroid-c4
  MENU LABEL Linux lts
  LINUX /boot/KERNEL
  INITRD /boot/initramfs-odroid-c4
  FDT /meson-sm1-odroid-c4.dtb
  APPEND console=ttyAML0,115200n8 console=tty0 debug_init
EOF
popd
sudo umount /tmp/alpine/le_img
sudo losetup -d $LOOP
I would expect similar steps to work for any Amlogic SBC supported by LibreElec
What about the result? is it good? and what about Wayland kernel or Panfrost?
thanks

PhracturedBlue
Posts: 4
Joined: Wed Dec 16, 2020 5:54 am
languages_spoken: english
ODROIDs: C4
Has thanked: 0
Been thanked: 3 times
Contact:

Re: [OS] Alpine Linux 3.12.2 for C4 with 5.10.0 kernel

Post by PhracturedBlue »

Alpine Linux is not really targeted at GUI use cases, and I haven't tested it. It is an ultra minimized OS designed to run containers or (as in this case) as a host for running containers. I plan to use it as a base image to run Docker on my C4 to host various services. I have no plans to do any graphics testing with this image. If you want a general purpose OS with mainline kernel support, Armbian is probably your best bet (I think they use a mainline u-boot too, though it looks like it has been customized?)

mentaluproar
Posts: 28
Joined: Tue Dec 01, 2020 2:44 pm
languages_spoken: english
Has thanked: 5 times
Been thanked: 1 time
Contact:

Re: [OS] Alpine Linux 3.12.2 for C4 with 5.10.0 kernel

Post by mentaluproar »

what's the login?

PhracturedBlue
Posts: 4
Joined: Wed Dec 16, 2020 5:54 am
languages_spoken: english
ODROIDs: C4
Has thanked: 0
Been thanked: 3 times
Contact:

Re: [OS] Alpine Linux 3.12.2 for C4 with 5.10.0 kernel

Post by PhracturedBlue »

root, no password. then use 'setup-alpine' to configure. note that there is no network until you've done that. there are instructions online for doing a headless configuration. You should probably follow some online guide to learn how to use Alpine, since it is a non-persistent image with its own package manager. There are alpine specific commands to install packages and save configuration.
These users thanked the author PhracturedBlue for the post:
mentaluproar (Thu Dec 17, 2020 7:38 am)

eyduh
Posts: 1
Joined: Sun Jan 24, 2021 9:55 am
languages_spoken: english
ODROIDs: HC4
Has thanked: 1 time
Been thanked: 0
Contact:

Re: [OS] Alpine Linux 3.12.2 for C4 with 5.10.0 kernel

Post by eyduh »

I just tried the steps outlined by OP to make an image for the HC4 and it boots fine.

Running Alpine LInux 3.15.4 with the kernel from LibreELEC-AMLGX.arm-11.0-nightly-20220510

Previously I was running root on a SSD in one of the toaster slots with a 3.5" spinny disk for data in the other, now I can add another HDD in the second toaster slot for RAID1 redundancy. Gonna set it up and run it for a while and make a separate post with the results after running it for a while.

Thanks for the help!

Oh btw, there were 2-3 typos in the initial setup which I took note of, ended up running this:
(basically, mounting tmp at mnt instead of tmp at tmp and adding a > on line 17)

Code: Select all

wget https://test.libreelec.tv/LibreELEC-AMLGX.arm-11.0-nightly-20220510-aefc6b8-odroid-hc4.img.gz
wget https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/aarch64/alpine-uboot-3.15.4-aarch64.tar.gz
mkdir -p /tmp/alpine/le_img /tmp/alpine/le_rootfs /tmp/alpine/alpine_img /tmp/alpine/alpine_initramfs
zcat LibreELEC-AMLGX.arm-11.0-nightly-20220510-aefc6b8-odroid-hc4.img.gz > alpine-odroid-hc4.img
tar -C /tmp/alpine/alpine_img -xf alpine-uboot-3.15.4-aarch64.tar.gz
export LOOP=`sudo losetup --partscan --show --find alpine-odroid-hc4.img`
sudo mount -o uid=`id -u $USER` ${LOOP}p1 /tmp/alpine/le_img
mkdir /tmp/alpine/le_img/boot
sudo mount /tmp/alpine/le_img/SYSTEM /mnt/alpine/le_rootfs
mksquashfs /mnt/alpine/le_rootfs/usr/lib/kernel-overlays/base/lib/ /tmp/alpine/le_img/boot/modloop-odroid-hc4 -b 1048576 -comp xz -Xdict-size 100%
sudo umount /mnt/alpine/le_rootfs
rm /tmp/alpine/le_img/SYSTEM*
mv /tmp/alpine/le_img/KERMEL* /tmp/alpine/le_img/boot/
pushd /tmp/alpine/alpine_initramfs
zcat ../alpine_img/boot/initramfs-lts | cpio -idmv
rm -rf lib/modules lib/firmware
find . | cpio -o -H newc > ../le_img/boot/initramfs-odroid-hc4
cd ../alpine_img
cp -prf alpine.apkovl.tar.gz apks ../le_img/
cat > ../le_img/extlinux/extlinux.conf << EOF
TIMEOUT 20
PROMPT 1
DEFAULT odroid-hc4

LABEL odroid-hc4
  MENU LABEL Linux lts
  LINUX /boot/KERNEL
  INITRD /boot/initramfs-odroid-hc4
  FDT /meson-sm1-odroid-hc4.dtb
  APPEND console=ttyAML0,115200n8 console=tty0 debug_init
EOF
popd
sudo umount /tmp/alpine/

Post Reply

Return to “Other OS”

Who is online

Users browsing this forum: tobetter and 1 guest