Xiaomi Redmi Note 8 Pro (xiaomi-begonia)

From postmarketOS Wiki
Xiaomi Redmi Note 8 Pro
Redmi Note 8 Pro running Weston
Redmi Note 8 Pro running Weston
Manufacturer Xiaomi
Name Redmi Note 8 Pro
Codename xiaomi-begonia
Released 2019
Type handset
Hardware
Chipset MediaTek Helio G90T (MT6785)
CPU Octa-core (2x2.05 GHz Cortex-A76 & 6x2.0 GHz Cortex-A55)
GPU Mali-G76 MC4
Display 1080 x 2340
Storage 64/128/256 GB
Memory 6/8 GB
Architecture aarch64
Software
Original software Android
Original version 9.0 (MIUI 11)
postmarketOS
Category testing
Pre-built images no
Mainline no
postmarketOS kernel 4.14.218
Unixbench Whet/Dhry score 5577.1
Features
Flashing
Works
USB Networking
Works
Internal storage
SD card
Battery
Broken
Screen
Works
Touchscreen
Works
Multimedia
3D Acceleration
Broken
Audio
Broken
Camera
Broken
Camera Flash
Connectivity
WiFi
Broken
Bluetooth
Broken
GPS
Broken
NFC
Modem
Calls
Broken
SMS
Broken
Mobile data
Broken
Miscellaneous
FDE
Broken
USB OTG
Works
HDMI/DP
Sensors
Accelerometer
Broken
Magnetometer
Ambient Light
Proximity
Hall Effect
Haptics
Barometer


Contributors

Maintainer(s)

Users owning this device

  • Cxt
  • KittyLe (Notes: running pmOS)
  • Michaelskyf (Notes: Daily driver - LineageOS 19.0)
  • Netman (Notes: Daily driver for now, back cover is cracked, and the screen has stains caused by contact with liquid)
  • Operachi (Notes: Android 14)
  • PiotrZPL (Notes: Sold after the Mediatek CPU ruined my mental health.)
  • Prowindows62 (Notes: cannot be used for testing)
  • Sohrabbehdani (Notes: running CrDroid)


How to enter flash mode

Unlocking the bootloader

Sign up for a Mi Account, register your device in the settings, and wait for a week. More info

Before you go any further

Please read Redmi Note 8 Pro XDA Megathread

Entering recovery

Volume Up + Power

Entering fastboot

Volume Down + Power

Installation

Via fastboot

  • pmbootstrap init
  • pmbootstrap install
  • pmbootstrap flasher flash_rootfs
  • pmbootstrap flasher flash_kernel
  • fastboot reboot

Via zip

  • pmbootstrap init
  • pmbootstrap install --android-recovery-zip
  • pmbootstrap export
  • Transfer the zip to the device
    • adb push /tmp/postmarketOS-export/pmos-xiaomi-begonia.zip /sdcard
  • Flash the zip
  • Reboot

Unbricking

