Archlinux on Rock5b

Kernel & Rootfs installation:

  1. You need a working rootfs. Easiest way to do is to install Radxa Debian Image. Advanced users can do it in very different other ways.

  2. Get the AArch64 generic rootfs tar ball and overwrite the rootfs of the debian image.
    https://archlinuxarm.org/platforms/armv8/generic.

  3. Reboot device to arch linux, and install the linux-radxa-rkbsp5-bin or linux-radxa-rkbsp5-git package mentioned in the above. You have to install it with makepkg -si in the folder where the PKGBUILD exists for the given package. Now you have a maintainable kernel which is in sync with Radxa Debian OS Releases (When packages are AURed). The git version compiles the kernel from the latest source code available so it takes a lot time and space to compile but gives the latest available features, the bin package will install the latest released version of Debian Kernel by Radxa
    Note: If you are a previous package user you have to adapt the extlinux.conf file with the new filenames.

  4. After mounting your boot parition to somewhere you know, navigate to /boot_partiton_mount_place/extlinux/extlinux.conf file and adapt it to the new kernel initramfs and dtb locations. A sample extlinux.arch.template file is provided under /boot/extlinux/ directory. You can simply overwrite this file to extlinux.conf and adapt your UUID in the the append section or copy the Archlinux part in it and use it in your existng file if you have other stuff that you want to preserve in your extlinux.conf

  5. If you want Arch to manage the kernels, simply mount your first boot partition to /boot folder in rootfs. In my setup i use NVME drive and the following fstab entry handles it properly. Make sure to adapt your device if you are not using NVME (mmcblk for sdcard etc).

/etc/fstab:
/dev/nvme0n1p1 /boot vfat dmask=000,fmask=0111,user 0 0

  1. After a restart, device will boot from arch packages. Whenever you do a system upgrade the kernel will be automatically updated. Note that this is meant to be working with Radxa Deian & Ubuntu bootloaders. I dont know how it works with Armbian bootloaders so you have been warned.

GPU OpenGL Acceleration with Panfork:

  1. If you want HW Acceleration install gnome sudo pacman -S gnome. Let if finish, after done replace the mesa package with mesa-panfork-git.

  2. Simply go to the mesa-panfork-git folder and execute makepkg -si and when asked by pacman, replace mesa and libglvnd with the panfork variant.

  3. Then simply start gnome with systemctl start gdm and enjoy.

  4. There is already a mesa-panfork-git package in AUR you can use this it will have the same affect. You do no need my packages for this, i am just keeping it to have more control.

Video Decoder Accelaration with FFMpeg & RKMPP

  1. Install the packages mpp-git, ffmpeg4.4-mpp, ffmpeg-mpp, kodi-stable-mpp-git.

  2. Make sure that your user is added to video group. This is neceesary for user space applications to access mpp drivers other-wise, video acceleration will not work. You can verify this by issuing groups and check if the video group is there, if not, you can add your user with usermod -A -g video myuser. Please note that after a user is added to a new group, restart is required to make it active.

  3. You can use all applications which depends ffmpeg4, ffmpeg with the acceleration. Please note that some software may categorize it SW decoder but in reality it is an hardware accelrated decoder. Only the verify you can see that the codec name has _rkmpp suffix at the end of it.

Here are some screenshots of 4k 60fps h264 decoder. This should work for VP8, VP9, H263, H264, MPEG1&2&4 yet i only tested h264.

Browser Acceleration:

I have only gathered the exsiting information so the actual credit here goes to @icecream95 for this RGA interface patch @amazingfate for his previous packaging efforts and of course @jeffyCN actually providing the RKMPP patches to FFMpeg.

First of rockchip has not va-api user space driver.
There two ways provided in the BSP.

1st option:
is to use v4l-rkmpp plugin which also patches v4l-utitls, and also patches chromium. This is how it works in Armbian. I do not follow this approach because it is hard to maintain the patches on each chromium release, and re-compiling chromium is not the best experience. How ever this might be the performance-wise faster way, yet i have no measurements to back it up. Would also like to see comparisons.

2nd option:
Browsers use FFmpeg when they fallback to software decoder, but our patched ffmpeg uses hardware accelerated MPP + RGA interface as default option. Replacing the system ffmpeg will suffice in that case.

Security Concerns: Since in each v4l-rkmpp or ffmpeg-mpp scenario, the browser needs to access kernel, and browsers disallows this behabiour for our security. To use video decode acceleration we need to bypass this, so you have been warned.

