[TWRP][E5823] TWRP for Z5 Compact [10.11.15]

Search This thread

nilezon

Senior Member
Jan 30, 2008
324
191
TWRP for Z5 Compact E5823

Credits first
Most of the ideas and some of the code are kang'd from @dl12345 and his TWRP v2.8.7.0 for Sony Z3+
The first release of this recovery was based on Zombie b1 by @Tommy-Geenexus

Known problems
  • Colors are a bit distorted - but I think it looks good (fixed)
  • Not working with encrypted phone (unconfirmed)

How to build
Not for beginners

Please contribute to my repositories by creating pull requests if you manage to fix any bugs

First, sync omnirom sources:
Code:
repo init -u git://github.com/omnirom/android.git -b android-5.1
repo sync
Waaaaaiiiiiit.

Create a local manifest:
Code:
mkdir .repo/local_manifests/
nano .repo/local_manifests/twrp.xml
Manifest contents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="sony" fetch="git://github.com/sonyxperiadev/" />
<remote name="jackfagner" fetch="git://github.com/jackfagner/" />
<project path="device/sony/kitakami" name="twrp-device-sony-kitakami" groups="device" remote="jackfagner" revision="TWRP" />
<project path="device/sony/suzuran" name="twrp-device-sony-suzuran" groups="device" remote="jackfagner" revision="TWRP" />
<project path="kernel/sony/kitakami" name="twrp-kernel-sony-kitkami" groups="device" remote="jackfagner" revision="TWRP" />
<project path="vendor/sony/system/dtbtool" name="twrp_vendor_sony_system_dtbtool" groups="device" remote="jackfagner" revision="TRWP-28.0.A.8.251" />
<project path="vendor/sony/system/mkivybootimg" name="twrp_vendor_sony_system_mkivybootimg" groups="device" remote="jackfagner" revision="TRWP-28.0.A.8.251" />
<project path="vendor/sony/system/thermanager" name="thermanager" groups="device" remote="sony" revision="master" />
<project path="vendor/sony/system/macaddrsetup" name="macaddrsetup" groups="device" remote="sony" revision="master" />
<project path="vendor/sony/system/timekeep" name="timekeep" groups="device" remote="sony" revision="master" />
</manifest>

Sync again.
Code:
repo sync

Download Sony binaries and unzip inside repo dir:
Code:
unzip SW_binaries_for_Xperia_AOSP_L_MR1_v12.zip

Setup your environment variables (ARCH and CROSS_COMPILE), then build as usual:
Code:
source build/envsetup.sh && lunch
make -j 4 recoveryimage

Binary download

Current (kernel and recovery):
TWRP for Z5C, based on kernel 32.0.A.6.152 (v2) (10.11.15)
GDrive mirror for all you MEGA haters

Old versions:
TWRP for Z5C, based on kernel 32.0.A.6.152 (v1) (07.11.15)
TWRP for Z5C, based on kernel 32.0.A.5.32 (29.10.15)
TWRP for Z5C, first release (28.10.15) - recovery only


Instructions

Boot using:
Code:
fastboot boot recovery.img

Or, better yet, flash to your phone (will replace your kernel):
Code:
fastboot flash recovery recovery.img
fastboot flash boot boot.img
When you see an amber LED, press volume buttons a few times to boot to TWRP.


Instructions to kernel developers (I'm looking at you @Tommy-Geenexus)

Like most Sony phones, the Z5/Z5C cannot boot from the recovery (FOTAKernel) partition.
This is "solved" by letting the kernel boot image chain load the recovery ramdisk.
I was looking around for a nice script to do this, but - no offence - they were all pretty bad.

So I wrote a less bad one:
https://github.com/jackfagner/twrp-sony-recovery-boot-script
 
Last edited:

Tommy-Geenexus

Senior Member
Apr 30, 2013
2,769
2,576
I live on a Stone Hill.
Nice work, boots fine, most things seem fine.
However colors are inverted, i suppose it needs some pixel format tuning there.

Else, great work!

Edit: @nilezon
Add
Code:
TW_BRIGHTNESS_PATH := /sys/class/leds/wled/brightness
TW_MAX_BRIGHTNESS := 3511
to fix brightness slider.
 
Last edited:

SdtBarbarossa

Senior Member
Dec 15, 2014
2,405
2,131
Thank you! Will do.
I just want to get a nicer build environment up. This first build required a lot of hacking.
I'm hoping to publish a manifest file for easy building, including regular Z5.

That would be good :) would like to see the source ^^

And while you are testing around with pixelformat may have a look here:

https://gerrit.omnirom.org/#/c/14475/

I know this is not a mtk device but maybe thats the pixelformat?

Sent from my mint using XDA Free mobile app
 

Mmmiku

Member
May 30, 2007
40
12
I've got to jump in with this. Thanks for your effort! This beauty works like a charm. I just made the first back up with this twrp and the outcome looks great. Overall size of back up file suprized me but otherwise it's all good and I kinda like this color layout more than the usual blue. Great job!
 

Mmmiku

