Skip to content

Flashing Guide

Jianfeng Liu edited this page Oct 16, 2024 · 21 revisions

Pre-installation

Check which panel you are using

You have to check kernel cmdline of your device.

You can see it from adb root shell or recovery shell by command cat /proc/cmdline.

msm_drm.dsi_display0=qcom,mdss_dsi_k81_42_02_0a_dual_cphy_video is CSOT panel.

msm_drm.dsi_display0=qcom,mdss_dsi_k81_35_02_0b_dual_cphy_video is BOE panel.

Partition the UFS

This procedure will wipe all your Android data!!!

We are going to resize userdata partition of android and create two partitions for our armbian installation.

You need to boot into a recovery, I recommend Orange Fox Recovery Project. You will also need parted.

You need to decompress the 7z archive to get the files, like parted.7z -> parted.

Then push the tools to your device and enter ADB shell:

adb push parted /cache/
adb shell "chmod 755 /cache/parted"
adb shell

After entering ADB shell:

cd /cache
./parted /dev/block/sda

Print the current partition table:

(parted) print

Then you will see your current partition table with userdata being the last partition.

Below is an example of output:

.........
Number  Start    End      Size     File system   Name       Flags
.........
34      2048MB   122GB    120GB    ext4          userdata

Now let’s continue partitioning:

Here the size of userdata can be decided by yourself. In this guide we take 30G as the example.

(parted) resizepart 34
# 34 is the partition number for userdata
End? [122GB]? 32GB

32GB is the End value for the new userdata partition.

Since the starting point for userdata is 2048MB = 2GB, the new size would be 32G - 2G = 30G.

Then create the linux and esp partitions:

# esp partition for booting
(parted) mkpart esp fat32 32GB 32.5GB
# set the esp partition as `EFI system partition type`
(parted) set 35 esp on
# partition for installing Linux
(parted) mkpart linux ext4 32.5GB 100%

Exit the parted tool finally.

(parted) quit

Now userdata resizing is done. After reboot to android you will get into a emergency mode, you will have to wipe the data to boot into android with resized userdata partition.

Installation

Download images

https://github.com/amazingfate/armbian-xiaomi-elish/releases/latest

Or armbian official: https://github.com/armbian/os/releases

Flash images

Get into fastboot mode.

First erase dtbo_b:

fastboot erase dtbo_b

Then flash rootfs partition:

fastboot flash linux Armbian_23.11.0-trunk_Xiaomi-elish_jammy_sm8250_6.5.9_gnome_desktop.rootfs.img

Flash boe kernel image if you have BOE panel:

fastboot flash boot_b Armbian_23.11.0-trunk_Xiaomi-elish_jammy_sm8250_6.5.9_gnome_desktop.boot_sm8250-xiaomi-elish-boe.img

Flash boe kernel image if you have CSOT panel:

fastboot flash boot_b Armbian_23.11.0-trunk_Xiaomi-elish_jammy_sm8250_6.5.9_gnome_desktop.boot_sm8250-xiaomi-elish-csot.img

Set B slot active to boot linux:

fastboot set_active b

Post-installation

First login

After booting into armbian, you have to connect typec port to the usb port of a computer and ssh into the system from usb gadget network:

ssh root@172.16.42.1

Default user and password is root/1234, you will set new user and password at first login.

Check your A/B slot

We have flashed armbian's kernel to boot_b, and set the default slot to b to boot armbian by default.

But the slot may change when android os has done a system update. If you have armbian kernel flashed to boot_a, you also have to update /boot/armbianEnv.txt with:

abl_boot_partition_label=boot_a

And check output of cat /proc/cmdline, if something like slot_suffix=_b is wrong, you have to run this command to set correct slot in kernel args.

sudo dpkg-reconfigure linux-image-current-sm8250

If everything is correct, you should see output from sudo qbootctl like this:

Current slot: _b
SLOT _a:
        Active      : 0
        Successful  : 1
        Bootable    : 1
SLOT _b:
        Active      : 1
        Successful  : 1
        Bootable    : 1

slot b is where armbian's kernel is flashed, and Active, Successful and Bootable are all 1.

Toggle USB role

USB role of typec port is device mode by default for usb gadget network. If you want to connect devices like keyboard to typec port, you have to toggle the role manually to host mode, run the following commands under root:

systemctl stop usbgadget-rndis.service
echo host > /sys/kernel/debug/usb/a600000.usb/mode

Then you can see two new bus from command lsusb -t:

/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 10000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 10000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M

Chromium hardware accelerated video decoding

On ubuntu jammy a special build of chromium is necessary: https://launchpad.net/~liujianfeng1994/+archive/ubuntu/chromium.

All the changes to chromium is submitted to chromium v121 so be patient to wait it packaged for debian.

You also need a udev rule to create devices chromium uses:

Create a file /etc/udev/rules.d/90-chromium-video.rules with the following contents:

SUBSYSTEM=="video4linux", ATTR{name}=="qcom-venus-decoder", SYMLINK+="video-dec%n"
SUBSYSTEM=="video4linux", ATTR{name}=="qcom-venus-encoder", SYMLINK+="video-enc%n"

Open chromium and see Video Acceleration Information in page chrome://gpu, you should see h264, vp8, vp9 and hevc are supported.