[KERNEL][MOD] Sony Stock Patcher for Xperia X Performance

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 or Marshmallow
  • Needs a working TWRP flashed into the FOTA partition (fastboot flash recovery...)
    > Fully working TWRP builds : https://mega.nz/#F!DtsERIzb!OFINTFpTQ6CF85alkcIpgA
  • Boot to TWRP (Power and Volume -)
  • Flash the relevant sony_stock_xperformance_patcher: n for 7.x or m for 6.0
  • (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)


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_dora (branch device_sony_dora)


Sony Stock Patcher for Xperia X Performance 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 X Performance, Kernel for the Sony Xperia X Performance

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

Kernel Special Features:

Version Information
Status: No Longer Updated

Created 2016-12-29
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 X Performance - 23/10/2019
=================================================
* Update release to resolve 3.18 ramoops (o_v7.2.157)
> See commit 71d1aa14bdae1f38a56be10468556d43f108478a

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

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

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

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

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

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

Sony Stock Patcher for X Performance - 26/11/2017
=================================================
* Upgrade to Nougat 7.1.1 41.2.A.7.76 (n_v12.7.76)

Sony Stock Patcher for X Performance - 25/09/2017
=================================================
* Upgrade to Nougat 7.1.1 41.2.A.7.65 (n_v11.7.65)

Sony Stock Patcher for X Performance - 19/08/2017
=================================================
* Upgrade to Nougat 7.1.1 41.2.A.7.53 (n_v10.7.53)

Sony Stock Patcher for X Performance - 16/07/2017
=================================================
* Upgrade to Nougat 7.1.1 41.2.A.7.35 (n_v9.7.35)

Sony Stock Patcher for X Performance - 08/06/2017
=================================================
* Upgrade to Nougat 7.1.1 41.2.A.7.8 (n_v8.7.8)

Sony Stock Patcher for X Performance - 21/05/2017
=================================================
* Upgrade to Nougat 7.1.1 41.2.A.2.223 (n_v7.223)

Sony Stock Patcher for X Performance - 26/04/2017
=================================================
* Upgrade to Nougat 7.1.1 41.2.A.2.199 (n_v6.199)

Sony Stock Patcher for X Performance - 16/03/2017
=================================================
* Upgrade to Nougat 7.0 39.2.A.0.442 (n_v5.442)

Sony Stock Patcher for X Performance - 04/02/2017
=================================================
* Upgrade to Nougat 7.0 39.2.A.0.417 (n_v4.417)

Sony Stock Patcher for X Performance - 13/01/2017
=================================================
* Minor fix for enforcing SELinux (n_v3.361, m_v3.297)

Sony Stock Patcher for X Performance - 08/01/2017
=================================================
* Remove permissive for Stock 7.0 (n_v2.361, 39.2.A.0.361)
* Remove permissive for Stock 6.0, to fix WiFi (m_v2.297, 35.0.A.1.297)

Sony Stock Patcher for X Performance - 29/12/2016
=================================================
* Initial release for Stock 7.0 (n_v1, 39.2.A.0.361)
* Initial release for Stock 6.0 (m_v1, 35.0.A.1.297)
 
Last edited:

serajr

Recognized Developer / Recognized Themer
Apr 21, 2011
5,071
18,700
São Paulo - SP
@Adrian DC Congrats buddy!!
This is absolutely amazing. Confirmed that it is working on my XP with stock MM firmware (35.0.A.1.297).

I need to say that I was afraid of losing all my data due "encryptable" flag, but they were preserved.
Recovery working flawlessly on both ways to enter on it (combo-keys with device turned off, or normal boot with volume + key press).

