[Nokia X5 (Nokia 5.1 Plus) Guides, News, Discussion] hikari_calyx:
Unlike the previous root guide written for Nokia 7 Plus, this guide requires to use MTK SP Flash Tool to dump stock boot.

Why I suddenly release this guide? Because I found the method to unlock the bootloader for Nokia X5 / 5.1 Plus, but the unlock guide is unsuitable to disclose here right now. Check my Twitter if you want to confirm. To apply this guide, you must have your phone bootloader unlocked. So in theory this guide will also work on Nokia 3.1, 3.1 Plus and 5.1 once stock firmware released.

Since it's a MediaTek-based device, you can easily dump the stock boot from your device by reading the partition table of scatter file.

Now let's begin.

Step 1: Check which slot is your phone currently using

You have few methods to check, but let me introduce two usually used methods. Pick one of them that you're familiar with.

1. Use USB Debugging method to check

Once you enable the USB debugging, execute following command in either terminal or command prompt. I assume you have installed Android Platform Tools.

.\adb shell getprop ro.boot.slot_suffix

Expected output would be either

[ro.boot.slot_suffix]: [_a]

Or:

[ro.boot.slot_suffix]: [_b]

2. Use Fastboot command to check

Same as above, I assume you have installed Android Platform Tools and you have enabled USB debugging.

.\adb reboot bootloader

.\fastboot getvar current-slot

Expected output would be either

current-slot: a

Or:

current-slot: b

Step 2: Dump your stock boot with MTK SP Flash Tool

I assume that you already have MTK Port driver installed properly.

Check the MT6xxx_Android_scatter.txt from the stock firmware, and find either "boot_a" or "boot_b" on the whole text.

In this case, I used Nokia X5 CN PDA-0-102A-MT6771_Android_scatter.txt, and you'll find following info:

- partition_index: SYS34
partition_name: boot_a
file_name: PDA-0-102A-00CN-boot.img
is_download: true
type: NORMAL_ROM
linear_start_addr: 0x22a00000
physical_start_addr: 0x22a00000
partition_size: 0x2000000
region: EMMC_USER
storage: HW_STORAGE_EMMC
boundary_check: true
is_reserved: false
operation_type: UPDATE
is_upgradable: true
empty_boot_needed: false
reserve: 0x00

- partition_index: SYS52
partition_name: boot_b
file_name: NONE
is_download: false
type: NORMAL_ROM
linear_start_addr: 0xf4200000
physical_start_addr: 0xf4200000
partition_size: 0x2000000
region: EMMC_USER
storage: HW_STORAGE_EMMC
boundary_check: true
is_reserved: false
operation_type: INVISIBLE
is_upgradable: true
empty_boot_needed: false
reserve: 0x00

Please write down the linear_start_addr and partition_size of your stock boot in your current active slot.

For example, if your current slot is B, then you need to use the start address and size of boot_b, which is started from 0xf4200000 and the length is 0x2000000.

You know what to use if your current slot is A, right?

Open MTK SP Flash Tool, load the Download Agent file and scatter file from the extracted stock firmware (older than your current firmware is OK).

Then switch to Readback tab.

Add a readback info, double click that, find a suitable location and save it as "PDA-XXXX-stock_boot.img" (depends on your current firmware revision, e.g. PDA-114A-stock_boot.img)

In this case, we need to dump stock boot from boot_b, now type 0xf4200000 in start address text box and 0x2000000 in length box.

After these info are typed, click OK, Readback - now connect your powered off phone with both volume keys pressed.

After readback OK popped up, close SP Flash Tool, disconnect your phone and power it on again.

Part 3: Patch this boot image

Download and install latest Magisk Manager from https://github.com/topjohnwu/Magisk/releases

Copy the stock boot to the Download directory of internal storage, then tap "Install" - "Install" - "Patch Boot Image", choose "PDA-XXXX-stock_boot.img" you just copied to the phone.

Now you need to wait 1-2 minutes for finish patched boot image.

Pull it out from your phone once finished:

.\adb pull /storage/emulated/0/Download/magisk_patched.img D:\PDA-XXXX-patched_boot.img

Part 4: Flash boot image

Unlike Qualcomm-based models, we can't perform temporarily boot.

Luckily, we have stock boot already, you should know what to do if you want to go back to stock.

Here's how:

Reboot to fastboot mode with your familiar method:

.\adb reboot bootloader

Flash patched boot with this command:

.\fastboot flash boot_(currentslot) D:\PDA-XXXX-patched_boot.img

Example:

.\fastboot flash boot_b D:\PDA-114A-patched_boot.img

Then reboot your phone:

.\fastboot reboot

Now all done. Enjoy your rooted Nokia X5 / 5.1 Plus.

Part 5: How to make OTA available with only your phone?

When a newer update released, you can follow this guide to install new updates and inherit root permission with OTA updates: https://github.com/topjohnwu/Magisk/blob/master/docs/tutorials.md