If something went terribly wrong (eg. boot.img doesn't contain valid DTB) your device will hard-brick. Fortunately these days it's pretty easy to unbrick the device.

Requirements (GNU/Linux):

Steps:

  1. Run the exploit
  2. Connect the device via USB and hold Volume Up (+)
  3. When "Protection disabled" message appears, open SP Flash Tool
  4. Select partition images that you want to write and click Download
  5. After green checkmark image appears, restart your phone

Mainline kernel

To boot mainline kernel you need:

  1. Non-CFW based Android boot.img
  2. Non-CFW firmware
  3. osm0sis/mkbootimg
  4. Android kernel (For dtb)
  5. This simple script (Remember to modify it)

Remember to enable pstore console
If you don't get current logs in /proc/last_kmsg, try building the output.img without ramdisk (that will force kernel panic)
You also need to patch drivers/watchdog/mtk_wdt.c to support "mediatek,mt6785-toprgu", otherwise the phone will reboot after a while
The goal is to enable framebuffer or usb, so we can progress with mainlining

Misc

Andoid memory map

$ sudo cat /proc/iomem

0011bb80-0011bbff : /qos@0011bb80
10001000-10001fff : /scpsys@10001000
1000d000-1000dfff : pwrap
10012000-10012fff : /dvfsrc@10012000
10017000-10017fff : sys_timer_base
1020e000-1020efff : /emi@10219000
10219000-10219fff : /emi@10219000
1021a000-1021afff : /device_mpu_low@1021a000
10226000-10226fff : /emi@10219000
10228000-1022bfff : /gce_mbox@10228000
10230000-10231fff : /dramc@10230000
10234000-10234fff : /dramc@10230000
10235000-10235fff : /emi@10219000
10236000-10236fff : /dramc@10230000
10238000-10239fff : /dramc@10230000
10240000-10241fff : /dramc@10230000
10244000-10244fff : /dramc@10230000
10245000-10245fff : /emi@10219000
10246000-10246fff : /dramc@10230000
10248000-10249fff : /dramc@10230000
10400000-10427fff : sspm_base
10440000-1044ffff : cfgreg
10450000-104500ff : mbox0_base
10451000-10451007 : mbox0_ctrl
10460000-104600ff : mbox1_base
10461000-10461007 : mbox1_ctrl
10470000-104700ff : mbox2_base
10471000-10471007 : mbox2_ctrl
10480000-104800ff : mbox3_base
10481000-10481007 : mbox3_ctrl
10500000-105bffff : /scp@10500000
105c0000-105c2fff : /scp@10500000
105c4000-105c4fff : /scp@10500000
105d4000-105d9fff : /scp@10500000
10600000-1060ffff : /adsp@10600000
10610000-10617fff : /adsp@10600000
10630000-10638fff : /adsp@10600000
11000080-110000ff : /i2c0@11007000
11000100-1100017f : /i2c1@11008000
11000180-110002ff : /i2c2@11009000
11000300-1100037f : /i2c3@1100f000
11000380-110004ff : /i2c4@11011000
11000500-1100057f : /i2c5@11016000
11000580-1100067f : /i2c6@11005000
11000680-1100077f : /i2c7@1101a000
11000780-110007ff : /i2c8@1101b000
11000800-1100087f : /i2c9@11015000
11000880-110008ff : /dma-controller@11000880
11000900-1100097f : /dma-controller@11000880
11000980-110009ff : /dma-controller@11000880
11000a00-11000a7f : /dma-controller@11000880
11001000-11001fff : /auxadc@11001000
11002000-1100201f : serial
11003000-1100301f : serial
11005000-11005fff : /i2c6@11005000
11007000-11007fff : /i2c0@11007000
11008000-11008fff : /i2c1@11008000
11009000-11009fff : /i2c2@11009000
1100a000-1100afff : /spi0@1100a000
1100f000-1100ffff : /i2c3@1100f000
11010000-11010fff : /spi1@11010000
11011000-11011fff : /i2c4@11011000
11012000-11012fff : /spi2@11012000
11013000-11013fff : /spi3@11013000
11015000-11015fff : /i2c9@11015000
11016000-11016fff : /i2c5@11016000
11018000-11018fff : /spi4@11018000
11019000-11019fff : /spi5@11019000
1101a000-1101afff : /i2c7@1101a000
1101b000-1101bfff : /i2c8@1101b000
1101d000-1101dfff : /spi6@1101d000
1101e000-1101efff : /spi7@1101e000
11201000-11203fff : mac
11210000-11210fff : /mt6785-afe-pcm@11210000
11270000-112722ff : /ufshci@11270000
13040000-1304ffff : 13040000.mali
14017000-14017fff : /smi_larb0@14017000
14018000-14018fff : /smi_larb1@14018000
14019000-14019fff : /smi_common@14019000
15021000-15021fff : /smi_larb5@15021000
1502f000-1502ffff : /smi_larb4@1502f000
16000000-16000fff : /vdec_gcon@16000000
16010000-16010fff : /smi_larb2@16010000
16025000-16025fff : /vdec_gcon@16000000
17010000-17010fff : /smi_larb3@17010000
17020000-17020fff : /venc_gcon@17000000
18000000-180fffff : AXI-BUS
19180000-19180fff : /apu_dvfs@19180000
1a001000-1a001fff : /smi_larb6@1a001000
1a002000-1a002fff : /smi_larb7@1a002000
40000000-4c3fffff : System RAM
  40080000-415fffff : Kernel code
  41b70000-4281cfff : Kernel data
4c800000-4cdfffff : System RAM
4d000000-55ffffff : System RAM
56700000-6fffffff : System RAM
74240000-77feffff : System RAM
78000000-7bdbffff : System RAM
7e010000-7eebffff : System RAM
7ffc0000-8bffffff : System RAM
8d100000-8effffff : System RAM
8f300000-8f3fffff : System RAM
90000000-9f7effff : System RAM
9ff00000-bbffffff : System RAM
bc400000-bcffffff : System RAM
bd000000-bd2fffff : AXI-BUS
bd300000-bd55ffff : System RAM
bfff0000-bfffafff : System RAM
c0000000-ffdfffff : System RAM
fff00000-1bfffefff : System RAM

Partition table

$ sudo parted
(parted) list

Model: SAMSUNG KM2H7001CM-B518 (scsi)
Disk /dev/block/sdc: 64.0GB
Sector size (logical/physical): 4096B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name       Flags
 1      32.8kB  67.1MB  67.1MB               recovery   msftdata
 2      67.1MB  71.3MB  4194kB               misc       msftdata
 3      71.3MB  71.9MB  524kB                para       msftdata
 4      71.9MB  92.8MB  21.0MB               expdb      msftdata
 5      92.8MB  93.9MB  1049kB               frp        msftdata
 6      93.9MB  102MB   8389kB               vbmeta     msftdata
 7      102MB   136MB   33.6MB  ext4         nvcfg      msftdata
 8      136MB   203MB   67.1MB  ext4         nvdata     msftdata
 9      203MB   236MB   33.6MB  ext4         metadata   msftdata
10      236MB   310MB   73.9MB  ext4         persist    msftdata
11      310MB   319MB   8389kB  ext4         protect1   msftdata
12      319MB   327MB   8389kB  ext4         protect2   msftdata
13      327MB   336MB   8389kB               seccfg     msftdata
14      336MB   386MB   50.3MB               otp        msftdata
15      386MB   388MB   2097kB               sec1       msftdata
16      388MB   391MB   3146kB               proinfo    msftdata
17      391MB   392MB   524kB                efuse      msftdata
18      392MB   459MB   67.1MB               nvram      msftdata
19      459MB   616MB   157MB                md1img     msftdata
20      616MB   643MB   27.3MB               boot_para  msftdata
21      643MB   644MB   1049kB               spmfw      msftdata
22      644MB   649MB   4194kB               audio_dsp  msftdata
23      649MB   655MB   6291kB               scp1       legacy_boot, msftdata
24      655MB   661MB   6291kB               scp2       msftdata
25      661MB   662MB   1049kB               sspm_1     legacy_boot, msftdata
26      662MB   663MB   1049kB               sspm_2     msftdata
27      663MB   679MB   15.7MB               cam_vpu1   msftdata
28      679MB   695MB   15.7MB               cam_vpu2   msftdata
29      695MB   710MB   15.7MB               cam_vpu3   msftdata
30      710MB   744MB   33.6MB               gz1        legacy_boot, msftdata
31      744MB   778MB   33.6MB               gz2        msftdata
32      778MB   780MB   2097kB               lk         legacy_boot, msftdata
33      780MB   782MB   2097kB               lk2        msftdata
34      782MB   849MB   67.1MB               boot       msftdata
35      849MB   916MB   67.1MB               logo       msftdata
36      916MB   949MB   33.6MB               dtbo       msftdata
37      949MB   955MB   5243kB               tee1       legacy_boot, msftdata
38      955MB   965MB   9961kB               tee2       msftdata
39      965MB   2575MB  1611MB  ext2         vendor     msftdata
40      2575MB  6333MB  3758MB  ext4         system     msftdata
41      6333MB  6786MB  453MB   ext4         cache      msftdata
42      6786MB  6803MB  16.8MB               gsort      msftdata
43      6803MB  6820MB  16.8MB               oem_misc1  msftdata
44      6820MB  6954MB  134MB                exaid      msftdata
45      6954MB  7827MB  872MB   ext4         cust       msftdata
46      7827MB  64.0GB  56.1GB  ext4         userdata   msftdata
47      64.0GB  64.0GB  16.8MB               flashinfo  msftdata

Booting process

More info

1. BROM (Boot ROM)

Boots when power is applied to SoC. Initializes flash storage and starts preloader

2. PL (Preloader)

Initializes basic devices like usb, gpio, timers, etc. If Volume Up (+) is held, PL will hand controll back to BROM wth EDL (Emergency Download Mode).

3. LK (Little Kernel)

Displays logo and verifies some partitions (TODO: which partitions). If it fails to verify partition, it won't continue.
!IMPORTANT! LK WILL USE DTB (Device Tree Blob) FOUND IN BOOT.IMG which means that if DTB is invalid, the device will be hard-bricked

4. Linux

Additional info

See also