PostmarketOS for Xiaomi Angelican (Redmi 9C NFC)
This port also might work on angelica (without NFC) and other phones on MT6765 processors (like Redmi 9A). If you want to develop it together, or maybe you have a working port, please write me in discord/telegram: @meexreay. Also you can find more about me on my site: meex.lol
Roadmap
- Kernel compiling
- Kernel booting
- Debug shell
- SSH (use
ssh 172.16.42.1
) - Display + Touchscreen (i3wm works)
- Buffyboard now works
- Phosh now works
- Split firmware and device info
- Mainline
How to install
Run these commands to add the device to pmaports:
git clone https://github.com/MeexReay/pmos-xiaomi-angelican.git
cd pmos-xiaomi-angelican
PMAPORTS=$(pmbootstrap config | sed -n 's/^aports = //p')
ln -s $PWD/linux-xiaomi-angelican $PMAPORTS/device/testing
ln -s $PWD/device-xiaomi-angelican $PMAPORTS/device/testing
# or just ./install.sh
How to prepare a phone
Unlock bootloader
Here is described the unofficial method with mtkclient
Install dependencies
Install libraries:
- libusb / libusb1
- fuse2 / libfuse2
Install rules:
git clone https://github.com/bkerler/mtkclient
cd mtkclient
sudo usermod -a -G plugdev $USER
sudo usermod -a -G dialout $USER
sudo cp mtkclient/Setup/Linux/*.rules /etc/udev/rules.d
sudo udevadm control -R
sudo udevadm trigger
Then reboot.
Prepare mtkclient
git clone https://github.com/bkerler/mtkclient
cd mtkclient
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
git clone https://github.com/coloredmarble/redmi_9a_mtkclient
cp redmi_9a_mtkclient/* .
Unlock
- Run this command:
python mtk.py da seccfg unlock --preload preloader_k62v1_64_bsp.bin --loader n.bin
- Power off the phone, hold
Volume Up
andVolume Down
buttons at the same time and connect usb cable
Backup full flash
To backup:
python mtk.py rf backup.bin --preload preloader_k62v1_64_bsp.bin --loader n.bin
To restore:
python mtk.py wf backup.bin --preload preloader_k62v1_64_bsp.bin --loader n.bin
My backup image (7zip compressed)
Flash stock firmware with fastboot
It is recommended to flash stock firmware before doing anything.
Download Firmware (MIUI v12.0.16.0) and unpack it
- Open the firmware directory in console
- Remove flashing your vbmeta and recovery partitions (optional):
sed -i '/flash vbmeta/d;/flash recovery/d' flash_all.sh
- Connect the phone in fastboot mode (not fastbootd)
- Run
./flash_all.sh
Flash stock firmware with mtkclient (experimental)
This guide can be helpful to unbrick a phone.
Download Firmware (MIUI v12.0.16.0) and unpack it
- Open the firmware directory in console.
- Clone mtkclient stuff:
git clone https://github.com/bkerler/mtkclient
cp -r mtkclient/* .
git clone https://github.com/MeexReay/mtkclient-angelican
cp mtkclient-angelican/* .
- Run
./flash_all_mtkclient.sh
- Power off the phone, hold
Volume Up
andVolume Down
buttons and connect usb cable
Flash recovery
It is strongly recommended to flash the recovery.
Orangefox recovery page
Download recovery
Here is a simple script to download and flash it automatically (for linux):
cd /tmp
curl -o recovery.zip https://dl.orangefox.download/62bb16c36a44bc738419d9bb
unzip recovery.zip recovery.img
fastboot flash recovery recovery.img
rm recovery.zip recovery.img
How to flash
- Build images
pmbootstrap init
pmbootstrap install
- Flash partitions
Enter fastboot mode (hold vol- and pwr buttons while turned off), and run these commands:
pmbootstrap flasher flash_vbmeta --partition vbmeta
pmbootstrap flasher flash_vbmeta --partition vbmeta_system
pmbootstrap flasher flash_vbmeta --partition vbmeta_vendor
pmbootstrap flasher flash_kernel # flash kernel to boot
fastboot reboot fastboot # enter fastbootd mode
pmbootstrap flasher flash_rootfs # flash rootfs to system
pmbootstrap flasher flash_rootfs --partition userdata # flash rootfs to userdata
- Reboot
Important
Always leave from fastboot with
fastboot reboot
fastboot reboot
See also
- adomerle's mainline kernel fork
- xiaomi angelican wiki
- orangefox recovery
- my firmware images mirror
- mtkclient
- ubuntu touch installation
- ubports community redmi 9c
- mt6765 wiki
- mtkclient redmi loader
- working mt6765 port (lg-mmh4x)
- xiaomi angelica wiki
- xiaomi dandelion wiki
- postmarket redmi 9a
- linux on redmi 9c/9a in telegram
- 4pda topic about redmi 9c nfc
Contributing
If you would like to contribute to the project, feel free to fork the repository and submit a pull request.