[KERNEL][MOD] Sony Stock Patcher for Xperia XZ


Recognized Developer
Dec 22, 2009
#include <std_disclaimer.h>
 * Your warranty is now void.
 * I am not responsible for bricked devices, dead SD cards,
 * thermonuclear war, or you getting fired because the alarm app failed. Please
 * do some research if you have any concerns about features included in this ROM
 * before flashing it! YOU are choosing to make these modifications, and if
 * you point the finger at me for messing up your device, I will laugh at you.

About the project
Sony Stock Patcher is a minimal and easy transition from Sony's Stock ROM
(flashed directly from an FTF for example) to a modifiable ROM that can be modded as you like.

Built out of my evolutions of libbootimg for MultiROM to support Sony ELF bootimages,
a custom modified kernel based on Sony's copyleft with a minimal set of needed custom changes,
and an automated installation process to patch completely a Stock ROM,
this will allow you to use the Stock ROMs as you wish to.

Relevant features of Sony Stock Patcher

  • Using my Sony ELF 64bits port to libbootimg, Stock boot partition is automatically converted
  • Modified copyleft Stock kernel to support alterations and remove limitations
  • Patches the ramdisk to disable automatically Sony RIC security
  • Patches the fstab automatically for verity
  • Injects my init_sony project used on Sony custom ROM projects
  • Supports making the ROM usable as secondary MultiROM

List of changes made to the kernel

  • Disable Selinux trap security (allows to boot with stock ramdisk sepolicies)
  • Disable Device-Mapper verity (needed for example to patch system partitions)
  • Disable kernel modules forced validation (avoids failures on modules signature)
  • Disable coresight (unneeeded and irrelevant, just to avoid unsupported error logs)
  • Disable Sony RIC security (needed to use a recovery and alter /system, /data, ...)
  • Inline kernel modules compilation (to avoid kernel installation fragmentation)
  • Clearpad touchscreen updates for MultiROM UI
  • Minor kernel updates


  • Needed: Device has to be with an Unlocked Bootloader
  • Use Stock ROM or flash a clean FTF ROM from Nougat
  • Needs a working TWRP flashed into the FOTA partition (fastboot flash recovery...)
    > Fully working TWRP builds : See below with downloads
  • Boot to TWRP (Power and Volume -)
  • Flash the relevant sony_stock_xz_patcher: n for 7.x
  • (Optional) Flash SuperSU by Chainfire if you want to have root access
  • Reboot to Android

Reasons to use this project ?

  • Unlocked Bootloader customizations allowed on Stock
  • Converts the bootimage to support systemless tools
  • Ability to root with tools like SuperSU
  • Retains the original Sony bootimage files
  • Minimal needed changes, no additional kernel mods

Downloads (Unlocked Bootloader only)

Personal TWRP releases

Source code
Kernel sources - https://github.com/AdrianDC/kernel-sony-copyleft (branch 41.2.A.7.xxx)
libbootimg sources - https://github.com/AdrianDC/multirom_libbootimg (branch master)
init_sony sources - https://github.com/AdrianDC/device-sony-common-init (branch master)
MultiROM sources - https://github.com/AdrianDC/multirom_core (branch master)
TWRP sources - https://github.com/AdrianDC/twrp_development_sony/commits/device_sony_kagura (branch device_sony_kagura)

Sony Stock Patcher for Xperia XZ created also thanks to :
- Sony for their original copyleft kernel sources
- Tasssadar for the original libbootimg / MultiROM sources
- The XperiaMultiROM team for our evolution of MultiROM
- Everyone involved in testing it​

XDA:DevDB Information
Sony Stock Patcher for Xperia XZ, Kernel for the Sony Xperia XZ

Source Code: https://github.com/AdrianDC/kernel-sony-copyleft

Kernel Special Features:

Version Information
Status: No Longer Updated

Created 2017-03-20
Last Updated 2020-08-15


Recognized Developer
Dec 22, 2009

Sony Stock Patcher for XZ - 23/10/2019
* Update release to resolve 3.18 ramoops (o_v7.2.157)
> See commit 71d1aa14bdae1f38a56be10468556d43f108478a

Sony Stock Patcher for XZ - 08/09/2018
* Upgrade to Oreo 8.0.0 41.3.A.2.149/157 (o_v6.2.157)

Sony Stock Patcher for XZ - 19/05/2018
* Upgrade to Oreo 8.0.0 41.3.A.2.128 (o_v5.2.128)