But I have a question regarding whole process, is Permissive mandatory (# Inject the permissive cmdline)?
Edit.: It looks like it is, but Permissive does break device's wifi connectivity (and maybe other things)!! Is there a way to set Permissive only if we choose to boot up into recovery?

Also, I'm creating a script to do the same! Gonna try it out.
Edit 2: Done, script is working like a charm!
 
Last edited:
  • Like
Reactions: AdrianDC

AdrianDC

Recognized Developer
Dec 22, 2009
2,206
12,970
Île-de-France
adriandc.github.io
@Adrian DC Congrats buddy!!
This is absolutely amazing. Confirmed that it is working on my XP with stock MM firmware (35.0.A.1.297).

Thanks, glad it works fine for you too


But I have a question regarding whole process, is Permissive mandatory (# Inject the permissive cmdline)?
Edit.: It looks like it is, but Permissive does break device's wifi connectivity (and maybe other things)!! Is there a way to set Permissive only if we choose to boot up into recovery?

Nice catch, I had forgotten I had an issue 2 months ago on M with WiFi not working entirely,
and it's not an issue that can be found on Nougat so left it aside for the time.

It is indeed related to permissive, and with the recent changes I made for the Nougat support,
permissive is actually totally useless, therefore I made a new release for both M / N with updated kernel & no permissive changes.

Tested both situations with Stock M and Stock N, all works fine.
 
Last edited:

serajr

Recognized Developer / Recognized Themer
Apr 21, 2011
5,071
18,700
São Paulo - SP
Nice catch, I had forgotten I had an issue 2 months ago on M with WiFi not working entirely,
and it's not an issue that can be found on Nougat so left it aside for the time.

It is indeed related to permissive, and with the recent changes I made for the Nougat support,
permissive is actually totally useless, therefore I made a new release for both M / N with updated kernel & no permissive changes.

Tested both situations with Stock M and Stock N, all works fine.

Thank you so much Adrian... everyting are working now. You're the one!
Just one thing, getenforce returns Permissive (yet)! Not a problem for me at all, but is that right?

I'm still on MM due development of my xposed framework modules.
 
  • Like
Reactions: AdrianDC

AdrianDC

Recognized Developer
Dec 22, 2009
2,206
12,970
Île-de-France
adriandc.github.io
Thank you so much Adrian... everyting are working now. You're the one!
Just one thing, getenforce returns Permissive (yet)! Not a problem for me at all, but is that right?

I'm still on MM due development of my xposed framework modules.

Thanks.
You patched the v2 on top of v1 ?

I don't share full boot or ramdisk, I modify them, hence better compatibility & less invasive changes,
and the permissive part is no longer touched, hence if you patched it, the kernel cmdline just stayed as it was.

If you want to, just reflash the boot from ftf (Kernel only listed), then reflash the v2.
You can also edit the bootimage with regular tools now that it's converted away from ELF.
And I could also upload you my N & M bootimages flasher if you need, let me know.
 
  • Like
Reactions: ze7zez and serajr

serajr

Recognized Developer / Recognized Themer
Apr 21, 2011
5,071
18,700
São Paulo - SP
Thanks.
You patched the v2 on top of v1 ?

I don't share full boot or ramdisk, I modify them, hence better compatibility & less invasive changes,
and the permissive part is no longer touched, hence if you patched it, the kernel cmdline just stayed as it was.

If you want to, just reflash the boot from ftf (Kernel only listed), then reflash the v2.
You can also edit the bootimage with regular tools now that it's converted away from ELF.
And I could also upload you my N & M bootimages flasher if you need, let me know.

No, I didn't! It is somewhere at v2. Weird!!
And now I did it this way:
- Flashed modified stock kernel (tobias.waldvogel's tool: dm-verity, ric, drmfix, and busybox) - Reboot >> Enforcing
- Flashed latest SuperSU - Reboot >> Enforcing
- Flashed modified Sony Stock Patcher v2 (sony_stock_patcher.sh: removed dm-verity and ric related lines) - Reboot >> Permissive
 
Last edited:

karrouma

Senior Member
Jun 27, 2013
2,051
674
No, I didn't! It is somewhere at v2. Weird!!
And now I did it this way:
- Flashed modified stock kernel (tobias.waldvogel's tool: dm-verity, ric, drmfix, and busybox) - Reboot >> Enforcing
- Flashed latest SuperSU - Reboot >> Enforcing
- Flashed modified Sony Stock Patcher v2 (sony_stock_patcher.sh: removed dm-verity and ric related lines) - Reboot >> Permissive

Nice job.
working well with stock
V2 is working with latest kernel
Thank you
Keep updating
 
  • Like
Reactions: AdrianDC

AdrianDC

Recognized Developer
Dec 22, 2009
2,206
12,970
Île-de-France
adriandc.github.io
No, I didn't! It is somewhere at v2. Weird!!
And now I did it this way:
- Flashed modified stock kernel (tobias.waldvogel's tool: dm-verity, ric, drmfix, and busybox) - Reboot >> Enforcing
- Flashed latest SuperSU - Reboot >> Enforcing
- Flashed modified Sony Stock Patcher v2 (sony_stock_patcher.sh: removed dm-verity and ric related lines) - Reboot >> Permissive

Minor update v3, removed a remaining kernel commit that allowed to override the enforcing/permissive status,
in some situations it can cause the permissive status even if not wished, you might be fine now.
Works fine on mine (Enforcing, running 7.0 from my MicroSD & no issue so far).

v2 removed as it almost identical to v3 with this minor removal.
 
Last edited:

serajr

Recognized Developer / Recognized Themer
Apr 21, 2011
5,071
18,700
São Paulo - SP
Minor update v3, removed a remaining kernel commit that allowed to override the enforcing/permissive status,
in some situations it can cause the permissive status even if not wished, you might be fine now.
Works fine on mine (Enforcing, running 7.0 from my MicroSD & no issue so far).

v2 removed as it almost identical to v3 with this minor removal.

Thank you so much. Everything working as expected with v3! Great job as always!!
Could you please explain some points of the script?
What does "# Inject the cleared DTB" actually do?
Are there changes made into injected kernel to disable sony ric (or the ones into ramdisk only >> "# Patch the Sony RIC")?
 
  • Like
Reactions: AdrianDC

AdrianDC

Recognized Developer
Dec 22, 2009
2,206
12,970
Île-de-France
adriandc.github.io
Could you please explain some points of the script?
What does "# Inject the cleared DTB" actually do?
Are there changes made into injected kernel to disable sony ric (or the ones into ramdisk only >> "# Patch the Sony RIC")?

During the patch, I unpack the bootimage (Original ELF 64 bits or regular Android if already patched once),
do all the necessary changes & repack to regular Android, that just puts back all parts of the bootimage.

The kernel zImage is replaced, injected, inside the bootimage from the one I provide in the zip.

You can look at the kernel sources on GitHub linked in the OP
that hold the kernel patches including the removal of Sony RIC elements.
 
  • Like
Reactions: ze7zez and serajr

R_captivate

Senior Member
Feb 16, 2012
95
6
Can anyone tell me what will be the sequence installation after TWRP to install modification and bring SU?
1st Flash SU
2nd Flash Mod
3rd Flash Androplus kernel
is that Correct?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 13
    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 or Marshmallow
    • Needs a working TWRP flashed into the FOTA partition (fastboot flash recovery...)
      > Fully working TWRP builds : https://mega.nz/#F!DtsERIzb!OFINTFpTQ6CF85alkcIpgA
    • Boot to TWRP (Power and Volume -)
    • Flash the relevant sony_stock_xperformance_patcher: n for 7.x or m for 6.0
    • (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)


    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_dora (branch device_sony_dora)


    Sony Stock Patcher for Xperia X Performance 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 X Performance, Kernel for the Sony Xperia X Performance

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

    Kernel Special Features:

    Version Information
    Status: No Longer Updated

    Created 2016-12-29
    Last Updated 2020-08-15
    6
    Reserved

    Changelog
    Code:
    Sony Stock Patcher for X Performance - 23/10/2019
    =================================================
    * Update release to resolve 3.18 ramoops (o_v7.2.157)
    > See commit 71d1aa14bdae1f38a56be10468556d43f108478a
    
    Sony Stock Patcher for X Performance - 08/09/2018
    =================================================
    * Upgrade to Oreo 8.0.0 41.3.A.2.149/157 (o_v6.2.157)
    
    Sony Stock Patcher for X Performance - 19/05/2018
    =================================================
    * Upgrade to Oreo 8.0.0 41.3.A.2.128 (o_v5.2.128)
    
    Sony Stock Patcher for X Performance - 24/03/2018
    =================================================
    * Upgrade to Oreo 8.0.0 41.3.A.2.99 (o_v4.2.99)
    
    Sony Stock Patcher for X Performance - 12/03/2018
    =================================================
    * Upgrade to Oreo 8.0.0 41.3.A.2.75 (o_v3.2.75)
    
    Sony Stock Patcher for X Performance - 25/12/2017
    =================================================
    * Upgrade to Oreo 8.0.0 41.3.A.2.24 (o_v2.2.24)
    
    Sony Stock Patcher for X Performance - 17/12/2017
    =================================================
    * Upgrade to Oreo 8.0.0 41.3.A.0.401 (o_v1.0.401)
    
    Sony Stock Patcher for X Performance - 26/11/2017
    =================================================
    * Upgrade to Nougat 7.1.1 41.2.A.7.76 (n_v12.7.76)
    
    Sony Stock Patcher for X Performance - 25/09/2017
    =================================================
    * Upgrade to Nougat 7.1.1 41.2.A.7.65 (n_v11.7.65)
    
    Sony Stock Patcher for X Performance - 19/08/2017
    =================================================
    * Upgrade to Nougat 7.1.1 41.2.A.7.53 (n_v10.7.53)
    
    Sony Stock Patcher for X Performance - 16/07/2017
    =================================================
    * Upgrade to Nougat 7.1.1 41.2.A.7.35 (n_v9.7.35)
    
    Sony Stock Patcher for X Performance - 08/06/2017
    =================================================
    * Upgrade to Nougat 7.1.1 41.2.A.7.8 (n_v8.7.8)
    
    Sony Stock Patcher for X Performance - 21/05/2017
    =================================================
    * Upgrade to Nougat 7.1.1 41.2.A.2.223 (n_v7.223)
    
    Sony Stock Patcher for X Performance - 26/04/2017
    =================================================
    * Upgrade to Nougat 7.1.1 41.2.A.2.199 (n_v6.199)
    
    Sony Stock Patcher for X Performance - 16/03/2017
    =================================================
    * Upgrade to Nougat 7.0 39.2.A.0.442 (n_v5.442)
    
    Sony Stock Patcher for X Performance - 04/02/2017
    =================================================
    * Upgrade to Nougat 7.0 39.2.A.0.417 (n_v4.417)
    
    Sony Stock Patcher for X Performance - 13/01/2017
    =================================================
    * Minor fix for enforcing SELinux (n_v3.361, m_v3.297)
    
    Sony Stock Patcher for X Performance - 08/01/2017
    =================================================
    * Remove permissive for Stock 7.0 (n_v2.361, 39.2.A.0.361)
    * Remove permissive for Stock 6.0, to fix WiFi (m_v2.297, 35.0.A.1.297)
    
    Sony Stock Patcher for X Performance - 29/12/2016
    =================================================
    * Initial release for Stock 7.0 (n_v1, 39.2.A.0.361)
    * Initial release for Stock 6.0 (m_v1, 35.0.A.1.297)
    5
    No, I didn't! It is somewhere at v2. Weird!!
    And now I did it this way:
    - Flashed modified stock kernel (tobias.waldvogel's tool: dm-verity, ric, drmfix, and busybox) - Reboot >> Enforcing
    - Flashed latest SuperSU - Reboot >> Enforcing
    - Flashed modified Sony Stock Patcher v2 (sony_stock_patcher.sh: removed dm-verity and ric related lines) - Reboot >> Permissive

    Minor update v3, removed a remaining kernel commit that allowed to override the enforcing/permissive status,
    in some situations it can cause the permissive status even if not wished, you might be fine now.
    Works fine on mine (Enforcing, running 7.0 from my MicroSD & no issue so far).

    v2 removed as it almost identical to v3 with this minor removal.
    4
    @Adrian DC Congrats buddy!!
    This is absolutely amazing. Confirmed that it is working on my XP with stock MM firmware (35.0.A.1.297).

    Thanks, glad it works fine for you too


    But I have a question regarding whole process, is Permissive mandatory (# Inject the permissive cmdline)?
    Edit.: It looks like it is, but Permissive does break device's wifi connectivity (and maybe other things)!! Is there a way to set Permissive only if we choose to boot up into recovery?

    Nice catch, I had forgotten I had an issue 2 months ago on M with WiFi not working entirely,
    and it's not an issue that can be found on Nougat so left it aside for the time.

    It is indeed related to permissive, and with the recent changes I made for the Nougat support,
    permissive is actually totally useless, therefore I made a new release for both M / N with updated kernel & no permissive changes.

    Tested both situations with Stock M and Stock N, all works fine.
    4
    New release for the new Sony 41.2.A.7.53 firmware, Android 7.1.1.