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

Search This thread

AdrianDC

Recognized Developer
Dec 22, 2009
2,206
12,970
Île-de-France
adriandc.github.io
Code:
#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

Installation

  • 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

Contributors
AdrianDC
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
 

AdrianDC

Recognized Developer
Dec 22, 2009
2,206
12,970
Île-de-France
adriandc.github.io
Reserved

Changelog
Code:
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
1,300
693
Nuremberg
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:
 

Soheil_rf

Senior Member
Jul 7, 2009
630
1,020
Tehran
@AdrianDC
Thanks for your work
TWRP 3.10 works perfect on F8332 XZ Dual

I installed Stock Patcher on my patched kernel with PoC for load Kcal Module from here
after load kcal module got reboot and that module cant be loaded , any Help ?
 

Attachments

  • Screenshot_20170326-164850.png
    Screenshot_20170326-164850.png
    106.9 KB · Views: 1,455
Last edited:
  • Like
Reactions: AdrianDC

RomanSkyline

Senior Member
Sep 9, 2014
100
21
28
Can you make a Overcloked and Undervolted version? Thanks

Enviado desde mi F8331 mediante Tapatalk
 

Announcement

Member
Jan 23, 2014
13
4
Houston
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
1,300
693
Nuremberg
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.
 

AdrianDC

Recognized Developer
Dec 22, 2009
2,206
12,970
Île-de-France
adriandc.github.io
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.

Top Liked Posts

  • There are no posts matching your filters.
  • 30
    Code:
    #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

    Installation

    • 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

    Contributors
    AdrianDC
    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
    12
    Reserved

    Changelog
    Code:
    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
    7
    As mentioned by Klaus :good::

    New release for Sony 41.2.A.2.199 release, Android 7.1.1.
    6
    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:
    6
    please add support for oero?
    and can this patcher be used for xperia X ?

    1. I will add support for Oreo when I have time to do it.
    2. I will be able to think about adding support for Oreo only once Sony actually releases its corresponding kernel sources
    3. No it can't be used for a different device, although I know some tried to adapt my sources, projects and script.