Sony Stock Patcher for XZ - 24/03/2018
* Upgrade to Oreo 8.0.0 41.3.A.2.99 (o_v4.2.99)

Sony Stock Patcher for XZ - 12/03/2018
* Upgrade to Oreo 8.0.0 41.3.A.2.75 (o_v3.2.75)

Sony Stock Patcher for XZ - 25/12/2017
* Upgrade to Oreo 8.0.0 41.3.A.2.24 (o_v2.2.24)

Sony Stock Patcher for XZ - 17/12/2017
* Upgrade to Oreo 8.0.0 41.3.A.0.401 (o_v1.0.401)

Sony Stock Patcher for XZ - 26/11/2017
* Upgrade to Nougat 7.1.1 41.2.A.7.76 (n_v8.7.76)

Sony Stock Patcher for XZ - 25/09/2017
* Upgrade to Nougat 7.1.1 41.2.A.7.65 (n_v7.7.65)

Sony Stock Patcher for XZ - 19/08/2017
* Upgrade to Nougat 7.1.1 41.2.A.7.53 (n_v6.7.53)

Sony Stock Patcher for XZ - 16/07/2017
* Upgrade to Nougat 7.1.1 41.2.A.7.35 (n_v5.7.35)

Sony Stock Patcher for XZ - 08/06/2017
* Upgrade to Nougat 7.1.1 41.2.A.7.8 (n_v4.7.8)

Sony Stock Patcher for XZ - 21/05/2017
* Upgrade to Nougat 7.1.1 41.2.A.2.223 (n_v3.223)

Sony Stock Patcher for XZ - 26/04/2017
* Upgrade to Nougat 7.1.1 41.2.A.2.199 (n_v2.199)

Sony Stock Patcher for XZ - 21/03/2017
* Initial release for Stock 7.0 (n_v1, 39.2.A.0.442)
* Based on my initial releases for Xperia X Performance
Last edited:

Klaus N.

Senior Member
Oct 14, 2012
I've already tested this patcher and can confirm, it works like a charm :good:

My steps:

- Flashed the current 442 ftf via FlashTool (ejected the ext sd after poweroff, ofc), checked every checkbox in the wipe sector (don't know, if that's really neccessary).
- rebooted into system to check, if it boots fine, then power off again
- installed Adrian's current TWRP 3.1.0 via fastboot command (fastboot flash recovery <name of the recovery>.img)
- boot into recovery (<power> + <vol-> together until one time vibration, then left <power>)
- flashing the provided patcher.zip via TWRP and reboot, then - after booting - choose reboot
- now wait until vibration and the purple led, then push <vol+> => now you have to be in TWRP :good:
- flash the SuperSU.zip, if you want root
- if you want also the drm fix:
Connect your device via usb and type:
# adb -d shell
# su
# dd if=/dev/block/bootdevice/by-name/boot of=/sdcard/kernel.img

Then pull the kernel.img from /sdcard/kernel.img and go on with the unofficial rootkernel 5.23 @serajr I said yes to everything but SuperSU, TWRP and busybox (but test it by your own, it's not related to this thread). Btw, if you've managed to backup your ta before unlocking your bootloader, you can also use the PoC @munjeni for that (I unfortunately can't, because I don't have such a ta backup). But no mor ot here ;)

I can confirm, it works like a charm - and it's like in mm times: you don't have to poweroff your device; just wait for the purple led and push <vol+> = enter TWRP :good::good::good:

Thank's @AdrianDC for your brilliant job :highfive:


Jan 23, 2014
It's only possible with a custom kernel. On the other hand, it's really not neccessary, because battery drain and performance are really awesome as it is :good:
I disagree, the battery life on my XZ is TERRIBLE, recharging 2-3 times a day, to be fair though my day starts at like 4a and one Fridays ends at like 10p so meh lol... any recommendations for me?

Klaus N.

Senior Member
Oct 14, 2012
There's only one little issue (only for me?) atm: When entering TWRP by pushing <vol+> while the purple led lights up, the display doesn't react. I've to turn off/on the display, then swipe to unlock the display. After doing that, it works as it should.


Recognized Developer
Dec 22, 2009
Regular TWRP 20170521: TWRP 3.1.1 release, including changes
to match 7.1.1 touchscreen init (to confirm for XZ) and Nougat decryption of course.

Regular TWRP 20170524: Re-release that avoids a touchscreen init race condition
on a specific variant of the device's touchscreen that prevented use without lock / unlock.
Last edited:
  • Like
Reactions: Klaus N.