Jump to content

Xiaomi Redmi 4 Prime (xiaomi-markw)

From postmarketOS Wiki
Note This device is supported as part of a generic port. Refer to Generic MSM8953 (qcom-msm8953) for installation instructions and more information.
Xiaomi Redmi 4 Prime
xiaomi-markw showing neofetch
xiaomi-markw showing neofetch
Manufacturer Xiaomi
Name Redmi 4 Prime
Codename xiaomi-markw
Released 2016
Type handset
Hardware
Chipset Qualcomm Snapdragon 625 (MSM8953)
CPU Octa-core 2 GHz Cortex-A53
GPU Adreno 506
Display 1080x1920 IPS
Storage 32 GB
Memory 3 GB
Architecture aarch64
Software
Original software
The software and version the device was shipped with.
Android (MIUI) 6.0.1
postmarketOS
Category community
Mainline
Instead of a Linux kernel fork, it is possible to run (Close to) Mainline.
yes
pmOS kernel
The kernel version that runs on the device's port.
mainline
Generic port Generic MSM8953 (qcom-msm8953)
Device package Device package
Kernel package Kernel package
Features
Flashing
It is possible to flash the device with pmbootstrap flasher.
Works
USB Networking
After connecting the device with USB to your PC, you can connect to it via telnet (initramfs) or SSH (booted system).
Works
Internal storage
eMMC, SD cards, UFS, ...
Works
Battery
Charging and battery level reporting works
Works
Screen
Display works. Ideally with sleep mode and brightness control.
Works
Touchscreen
Works
Multimedia
3D Acceleration
Works
Audio
Audio playback, microphone, headset and buttons.
Partial
Camera
Partial
Camera Flash
Broken
IR TX
Broken
Connectivity
WiFi
Works
Bluetooth
Works
GPS
Partial
Modem
Calls
Works
SMS
Works
Mobile data
Partial
Miscellaneous
FDE
Full disk encryption and unlocking with unl0kr.
Works
USB OTG
USB On-The-Go or USB-C Role switching
Works
Sensors
Accelerometer
Auto screen rotation works in desktops e.g. Phosh or Plasma Mobile
Works
Magnetometer
Sensor to measure magnetism
Works
Ambient Light
Partial
Proximity
Works
Haptics
Works

Device Notes

Touch Screens

Touch Screen Status
atmel,maxtouch Partial
edt,edt-5336 (edt,edt-ft5x06) Works

Both variants of touch screen use the same pins, so we can't just enable both drivers at a same time. Starting from 6.7.9, we let lk2nd to enable a device tree node of a touch screen. The touch screen won't work until you update lk2nd. For now, lk2nd can only enable focaltech, so you need to build lk2nd by youself if you have atmel (just comment ft and uncomment atmel in dts/msm8953-xiaomi-markw.dts in the sources)

Modem

Voice calls are working, SMS - untested yet, but should work. Mobile data doesn't work for me (vipaol), but maybe you're lucky. Mobile data works fine (apertureua), was this fixed?

Sound

Appears to struggle from a broken PipeWire config on UIs that use it as of March 2025, see Sxmo/Sound

Cameras

Both sensors are working in megapixels, but camera switching doesn't work for an unknown reason (probably it used to be a bug of megapixels, but now we also have some problems with VFEs in the kernel). The config for megapixels is below: ... Now megapixels have config for markw out of the box.

Sometimes numbers of i2c buses with the cameras can be different (aliases in i2c should help, but the maintainer is lazy) and they should be changed in the config ("media-links" lines).

markw:~$ media-ctl -p | grep -E "s5|ov"
  <- "s5k3l8 3-002d":0 [ENABLED,IMMUTABLE]
  <- "ov5670 4-0036":0 [ENABLED,IMMUTABLE]
- entity 184: ov5670 4-0036 (1 pad, 1 link)
- entity 186: s5k3l8 3-002d (1 pad, 1 link)

# we can see rear camera on i2c-3, and front on 4

None of vfeX_rdiX other than vfe0_rdi0 will work on recent kernel versions, so we can't use both cameras at a same time because we have only one working "output channel". Also csid2 doesn't work, but csid0 and csid1 work.

Sensors

Connected to i2c-gpio

Sensor Model Status
Accelerometer/Gyroscope bosch,bmi120 (bosch,bmi160) Works
Light/Proximity liteon,ltr559 (liteon,ltr501) Works
Magnetometer yamaha,yas537 (yamaha,yas530) Works

UART

The working voltage is 1.8 V. Warning: the test points are very small, soldering is not recommended. It's probably better to just hold a wire with a hard thin end with your hands.

See also: Serial debugging

How to enter flash mode

[Power] + [Vol-] to fastboot mode

Installation

