Jump to content

Xiaomi POCO F5 / Redmi Note 12 Turbo (xiaomi-marble)

From Nura Wiki
Xiaomi POCO F5
Redmi Note 12 Turbo
System settings info page screenshot
System settings info page screenshot
Manufacturer Xiaomi
Name POCO F5
Redmi Note 12 Turbo
Codename xiaomi-marble
Model 23049PCD8G, 23049PCD8I (POCO F5), 23049RAD8C (Redmi Note 12 Turbo)
Released 2023
Type handset
Hardware
Chipset Qualcomm Snapdragon 7+ Gen 2 (SM7475)
CPU Octa-core (1x 2.91 GHz Cortex-X2
3x 2.49 GHz Cortex-A710
4x 1.80 GHz Cortex-A510)
GPU Adreno 725
Display 1080x2400 (6.67" AMOLED, 120 Hz)
Storage 256/512 GB (UFS 3.1), 1 TB (Redmi Note 12 Turbo)
Memory 8/12 GB (LPDDR5X), 16 GB (Redmi Note 12 Turbo)
Architecture aarch64
Software
Original software
The software and version the device was shipped with.
Android (MIUI) 13 (MIUI 14)
Extended version
The most recent supported version from the manufacturer.
Android (MIUI) 15 (HyperOS 3)
FOSS bootloader no
Nura
Category testing
Pre-built images
Whether pre-built images are available from the Nura Installation page.
no
Mainline
Instead of a Linux kernel fork, it is possible to run (Close to) Mainline.
yes
Nura kernel
The kernel version that runs on the device's port.
7.2.8
Features
Flashing
Whether 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
Whether charging and battery level reporting work.
Works
Screen
Whether the display works; ideally with sleep mode and brightness control.
Works
Touchscreen
Works
Multimedia
3D Acceleration
Works
Audio
Audio playback, microphone, headset and buttons.
Works
Camera
Partial
Camera Flash
Broken
IR TX
Broken
Connectivity
Wi-Fi
Works
Bluetooth
Works
GPS
Works
NFC
Near Field Communication
Broken
Modem
Calls
Works
SMS
Works
Mobile data
Works
Miscellaneous
FDE
Full disk encryption and unlocking with unl0kr.
Works
USB OTG
USB On-The-Go or USB-C Role switching.
Works
Fingerprint
Fingerprint reader.
Broken
Sensors
Accelerometer
Handles automatic screen rotation in many interfaces.
Works
Magnetometer
Sensor to measure the Earth's magnetism
Works
Ambient Light
Measures the light level; used for automatic screen dimming in many interfaces.
Works
Proximity
Works
Haptics
Works
Power Sensor
Sensor to monitor current, voltage and power. Not fuel gauge!
Works
U-Boot
Primary Bootloader
Whether it is possible to replace stock bootloader with U-Boot.
Broken
Secondary Bootloader
Whether it is possible to chainload U-Boot from stock bootloader.
Works
Mainline
Whether latest upstream versions of U-Boot are not broken and it is possible to use them.
Works
Internal Storage
Whether it is possible to boot from internal storage (e.g. eMMC or UFS).
Works
USB Host
Whether it is possible to boot from a USB storage or connect a keyboard.
Broken
USB Peripheral
Whether it is possible to use device as a peripheral in U-Boot, e.g. for fastboot mode.
Works
Display
Works
Buttons
Whether it is possible to navigate in boot menu or grub with volume and power buttons.
Works

The Xiaomi POCO F5 and its Chinese counterpart, the Redmi Note 12 Turbo, share the codename marble. The SM7475 SoC is closely related to the SM8475 (Snapdragon 8+ Gen 1): all clock controllers are the SM8475 ("cape") variants, so the port uses the mainline SM8450/SM8475 drivers and device tree base.

The port runs a Linux 7.2 kernel with device-specific patches. It is not packaged in pmaports yet. My(iLtanaka) Nura is installed next to Android on the internal storage and is booted through mainline U-Boot, which is chainloaded by the stock Android bootloader (ABL).

Special boot modes

  • Fastboot: Hold Volume Down + Power while the phone is off.
  • Recovery: Hold Volume Up + Power while the phone is off.
  • U-Boot menu: Hold Volume Down while U-Boot starts, or wait for the 5 second boot menu.
  • EDL: Xiaomi EDL needs an authorized account and cannot be used as a normal recovery path. Avoid any change to the boot chain LUNs.

Bootloader unlock

The bootloader has to be unlocked with Xiaomi's official unlock tool, which applies a waiting period. Unlocking erases all data. Check the state in fastboot mode:

$ fastboot getvar unlocked

Boot flow

My daily boot path is:

ABL (stock) → U-Boot (flashed to boot_b) → extlinux.conf on the esp partition → Linux kernel, initramfs and DTB from /boot.

U-Boot is packed as an Android boot image with an appended DTB, which ABL requires. ABL still loads vendor_boot_b, but U-Boot ignores it. The esp partition is found by its GPT label, not by a fixed device number. The kernel command line is set in /boot/extlinux/extlinux.conf, so it can be changed from Linux without flashing. A U-Boot USB serial console (/dev/ttyACM0 on the host) is available on every cold boot.

The U-Boot boot menu offers:

  • Boot Nura (default)
  • Other systems (needs an others.env file on the esp partition; empty on a normal installation)
  • Serial console shell (USB ttyACM)
  • Enable USB mass storage (exports UFS LUN 0 to the PC)
  • Enable fastboot mode
  • Drop to shell, reset device, power off, and three information entries (environment, board info, bootargs)

Kernel and DTB updates are written to /boot by boot-deploy. The boot_b partition is never rewritten, because /etc/deviceinfo sets:

deviceinfo_flash_kernel_on_update="false"

The kernel command line used on the tested device contains these device-specific parameters:

clk_ignore_unused pd_ignore_unused regulator_ignore_unused fw_devlink=permissive deferred_probe_timeout=30 pcie_aspm=off

Installation

Installation is done from a Linux PC. U-Boot is flashed to slot B, the root filesystem is built with pmbootstrap, and the phone exports its internal storage over USB from the U-Boot menu. The marble-install script from the u-boot-marble repository then creates the partitions and writes the images. A custom recovery is not needed.

Both layouts erase the Android user data:

  • Single boot - the userdata partition is replaced by esp and pmos. Android on slot A can no longer start.
  • Dual boot - userdata is shrunk and esp and pmos are added at the end of LUN 0. Android is kept on slot A and needs a data wipe before its next start.

Only UFS LUN 0 is exported by U-Boot. The boot chain on the other LUNs cannot be reached from the PC.

Prerequisites

  • Unlocked bootloader, see Bootloader unlock
  • PC with fastboot, Python 3, pmbootstrap 3.11 or newer, e2fsprogs and util-linux (and cryptsetup for an encrypted root)
  • A backup of the Android data and of the persist, modemst1, modemst2 and fsg partitions
  • boot-uboot.img, either from the u-boot-marble releases or built with scripts/pack-marble-bootimg.sh

1. Flashing U-Boot to slot B

U-Boot is chainloaded by the stock ABL from boot_b, so Android on slot A stays intact. In fastboot mode, the active slot is queried twice (the first answer after a reboot can be wrong), U-Boot is written to boot_b and slot B is made active:

$ fastboot getvar current-slot
$ fastboot getvar current-slot
$ fastboot flash boot_b boot-uboot.img
$ fastboot set_active b
$ fastboot reboot

2. Building the images

The device packages are in a pmaports fork. pmbootstrap reads channels.cfg from the upstream branch, so the upstream remote has to be added before pmbootstrap init:

$ git clone -b marble https://github.com/iLtanaka/pmaports.git
$ git -C pmaports remote add upstream https://gitlab.postmarketos.org/postmarketOS/pmaports.git
$ git -C pmaports fetch --depth=1 upstream main
$ pmbootstrap --aports=./pmaports init

In pmbootstrap init, vendor xiaomi, codename marble and a user interface (for example Plasma Mobile or Phosh) are selected. The firmware package is not built automatically and has to be built first; otherwise the installation fails with no such package for the firmware-xiaomi-marble-* subpackages. The --split option creates separate boot and root images:

$ pmbootstrap build firmware-xiaomi-marble
$ pmbootstrap install --split --fde --add postmarketos-buffybox-unl0kr

Without full disk encryption, pmbootstrap install --split is used. The images are written to ~/.local/var/pmbootstrap/chroot_native/home/pmos/rootfs/ as xiaomi-marble-boot.img and xiaomi-marble-root.img.

3. Exporting the storage

After a reboot, Volume Down is held while U-Boot starts (or a key is pressed during the countdown). The entry Enable USB mass storage exports LUN 0 to the PC as a USB disk. The script finds it by its partition names and refuses any other disk:

$ scripts/marble-install list
$ scripts/marble-install show

4. Writing the images

The plan is printed first, and nothing is written with --dry-run. The script saves the old partition table to a .bak file, creates the partitions, writes and verifies the images and grows the filesystems. An encrypted root asks for its passphrase during this step.

$ scripts/marble-install install --layout single --dry-run
$ scripts/marble-install install --layout single

For a dual boot, --layout dual --pmos-size 64G is used instead. The remaining userdata has to be larger than 32 GiB. --layout reinstall writes new images to existing esp and pmos partitions.

5. Booting

A key press on the phone leaves mass storage mode. Boot Nura starts the system, and an encrypted root asks for the passphrase on the touchscreen.

For a dual boot, Android is started again by making slot A active, booting the recovery and wiping the data:

$ fastboot set_active a

Recovery

  • After repeated boots, ABL switches from slot B to slot A. fastboot set_active b selects slot B again.
  • scripts/marble-install restore FILE writes a saved partition table back. The data in pmos is lost.
  • A partition table can also be created by hand: U-Boot needs a GPT partition labeled esp on LUN 0 with /extlinux/extlinux.conf. The storage uses 4096-byte sectors, so tools that assume 512 bytes must not be used, and filesystems need a block size of at least 4096 bytes.

Hardware support

Component Status Notes
Display Works Command-mode DSC AMOLED panel, 120 Hz
Touchscreen Works Goodix Berlin
GPU Works Adreno 725 (Adreno 730 family), msm DRM with Freedreno and Turnip
Video decoding Works Iris (Venus) H.264, HEVC and VP9 through V4L2
Video encoding Works Iris H.264 and HEVC through V4L2 (v4l2h264enc, h264_v4l2m2m); needs out-of-tree patches for the secure (non-pixel) buffer region. Applications that do not use V4L2 encoders fall back to software encoding, see Camera
Wi-Fi Works WCN6855 on PCIe, ath11k driver
Bluetooth Works A2DP audio tested
Mobile data Works LTE through IPA v5.1 and ModemManager; the APN has to be set manually
SMS Works
Calls Works Earpiece, loudspeaker and main microphone; needs out-of-tree AudioReach voice routing patches, see Audio
Audio Works Stereo speakers (AW88263S amplifiers, aw88261 driver) and main microphone (WCD9385) work
GPS Works Needs patched libqmi and ModemManager, see GPS
Battery Works Capacity, current and power reporting through pmic-glink
Charging Works Fast charging (about 23 W measured) needs a patched qcom_battmgr driver
Sensors Works Accelerometer, gyroscope, magnetometer, light and proximity through the SLPI sensor core (hexagonrpcd); the magnetometer is not calibrated
Haptics Works PM8350B HV haptics driver (out-of-tree) with FF_RUMBLE and feedbackd support
Suspend Works deep sleep with power button wakeup
USB OTG Works
Camera Partial Rear main (OV64B40, 64 MP) and rear ultra-wide (IMX355, 8 MP) sensors work; front and macro sensors, autofocus and flash do not, see Camera
NFC Not working No driver
Fingerprint Not working Side-mounted sensor in the power button
IR transmitter Not working No driver

Partition layout

The UFS storage is split into six LUNs (sda to sdf). The boot chain (xbl, abl and others) lives on LUN 1, 2, 4 and 5. Android uses A/B slots.

Partition Device Size
boot_a /dev/block/sde14 192 MB
boot_b /dev/block/sde42 192 MB
vendor_boot_a /dev/block/sde24 96 MB
vendor_boot_b /dev/block/sde52 96 MB
dtbo_a /dev/block/sde18 24 MB
dtbo_b /dev/block/sde46 24 MB
recovery_a /dev/block/sde27 100 MB
recovery_b /dev/block/sde54 100 MB
vbmeta_a /dev/block/sde17 128 KB
vbmeta_b /dev/block/sde45 128 KB
modem_a /dev/block/sde7 380 MB
modem_b /dev/block/sde35 380 MB
persist /dev/block/sdf7 32 MB
modemst1 /dev/block/sdf3 8 MB
modemst2 /dev/block/sdf4 8 MB
fsg /dev/block/sdf5 8 MB
super /dev/block/sda32 9 GB
userdata /dev/block/sda33 224 GB (stock, 256 GB model)
Warning WARNING: The persist, modemst1, modemst2 and fsg partitions hold device-specific calibration and modem data (including the IMEI). Back them up before any change and never erase them.

Dual boot layout

On the tested device, userdata was shrunk and two partitions were added at the end of LUN 0:

Partition Device Size Content
userdata /dev/sda33 126 GB Android data (formatted again after the resize)
esp /dev/sda34 2 GB ext2 pmOS_boot: kernel, initramfs, DTB, extlinux/extlinux.conf
pmos /dev/sda35 96 GB ext4 pmOS_root

Android data uses f2fs with metadata encryption, so it cannot be shrunk in place. Resizing userdata needs a full backup, a format and a restore.

Audio

Audio runs on PipeWire with WirePlumber. The speakers are driven through the AudioReach DSP graph over a 4-slot TDM bus. The right (bottom) speaker needed several changes in the aw88261 driver to match the AW88263S register layout of the vendor firmware:

  • Hardware mute - bit 4 of SYSCTRL2, not bit 8 of SYSCTRL.
  • Volume - bits 15:6 of SYSCTRL2. Writing the volume unshifted overwrites the boost peak current limit and causes audible coil whine.
  • Boost converter - the forced PWM mode of the mainline driver must not be set.
  • PLL start - the start sequence must not issue a software reset, and PLL lock has to be polled for up to 100 ms. Otherwise, playback starts with digital noise.
  • Standby - bit 15 of SYSCTRL clamps the output stage to ground. Without it, plugging in or removing the charger produces crackling.

Voice calls use the hostless AudioReach voice graph, which needs patches to snd-q6apm and snd-soc-sc8280xp, a DSP voice profile and the UCM2 voice profile. A GPIO-controlled switch moves audio between the loudspeaker and the earpiece, and callaudiod selects the profile during a call. The voice PCMs must be hidden from PipeWire with an udev rule (ACP_IGNORE=1 on the voice capture and playback devices), otherwise WirePlumber falls back to a dummy output.

The headset jack is detected, but its playback and recording paths are not mapped in the UCM2 profile. The second microphone is not routed yet.

Camera

The cameras are connected through the Titan 680 CAMSS ISP, two PM8008 camera PMICs and the camcc-sm8450 clock controller. Two of the four sensors stream:

Sensor Position Status Mode
OmniVision OV64B40 (64 MP) Rear main Streams 4624x3472, 30 fps, C-PHY
Sony IMX355 (8 MP) Rear ultra-wide Streams 1640x1232, 120 fps, D-PHY
Samsung S5K3P9SP04 (16 MP) Front Not enabled
GalaxyCore GC02M1 (2 MP) Rear macro Not enabled

The following changes are needed on top of mainline:

  • camcc-sm8450 - all root clock generators must use clk_rcg2_shared_ops. With the plain ops, the IFE power domains stay stuck in the off state.
  • camss - C-PHY support (lane tables for CSIPHY v2.1.3 and the CSID PHY type selection) for the main sensor, and the IOMMU stream ID mask 0x800 0x460. The upstream-style mask resets the phone at the first IFE DMA write.
  • ov64b40 - an out-of-tree sensor driver, with register tables decoded from an Android trace.
  • Device tree - the SM8475 CSID and VFE lite blocks are at different addresses than on SM8550. Using the SM8550 addresses causes an immediate reset. The DT rotation is 270 for the OV64B40 and 90 for the IMX355.
  • libcamera - the simple pipeline with the software ISP works. The OV64B40 needs a tuning file with BlackLevel 4096 (/usr/share/libcamera/ipa/simple/ov64b40.yaml), otherwise the image is gray.
  • Kernel command line - deferred_probe_timeout=30 lets the CCI bus wait for the camera clock controller, so the sensors appear without a manual bind.

plasma-camera takes photos with both working sensors. If it reports that the camera is unavailable after being reopened, a previous plasma-camera process is still streaming and has to be stopped. Video recording is done in software, because Qt Multimedia does not use the Iris V4L2 encoder. Recording with ffmpeg (h264_v4l2m2m) or OBS uses the hardware encoder.

GPS

The GNSS engine in the modem only accepts location sessions from clients that register as the Android framework (QMI LOC Register Events with client type AFW). Upstream ModemManager 1.25.95 does not do this, and enabling GPS fails with QMI protocol error (46): 'GeneralError'.

The fix needs:

  • libqmi with commit 532de37 (client identification TLVs for Register Events)
  • ModemManager with merge request 1463

With both patches, GPS works through ModemManager and GeoClue. An outdoor fix was obtained in under 15 seconds. Enable and read it with:

# mmcli -m 0 --location-enable-gps-nmea --location-enable-gps-raw
$ mmcli -m 0 --location-get

Assisted GPS (XTRA predicted orbits) does not load yet.

Known issues

  • Camera - the front and macro sensors, autofocus, the flash and hardware video recording in plasma-camera are not supported.
  • Fast charging - needs the Xiaomi authentication handshake in qcom_battmgr, which is not upstream. The full 67 W rate of the stock charger needs a proprietary authentication that is not implemented.
  • GPS - needs patched libqmi and ModemManager until the changes reach the distribution packages.
  • Hardware video encoding - needs out-of-tree kernel patches for the Iris secure buffer region.
  • Mobile data - the APN is not detected automatically.
  • Magnetometer - readings are not calibrated.

Contributors

Maintainer(s)

Users owning this device

  • Aelin (Notes: Will mainline once SM8450 is in better shape)
  • Halhadus (Notes: running pmOS and HOS3, testing mainline and helping to ILtanaka)
  • ILtanaka (Notes: Ported mainline, now polish, source released on my GitHub)
  • Pc159 (Notes: Using as daily driver)
  • Rebel1725
  • YuzuruRiverflow (Notes: Trying to mainline)

Additional screenshots

Note Testing was conducted on a single hardware revision. Devices with second-source components or different regional hardware revisions may behave differently.

See also