Member
May 30, 2007
40
12
Ok, maybe I jumped thru the roof little too early. Is this meant to be launched with fastboot or is this integrated recovery after flashing it?? I couldn't get straight to twrp recovery without fastboot.
Anyway this is a great opening and one step closer to real thing ?
Thanks alot!
 

nilezon

Senior Member
Jan 30, 2008
324
191
Ok, maybe I jumped thru the roof little too early. Is this meant to be launched with fastboot or is this integrated recovery after flashing it?? I couldn't get straight to twrp recovery without fastboot.
Anyway this is a great opening and one step closer to real thing
Thanks alot!

I'm working on a kernel that can boot to recovery using key-combo.
 
  • Like
Reactions: cheatman

dl12345

Senior Member
Aug 1, 2014
293
815
I'm working on a kernel that can boot to recovery using key-combo.

This is tricky as you must use the sony copyleft sources...look at my github. You can deconstruct my Z3+ recovery image for the ramdisk for a dual recovery-boot solution. I'm guessing that you could probably apply my Z3+ config almost unchanged for the Z5. I used CM 12.1 to build for the Z3+....
 
  • Like
Reactions: duc2405 and nilezon

nilezon

Senior Member
Jan 30, 2008
324
191
This is tricky as you must use the sony copyleft sources...look at my github. You can deconstruct my Z3+ recovery image for the ramdisk for a dual recovery-boot solution. I'm guessing that you could probably apply my Z3+ config almost unchanged for the Z5. I used CM 12.1 to build for the Z3+....

I've done this. Unpacked your Z3+ boot img and repacked it with my TWRP ramdisk and kernel cpio, and of course my copyleft kernel.
However, something seem wrong with the boot script, since it is always booting to the ramdisk-recovery.cpio.

I'm not fully satisfied with the ramdisk.cpio/ramdisk-recovery.cpio solution. I'm going to try writing an init.sh script that allows booting from FOTA without using any cpio's at all: regular ramdisk already in /, and recovery ramdisk is fetched from FOTA and overwriting / if recovery is requested.
 

Tommy-Geenexus

Senior Member
Apr 30, 2013
2,769
2,576
I live on a Stone Hill.
New version!
Now you can flash recovery and boot it without using fastboot every time.

Edit:
New firmware (32.0.A.6.152) just released by Sony.
I will update the recovery and kernel when the source code is released.

The Sources are already up, but they're unbuildable.
I had to fix like 40 compiler issues and am now left with the linker stuff.
They must be incomplete.
 

dl12345

Senior Member
Aug 1, 2014
293
815
I've done this. Unpacked your Z3+ boot img and repacked it with my TWRP ramdisk and kernel cpio, and of course my copyleft kernel.
However, something seem wrong with the boot script, since it is always booting to the ramdisk-recovery.cpio.

I'm not fully satisfied with the ramdisk.cpio/ramdisk-recovery.cpio solution. I'm going to try writing an init.sh script that allows booting from FOTA without using any cpio's at all: regular ramdisk already in /, and recovery ramdisk is fetched from FOTA and overwriting / if recovery is requested.

I tried this. It's difficult to get a robust solution. You're better off having a clean ramdisk and unpacking the boot ramdisk from a cpio archive.

The recovery ramdisk in cpio format is just a backup in case no image exists in the FOTA kernel partition - if one does then it's used instead.
 

nilezon

Senior Member
Jan 30, 2008
324
191
I tried this. It's difficult to get a robust solution. You're better off having a clean ramdisk and unpacking the boot ramdisk from a cpio archive.

The recovery ramdisk in cpio format is just a backup in case no image exists in the FOTA kernel partition - if one does then it's used instead.

Ok. I understand your reasons, but I'm looking to create a solution that is as easy as possible for a 3rd party kernel developer to integrate. I think it works well right now:
https://github.com/jackfagner/twrp-sony-recovery-boot-script

There is of course room for improvement. I will try to improve the script with a full cleanup of the ramdisk (excluding my /bootrec folder) before extracting the recovery cpio, but that is more of an aesthetic thing.

Another thing:
Do you have any idea why the colors get distorted? Did you have that problem on the Z3+/Z4?
 

Mmmiku