Firefox Video Decoder Acceleration:
Simply run MOZ_DISABLE_RDD_SANDBOX=1 firefox. The first environment variable disables security checks so that ffmpeg do its work. This will bring ā€˜MPEG1,2,4 H263 & 264, VP8&9ā€™ acceleration provided by ffmpeg to firefox. You can easily 4k with it, See below SS for cpu load reference in 4K VP9 video.

HEVC is not supported by firefox and actually the web is also not ready for it, AV1 is not supported by BSP kernel, ffmpeg and mpp part is ready but we need a working kernel.

Chromium Video Decoder Acceleration
The librga patch inside the ffmpeg brakes the chromium video playback, i think the could be something wrong with memory alignment but dont take my word on it. It needs the attention someone who knows what he is talking about. It might occasionally work, but at the end it will crash. The VP9 youtube videos are not affecting because Chromium is not using ffmpeg for VP9 instead uses libvpx. And this is another reason not to use Chromium with this approach because even if the crash problems would be resolved, you would still need to recompile chromium because all the distros enable libvpx over fdmpeg by default. So moral of the story donā€™t use chromium for video.

Firefox GL Acceleraion with wayland and X11
if you run Firefox MOZ_ENABLE_WAYLAND=1 firefox env value, GPU acceleration will come directly. You dont have to do anything. For x11, i can only accelerate GL rendering, but the webrender is still in software mode. To enable GL rendering on X11, goto about:cofig and enable layers.acceleration.force-enabled config value. You can verify it in the page about:support. If you are using wayland you dont have to, it comes automatically.

Chromium GL Acceleration with Wayland and X11
I comes automatically. You can verify under chrome:gpu page. If you have issues, you can try with --in-process-gpu flag when calling the chromium.

TL&DR GPU Acceleration
Install ffmpeg-mpp package and use firefox in wayland and start with MOZ_ENABLE_WAYLAND=1 MOZ_DISABLE_RDD_SANDBOX=1 firefox


Troubleshooting:

  1. There already is a mesa-panfork-git package in the AUR, but it complies the rest of the drivers rather than panfrost. I had problems with screen glitching and color channels swapping with that build. I dont know the reason, the one in github repo is a strict panfrost compilation and i did not have any issues with that. We can merge both those into 1 single when things settle down.
  2. If you plan to use existing AUR version it does not bundle the g610 firmware at mali_csffw.bin You have to manually install it to /usr/lib/firmware
  3. Especially if you have 4GB ram compiling mesa can cause OOM time to time. To prevent issues, add a swap disk or file.
  4. You can verify FF is really using Hwdecoder by addingMOZ_LOG="PlatformDecoderModule:4 env value when spawning the firefox MOZ_ENABLE_WAYLAND=1 MOZ_DISABLE_RDD_SANDBOX=1 MOZ_LOG="PlatformDecoderModule:4" firefox, now you should see rkmpp variants of the decoders are actually being used by FF. Additonally you can add mpp_debug=1 or mpi_debug=1 and mpp library should spit some debug log data on to journalctl -f
  5. If your Browser plays few frames and then suddently stops, it is because the audio output is routed to no existent audio device. Just go to sound settings and select a proper output. This may sound silly, but actually wasted 4 days to figure this out.
  6. You can use https://tools.woolyss.com/html5-audio-video-tester/ site to test various video formats
  7. You can use https://webglsamples.org/aquarium/aquarium.html site to check webgl acceleration.
  8. If you dont want add environment variables to your system you can inject them with editing the .destop files in /usr/share/applications and set the Exec variable as below:
    Exec=env MOZ_ENABLE_WAYLAND=1 MOZ_DISABLE_RDD_SANDBOX=1 /usr/lib/firefox/firefox

Revisions:
10.04.23: Added create a new guide
05.01.23: Updated Linux and Panfork package names and dependencies
08.01.23: Added support for video decoder hardware acceleration
18.01.23: Added Browser Acceleration
23.01.23: Added Kernel Git packages, and renamed the existing as per Archlinux conventions

12 Likes

Thanks, I will for sure try your packages!

Worked pretty well! Saw that youā€™ve also packaged mpp-git, do you plan on packaging the other rockchip specific things as well (e.g. gstreamer)?

Yeah, next target is to provide video acceleration in a maintainable way

Then next provide scripts and packages for blob drivers

Then move kernel to latest bsp source without binaries

Then clean up the pkgbuilds and fix junk and upstream to aur.

Any prs are wellcome.

1 Like

Boogie please have an eye here too so we can keep an eye on your development too: https://discord.gg/rGzM9AAh

