Xiaomi Redmi 9A (xiaomi-dandelion)

From postmarketOS Wiki
Xiaomi Redmi 9A
File:Xiaomi-dandelion.jpg
Xiaomi Redmi 9A (xiaomi-dandelion)
Manufacturer Xiaomi
Name Redmi 9A
Codename xiaomi-dandelion
Model M2006C3LG
Released 2020
Type "handset"
Hardware
Chipset Mediatek Helio G25 (MT6762G)
CPU Octa-core (4x2.0 GHz Cortex-A53 & 4x1.5 GHz Cortex-A53)
GPU PowerVR GE8320
Display 720 x 1600 IPS LCD
Storage 32GB
Memory 2GB
Architecture aarch64
Software
Original software MIUI 12
Original version Android 10
postmarketOS
Category testing
Pre-built images no
postmarketOS kernel 6.x.x
Unixbench Whet/Dhry score 0.0
This device is marked as not booting.


Contributors

  • Paradoxvirus

Users owning this device


How to unlock device

How to enter flash mode

How to port device (overview)

1. Create pmbootstrap config files

2. Find the Linux kernel fork used by the device

3. Edit pmbootstrap config to point it to the kernel

4. Download the kernel

5. Compile the kernel

...

How to port device (in progress)

See official docs for up to date and more complete instructions. I recommend reading the installation guide, this guide and the official porting guide before running anything.

See also https://github.com/SheatNoisette/postmarket_redmi_9a/tree/main

Install pmbootstrap

What worked best for me was just using the latest version from Gitlab directly and not trying to install it.

git clone https://gitlab.com/postmarketOS && cd postmarketOS

./pmbootstrap.py --version

Initialize

./pmbootstrap.py init

As far as I can tell, this creates files in

$workdir/aports/device/testing/device-xiaomi-dandelion $workdir/aports/device/testing/linux-xiaomi-dandelion

or

$workdir/cache_git/aports/device/testing/device-xiaomi-dandelion $workdir/cache_git/aports/device/testing/linux-xiaomi-dandelion

and populates them according to the inputs you submitted.

Find the Linux kernel fork

If the device is supported by LineageOS, you can find the kernel on their GitHub repo. The same goes for other custom ROMs.

In this case, LineageOS does not support the device but the vendor (Xiaomi) open sources the kernels on https://github.com/MiCode/Xiaomi_Kernel_OpenSource.

Find the branch of the (same) repository that the kernel is hosted on and access it: https://github.com/MiCode/Xiaomi_Kernel_OpenSource/tree/dandelion-q-oss.

Tell pmbootstrap where the kernel is hosted

cd $workdir/cache_git/aports/device/testing/linux-xiaomi-dandelion

vim APKBUILD

Change the url, the _repository variable and the _commit variable in the APKBUILD so that they point to the latest commit in the branch of the git repo where the kernel is hosted.

< pkgver=4.9.190
---
> pkgver=3.0.0
26,27c26,27
< _repository="Xiaomi_Kernel_OpenSource"
< _commit="8974b9164af90d94603900b229264ae879a83a83"
---
> _repository="(CHANGEME!)"
> _commit="ffffffffffffffffffffffffffffffffffffffff"
30c30
< 	$pkgname-$_commit.tar.gz::https://github.com/MiCode/$_repository/archive/$_commit.tar.gz
---
> 	$pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz

Tell pmbootstrap what version of the kernel you found

Find the kernel version from the Makefile in the GitHub repo. In this case, as of October 2024,

VERSION = 4

PATCHLEVEL = 9

SUBLEVEL = 190

This is equivalent to kernel version 4.9.190

Download the kernel configuration (defconfig)

In this kernel fork there are many defconfig files and I'm not sure which one to use, but I think it makes most sense to use the one called dandelion-defconfig, even though this one isn't mentioned in the build.config files that are in the root of the project.

wget https://raw.githubusercontent.com/MiCode/Xiaomi_Kernel_OpenSource/refs/heads/dandelion-q-oss/arch/arm64/configs/dandelion_defconfig -O $HOME/.local/var/pmbootstrap/cache_git/pmaports/device/testing/linux-xiaomi-dandelion/config-xiaomi-dandelion.aarch64

Check that it has been downloaded and saved correctly by opening it.

vim config-xiaomi-dandelion.aarch64

Download and verify the kernel

pmbootstrap checksum linux-xiaomi-dandelion

Remove the patches that fail

Run the following code to check which patches fail.

pmbootstrap kconfig edit linux-xiaomi-dandelion

Remove the patches that fail from the directory and from the APKBUILD.

Calculate new checksums.

pmbootstrap checksum linux-xiaomi-dandelion

Try again.

pmbootstrap kconfig edit

Add the patch that fixes the ncurses error

pmbootstrap kconfig edit linux-xiaomi-dandelion

The above line fails for me with the error Install ncurses (ncurses-devel) and try again., so I download the patch to the directory and add it to the APKBUILD file as described in the docs.

Regenerate the checksums to add the patch.

pmbootstrap kconfig checksum linux-xiaomi-dandelion

Retry.

pmbootstrap kconfig edit linux-xiaomi-dandelion

Build (compile) the kernel

Find or create patches to fix kernel errors

Compile with GCC6 if you can't make it compile

Extract and analyze the boot image

Get a boot image from TWRP, LineageOS or extract it from running android.

How to install to device (after successful porting)

Flash

Add support for full disk encryption

Upstream and mainline

See also