User:Librecat/Redmi Note 12 Pro 4G(sweet k6a)
Introduction
this phone has 4 variants :2 touch and 2 panel variants
goodix touch vs ? touch and 2 panel variants
Preparing the root file system
i recommend starting from arm64 desktop stage3 of your desired init system. Use qemu chroot to prepare your root file system on a workstation as compiling on your phone can introduce wear on the battery and internal flash(find a reputable source to cite this) lots of mobile related packages are missing from the gentoo tree(make a list and provide an overlay for initial ebuilds)
Setting up the Stage3 and QEMU Chroot
TODO
making a folder for the chroot to live in
TODO
choosing a arm64 stage3
TODO
unpacking the stage3
TODO
entering the chroot environment with instructions from the embedded handbook
TODO
first sync and update
TODO
Configuring the system and installing desired packages
System Configuration
TODO
CFLAGS
Source: https://en.wikipedia.org/wiki/List_of_Qualcomm_Snapdragon_systems_on_chips
https://en.wikipedia.org/wiki/ARM_Cortex-A76
https://en.wikipedia.org/wiki/ARM_Cortex-A55
COMMON_FLAGS="-O2 -pipe -march=armv8.2-a+crypto+rcpc+dotprod -mtune=cortex-a76.cortex-a55"
cortex-a76.cortex-a55 is a supported mtune in gcc to tune the performance for a big.little system
VIDEO_CARDS
This smartphone has an adreno gpu so freedreno should do the trick
VIDEO_CARDS="freedreno"
INPUT_DEVICES
TODO
Packages of Intrest
TODO
enabling the modem
TODO
installing a desktop environment
TODO
package todo
Phosh - in guru
Kde Plasma Mobile - in some random overlay
SXMO - in progress in my overlay
Qualcomm modem packages - ?????
Compiling the kernel
clone the sm7150-mainline kernel
get defconfig from postmarketOS port from Vilez
edit dts for different panel
if you dont have goodix touchscreen there is no driver yet
Alternative: repack postmarketOS kernel:
First unpack the kernel image generated by postmarketOS
clone mkbootimg
git clone https://github.com/osm0sis/mkbootimg
compile the unpackbootimg and mkbootimg programs
make
unpack the boot image
mkdir sweet_k6a-mainline
./unpackbootimg -i /path/to/boot/image/boot.img -o sweet_k6a-mainline
repack the boot image
cd sweet_k6a-mainline
../mkbootimg --base "$(cat boot-mainline.img-base)" --board "$(cat boot-mainline.img-board)" --cmdline "root=/dev/sda25 loglevel=5" --hashtype "$(cat boot-mainline.img-hashtype)" --header_version "$(cat boot-mainline.img-header_version)" --kernel boot-mainline.img-kernel --kernel_offset "$(cat boot-mainline.img-kernel_offset)" --pagesize "$(cat boot-mainline.img-pagesize)" --ramdisk ../initramfs-6.10.3-sm7150.img --ramdisk_offset "$(cat boot-mainline.img-ramdisk_offset)" --second_offset "$(cat boot-mainline.img-second_offset)" --tags_offset "$(cat boot-mainline.img-tags_offset)" -o gentoo-sweet_k6a-bootimg.img
Installing the root file system and kernel
in orangefox recovery:
backup super boot and dtbo partitions you will need them to restore android
enter adb shell
adb shell
format the super partition to use as the root partition for gentoo
busybox mkfs.ext2 /dev/block/sda25
exit adb shell to push the rootfs
adb push gentoo-rootfs.tar /sdcard/
enter adb shell again to unpack the rootfs
adb shell
mount /dev/block/sda25 /mnt
cd /mnt
tar -xvpf /sdcard/gentoo-rootfs.tar
now you can configure the system but keep in mind that internet connection is not usable in recovery
flashing the kernel:
reboot into bootloader mode
once the phone says fastboot on the screen(instructions from https://wiki.postmarketos.org/wiki/Xiaomi_Redmi_Note_10_Pro_(xiaomi-sweet) and https://wiki.postmarketos.org/wiki/Xiaomi_Redmi_Note_12_Pro_(4G)_(xiaomi-sweet_k6a) )
fastboot erase dtbo
fastboot flash boot gentoo-sweet_k6a-bootimg.img
now you can reboot your phone to test
Entering chroot from recovery to change configuration
mount /dev/sda25 /mnt
cd /mnt
mount --rbind /dev ./dev
mount --rbind /sys ./sys
mount --rbind /proc ./proc
chroot . /bin/bash --login
now do whatever you want just dont forget to sync before rebooting the phone
Preparing a binhost on your workstation to compile updates
TODO
Kernel updates
TODO