Sorry, Iā€™m having a little trouble here. When I download and extract the Arch image directly to /root, upon reboot I either get a flashing cursor or the unit goes into a reboot cycle. I am overwriting the generic Ubuntu server image from the Radxa site. Any ideas? Thanks

For my setup, I recreated the entire root file system with mkfs.ext4. Then I used bsdtar to extract the root tarball, as described on the arch linux arm wiki page. Due to recreating the file system, the file system UUID changed, so I edited the boot entry in the extlinux config file. After that, everything just booted right away. Maybe that helps you?

Great. Thank you for your packaging.

I noticed that the bps kernel package is extracted from the official deb instead of building from source. Probably we could also have a build from source one to help make custom kernel builds easier. Sometimes the radxa kernelā€™s config does not fit certain use cases.

1 Like

Awesome had that in mind too for a while but not much experience nor time to do AUR package yet.
Gonna try probably this week-end and hopefully stick with arch as it is my usual dist, avoiding any further from-scratch setup .

Did you create a new partition to do this? I canā€™t overwrite or recreate the root file system because it is mounted and I canā€™t unmount it, ā€˜target is busyā€™. Iā€™m stumped here and missing something 101.

Also providing AUR package(s), to have panfork ā€˜gofasterā€™ version with kernel patches would be nice. Any plans regarding this?

Whereā€™s the ā€˜go-fasterā€™ version? Is it another branch of the panfork repo or a special patchset? I may look into it.

1 Like

I noticed that the dtb files copied are not in the same hierarchy as the kernel is expecting. All rockchip related dtbs should be placed under a ā€˜rockchipā€™ directory instead of placed directly under dtbs. This could break devicetreedir option in extlinux.conf and you have to change that file EVERY TIME you update the kernel.

1 Like

From what Iā€™ve understood this is setting env var PAN_MESA_DEBUG=gofaster either temporarily or system wide. We also need the kernel to be patched to take benefit from it

I made an iso file from my working setup:https://mega.nz/file/Uld0CIiA#CItkZNejNcSNvabMJMq2d4986TW9U5D1PeU4b_1lbxw

@Joperfi You can just try that. Iā€™ve tested this image by flashing to an nvme ssd using balenaEtcher.

I used UUID in fstab so you can also use this image on emmc and sdcard.

You will need an 16GB media to flash this image on, and you need to resize the partition yourself if you disk is much larger than this.

My iso is not miminal and has some packages installed like sudo and git. The default user alarm is already in the wheel group and can sudo without a password. If you want to change such behavior you can just visudo by yourself.

The alarm home folder has opā€™s repo hw_necromancer cloned and rock5 related PKGBUILD are located in hw_necromancer/rock5. You can makepkg the one you want to install/

The boot partition has the dtbs folder changed per This pull request, and the /boot/extlinux/extlinux.conf is modified accordingly. This modification allows me to upgrade kernel and keep the same extlinux.conf file.

5 Likes

@gnattu - Awesome! thanks a bunch. Iā€™ll give it a try soon.

1 Like

@gnattu - Etcher is telling me the disk image is not bootable - missing partition table. It went through the flash process but didnā€™t boot and nothing appears to be on the disk when I check it with Gparted. Iā€™m trying to flash to an nvme drive with a usb adapter. any ideas? Sorry you have to hand hold here. The Radxa images (Debian & Ubuntu) both booted with this drive previously. Thanks

This works great.

Currently i messing around with the display resolution.
With armbian i needed to compile a dtb overlay.
rk3588-add-hdptxphy_hdmi_clk.dts from amazingfate
If i try to compile with
dtc -O dtb -o ~/rk3588-add-hdptxphy_hdmi_clk.dtbo ~/rk3588-add-hdptxphy_hdmi_clk.dts

i get
Error: /home/alarm/rk3588-add-hdptxphy_hdmi_clk.dts:1.1-2 syntax error FATAL ERROR: Unable to parse input tree

Do you have any advice to compile and use it in archlinux?

Thank you in advance

EDIT: It works the same way as in armbian - i had a typo in my dts file - now it works

Great work.

Made testing so easy :smiley:

I will try to test these pkgbuild on Manjaro Rootfs.

Thanks.

Canā€™t believe booting archlinux was easy as just replacing rootfs

Once booted tried upgrading packages but got traditional signature errors, as archlinux-keyring provided in archlinuxarm rootfs tarball is very old (from july)

Trying to update it alone but then get invalid or corrupted package (PGP signature). Anyone else with same issue?

Usually I can solve it with a few pacman cache clean/refresh commands but here seems different