Note The device now uses the generic device port. You need to select qcom-msm8953 (Generic MSM8953) instead of xiaomi-markw.
Warning WARNING: Installation on the internal memory will erase all your data!

Pre-built images

Download the image and lk2nd for Generic MSM8953. Once downloaded, extract the files with unxz or any compatible archiver.

Step 1. Flash rootfs:

- To SD-card
The downloaded rootfs img is a sparse img. You need to convert it to a normal img before flashing it to an SD-card:
$ simg2img <...>-qcom-msm8953.img nonsparse-converted.img
Then just write it using a tool for writing images.
- To internal memory
$ fastboot flash userdata <...>-qcom-msm8953.img

Step 2. Flash lk2nd:

$ fastboot flash boot <...>-lk2nd.img

lk2nd is a second stage bootloader that is used for booting the generic image and for some device-specific hacks. It boots the kernel with initramfs from the "pmOS_boot" subpartition using extlinux.

If you see < waiting for any device >, try running as sudo and restart your device into fastboot mode again.

Manual build

Note The device now uses the generic device port. You need to select qcom-msm8953 instead of xiaomi-markw.

Step 1. Flash rootfs:

- To SD-card
Find your SD-card: lsblk
Install (change /dev/sdX to your card)
$ pmbootstrap install --sdcard /dev/sdX
- To internal memory
$ pmbootstrap install
$ pmbootstrap flasher flash_rootfs

Step 2. Flash lk2nd:

$ pmbootstrap flasher flash_lk2nd

lk2nd is a second stage bootloader that is used for booting the generic image and for some device-specific hacks. It boots the kernel with initramfs from the "pmOS_boot" subpartition using extlinux, so you don't need to use flash_kernel

Dual-boot with Android

Icon This page could use some expansion. If you'd like to help out, feel free to edit this article!
Warning WARNING: Your warranty is now void. We are not responsible for bricked devices, dead SD cards, thermonuclear war, or you getting fired because the alarm app failed.

1. Make sure that both normal and critical partitions are unlocked.

2. Flash your favorite custom recovery with terminal access and boot into it (eg. `adb shell`).

Note OrangeFox and Lineage/CrDroid recoveries seem to hang when userdata is invalid, try a TWRP port
Note If you flashed an unlock bypass from the internet as aboot and you can no longer boot to recovery, you need mainline lk2nd to use it

3. `adb push` a static build of `gdisk` (this one seems to work) into the root of the recovery ramdisk.

4. Unmount userdata (if possible).

5. Use `gdisk` to write down all of the UUIDs of the userdata partition, then delete it and create a new one with the same parameters and name but a different size so that pmOS can fit, then create a new partition named `pmOS_root` with the type "Linux aarch64 filesystem". Don't forget to `sync` after making your changes. It's suggested to pull a backup of the table back onto your computer.

6. Reboot into a fastboot interface. On your local machine, create an empty file to overwrite the filesystem headers (on *nix that would be `dd if=/dev/zero of=1g.img bs=512M count=1`) and flash it to both of the new partitions. This will let some recoveries boot.

7. Reboot back into recovery and format userdata via the shell OR make an empty partition on your local machine and flash it via fastboot (slow). Most ROMs work fine with F2FS, generally suggested flags: `extra_attr,inode_checksum,sb_checksum`. Don't forget to `sync` (or `fastboot reboot`) again!

8. Reboot into recovery again and flash some firmware as usual! This LineageOS port seems to work fine. Unsure why, but crDroid from the same author seems to brick itself after precisely 24 hours of total uptime. If you wish to install root, do it now and make sure it works via the provided root app (if applicable).

9. Reboot to a recovery again, via `adb shell` copy the resulting boot partition to root (`cp /dev/block/by-name/boot /`) and then `adb pull` it (using it directly doesn't seem to be reliable).

10. Reboot to fastboot yet again, make sure to flash lk2nd to boot if it's not currently installed, flash the Android boot to recovery (!!!) and proceed with making an image as per pmOS instructions to flash in `pmOS_root`.

Now, holding volume up will boot Android and doing nothing will boot pmOS.

Warning WARNING: Do NOT use "advanced reboot" or `adb reboot {target}` via Android, as that will cause an infinite loop of booting. Temporarily flash TWRP then use "reboot to system" to exit it.
Warning WARNING: The whole swapped boot/recovery thing as well as lk2nd should be reverted before an update via Android.

Users owning this device

  • Adomerle (Notes: On pmOS)
  • ApertureUA (Notes: Atmel with green lightsaber stripe in the middle focaltech, unlocked with aboot patch)
  • Vipaol (Notes: pmOS,Ebbg+Atmel)

Maintainer(s)

Contributors

See also

OSZAR »