Member
May 30, 2007
40
12
Looks like kernel and twrp works great after updating with latest release 32.0.A.6.152. Reminder: after updating with FlashTool install boot.img and recovery.img thru fastboot and you have the whole set (root, twrp and zombie kernel) kicking :D Thanks again with your great job!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 28
    TWRP for Z5 Compact E5823

    Credits first
    Most of the ideas and some of the code are kang'd from @dl12345 and his TWRP v2.8.7.0 for Sony Z3+
    The first release of this recovery was based on Zombie b1 by @Tommy-Geenexus

    Known problems
    • Colors are a bit distorted - but I think it looks good (fixed)
    • Not working with encrypted phone (unconfirmed)

    How to build
    Not for beginners

    Please contribute to my repositories by creating pull requests if you manage to fix any bugs

    First, sync omnirom sources:
    Code:
    repo init -u git://github.com/omnirom/android.git -b android-5.1
    repo sync
    Waaaaaiiiiiit.

    Create a local manifest:
    Code:
    mkdir .repo/local_manifests/
    nano .repo/local_manifests/twrp.xml
    Manifest contents:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <manifest>
    <remote name="sony" fetch="git://github.com/sonyxperiadev/" />
    <remote name="jackfagner" fetch="git://github.com/jackfagner/" />
    <project path="device/sony/kitakami" name="twrp-device-sony-kitakami" groups="device" remote="jackfagner" revision="TWRP" />
    <project path="device/sony/suzuran" name="twrp-device-sony-suzuran" groups="device" remote="jackfagner" revision="TWRP" />
    <project path="kernel/sony/kitakami" name="twrp-kernel-sony-kitkami" groups="device" remote="jackfagner" revision="TWRP" />
    <project path="vendor/sony/system/dtbtool" name="twrp_vendor_sony_system_dtbtool" groups="device" remote="jackfagner" revision="TRWP-28.0.A.8.251" />
    <project path="vendor/sony/system/mkivybootimg" name="twrp_vendor_sony_system_mkivybootimg" groups="device" remote="jackfagner" revision="TRWP-28.0.A.8.251" />
    <project path="vendor/sony/system/thermanager" name="thermanager" groups="device" remote="sony" revision="master" />
    <project path="vendor/sony/system/macaddrsetup" name="macaddrsetup" groups="device" remote="sony" revision="master" />
    <project path="vendor/sony/system/timekeep" name="timekeep" groups="device" remote="sony" revision="master" />
    </manifest>

    Sync again.
    Code:
    repo sync

    Download Sony binaries and unzip inside repo dir:
    Code:
    unzip SW_binaries_for_Xperia_AOSP_L_MR1_v12.zip

    Setup your environment variables (ARCH and CROSS_COMPILE), then build as usual:
    Code:
    source build/envsetup.sh && lunch
    make -j 4 recoveryimage

    Binary download

    Current (kernel and recovery):
    TWRP for Z5C, based on kernel 32.0.A.6.152 (v2) (10.11.15)
    GDrive mirror for all you MEGA haters

    Old versions:
    TWRP for Z5C, based on kernel 32.0.A.6.152 (v1) (07.11.15)
    TWRP for Z5C, based on kernel 32.0.A.5.32 (29.10.15)
    TWRP for Z5C, first release (28.10.15) - recovery only


    Instructions

    Boot using:
    Code:
    fastboot boot recovery.img

    Or, better yet, flash to your phone (will replace your kernel):
    Code:
    fastboot flash recovery recovery.img
    fastboot flash boot boot.img
    When you see an amber LED, press volume buttons a few times to boot to TWRP.


    Instructions to kernel developers (I'm looking at you @Tommy-Geenexus)

    Like most Sony phones, the Z5/Z5C cannot boot from the recovery (FOTAKernel) partition.
    This is "solved" by letting the kernel boot image chain load the recovery ramdisk.
    I was looking around for a nice script to do this, but - no offence - they were all pretty bad.

    So I wrote a less bad one:
    https://github.com/jackfagner/twrp-sony-recovery-boot-script
    8
    Hey guys
    Thanks to some advice from AndroPlus I got usb-otg to work in TWRP 3.0.2-0 for Z5C, even if your using AndroPlus kernel.
    usb-otg, pc, external usb mounts working.
    https://mega.nz/#!kxgzQAwK!04Nrn98vxChFRoyN8y0JvD9VRTf-0CrM6qx_9WldDVw
    8
    TWRP 3.0 SonyZ5C Marshmallow

    Hi Z5C users
    AndroPlus on the z5 thread has made custom kernel for z5c that is TWRP friendly. Download V20
    http://forum.xda-developers.com/xperia-z5/development/kernel-andropluskernel-v1-t3246100

    I built TWRP 3.0 for e5823 running MM.
    Briefly tested on my phone (installed AndroPlus Kernel V20, SU, BB and DRM restore, created a backup and deleted un wanted back ups.) works so far.
    Can not detect USB OTG (yet)
    This will do the job until a proper dev makes a better version.

    This is just the recovery.img. Not a kernel. Boot in to it using AndroPlus Kernel or adb after flashing to recovery partition via fastboot.

    https://mega.nz/#!choTQKaa!_MQFdFiu-9m_A2lhgWJWh-1A8rhgu86PBuIM5sBlKkw

    I didn’t want to hi-jack this thread. When nilezon has time to update I can remove the link if he wants.
    Enjoy!
    8
    Please publish the Sd card fix/code. Maybe it can be used to fix SD detection in CM13?

    Pushed it to github. your looking for android_device_sony_kitakami-common - test branch.
    Also I built TWRP 3.0.2-0 for z5c MM. USB still not working.
    Edit: got usb-otg to work. Now all mount points in TWRP, PC, external sd-card and usb-otg working with AndroPlus Kernel.
    https://mega.nz/#!s0omADJC!yWMGUFbM7BSohAwJUQctOLz6Xve_IFnd2tt5fLzp3xo
    https://mega.nz/#!kxgzQAwK!04Nrn98vxChFRoyN8y0JvD9VRTf-0CrM6qx_9WldDVw