yashsingh1/xdaforums huggingface dataset:
[Xperia Z5 Android Development] tobias.waldvogel:
Basically the kernel module version did not match the kernel version. The kernel is still 3.10.84, but the full version string is now 3.10.84-perf-g4a67e96. You can check the kernel version with

uname -a

and the version of the modules with

strings <module>.ko | grep vermagic=

If the version is not the same then kernel refuses to load the modules.

Therefore I modified my script to extract the full version string.

You can extract the right modules from /system/lib/modules ;)
[Xperia Z5 Android Development] tobias.waldvogel:
Thanks for the feedback :)
[Xperia Z5 Android Development] wellison:
it works on z3+ Dual E6533 ???
[Xperia Z5 Android Development] Learnincurve:
Excellent! Thank you so much for the fix. The script went through perfectly now. I might wait for the nordic-combined fw to be published before I flash.
[Xperia Z5 Android Development] erveemoskovic:
Hi [MENTION=357342]tobias.waldvogel[/MENTION]. Thank you for your work! I used it to Systemless Root my Z5 Compact, but I'm unable to Flash Systemless Xposed.

It could be because a 32-bit/64-bit issue in TWRP packed with rootkernel (says [MENTION=4470081]topjohnwu[/MENTION] here: http://xdaforums.com/showpost.php?p=67166238&postcount=234)

I read in this thread you switched something to 32-bit for compatibility? Could that be the issue? Should I use an older version of rootkernel or is there another solution?

Thank you.
[Xperia Z5 Android Development] sovanyio:
Chiming in here that I was successful in doing the same with the TWRP version posted here: http://xdaforums.com/xperia-z5/development/twrp-3-0-2-cm-aosp-roms-t3373008 on my Sumire
[Xperia Z5 Android Development] tobias.waldvogel:
I will add an option to automatically integrate xposed systemless

Gesendet von meinem E6683 mit Tapatalk
[Xperia Z5 Android Development] erveemoskovic:
Will try flashing that recovery. In the other thread you mentioned something with needing to change SELinux context for Xposed to work? Care to share that? :)

That would be super easy for us all :)
[Xperia Z5 Android Development] sovanyio:
Sure, the folders have the wrong context set, to set them correctly:

root # cd /xposed
root # chcon u:object_r:system_file:s0 {bin, framework, lib, lib64}
[Xperia Z5 Android Development] erveemoskovic:
Thank you.
[Xperia Z5 Android Development] erveemoskovic:
Hmm, downloaded that img and:

C:\temp>fastboot flash recovery recovery_3.0.2.img
target reported max download size of 536870912 bytes
sending 'recovery' (15988 KB)...
OKAY [ 0.421s]
writing 'recovery'...
OKAY [ 0.109s]
finished. total time: 0.530s

Rebooted in recovery and flashed xposed-v85.2-sdk23-arm64-systemless.zip but the recovery log still says:

******************
Boot image patcher
******************
- Found Boot Image: /dev/block/mmcblk0p29
131072+0 records in
131072+0 records out
67108864 bytes (64.0MB) copied, 0.591491 seconds, 108.2MB/s
- Patching ramdisk
CANNOT LINK EXECUTABLE: "/sbin/libz.so" is 32-bit instead of 64-bit
page record for 0x7fa40a5010 was not found (block_size=64)
CANNOT LINK EXECUTABLE: "/sbin/libz.so" is 32-bit instead of 64-bit
etc...

My bootloader is locked and I read somewhere you need to fastboot flash recovery with an un locked boatloader, is that correct? It does say OKAY during flash...
[Xperia Z5 Android Development] sovanyio:
You're sure your bootloader is locked? You can't have a locked bootloader with systemless root etc (unless maybe you've already patched your kernel but then you would have to have been unlocked to do that...)

I did not flash the recovery though, I just booted to it since I wasn't sure if a fastboot flash recovery would actually update the installed one. I think on my Tablet Z the recovery image is built into the kernel so that may also be the case for the Z5?
[Xperia Z5 Android Development] erveemoskovic:
I temp rooted with iovroot to backup TA. Then unlocked to flash patched kernel. Then relocked by flashing back TA.

The recovery is probably in the patched kernel like you say. I'm currently away from my computer. When I get home I should just 'fastboot boot recovery.img' in fastboot mode?
[Xperia Z5 Android Development] sovanyio:
I'm not actually sure that you can boot from fastboot with a locked bootloader. You may need to unlock it again...

Edit: You could try flashing the new TWRP from within TWRP since you'd still have 'root' access there. You should be able to adb shell into the phone--but not sure if that'll work

Edit2: Of course TWRP is integrated into the kernel lol, that is what this script does.
[Xperia Z5 Android Development] zohaib0001:
[MENTION=357342]tobias.waldvogel[/MENTION]

SystemLess Xposed is not working on xperia z5 6.0.1 with patch kernel by this tool

But its working on androkernel v31 with his twrp recovery

Please can you also fix this for your tool
[Xperia Z5 Android Development] boolee:
It is a reason that a status of SELinux is "Enforcing".

If you run the command , it allows you to use the Xposed.

Using ADB shell,

$ adb shell

$ su

# setenforce 0

or Android Terminal Emulator App,

# setenforce 0

Once the reboot , please note that reverts back to the original "Enforcing".
[Xperia Z5 Android Development] zohaib0001:
[MENTION=357342]tobias.waldvogel[/MENTION]

Can you include SElinux mod option into your tool.

So at the time of patching the kernel we chose that we want permisive kernel or enforcing
[Xperia Z5 Android Development] tobias.waldvogel:
I am working on a proper way to include xposed system-less. Deactivating SE Linux is a __really__ bad idea. It protects you from malware atttacks.

Gesendet von meinem E6683 mit Tapatalk
[Xperia Z5 Android Development] zohaib0001:
Best of luck for that

thanks for your hard work
[Xperia Z5 Android Development] deepongi:
[MENTION=357342]tobias.waldvogel[/MENTION]

what about that situation i mentioned earlier on this thread?

about the "product id" not being e6653/sumire

check screenshot.

regards.
[Xperia Z5 Android Development] erveemoskovic:
Flashing TWRP from within this TWRP was not possible. I could only flash an image file as kernel. Not sure what I should do with adb though. I couldn't fastboot into another recovery either. I ended up going with the normal way of installing XPosed for now.

I have some doubts though... I like this kernel repack because it allows me to keep my own stock kernel. But to update the integrated TWRP, SuperSU and possibly XPosed later on you have to repack again and reflash the repacked kernel isn't it? And if I need to unlock my bootloader again for that (have not tried yet), the devices gets completely wiped again. I hope to be wrong :)

---------- Post added at 09:54 AM ---------- Previous post was at 09:34 AM ----------

Hi [MENTION=357342]tobias.waldvogel[/MENTION].

Instead of including Xposed. Is it possible to release a 32-bit and 64-bit version (of TWRP) so we can just systemless-install the lates Xposed ourself?

Also, it seems that the included TWRP cannot decrypt an encrypted device (/data). This is my first encrypted device so I have no experience with that, but I read TWRP should be able to ask for credentials and then decrypt /data.
[Xperia Z5 Android Development] Daniel_GB:
How do you do that? I use "fastboot boot recovery.img" but my phone stuck in fastboot forever
[Xperia Z5 Android Development] tobias.waldvogel:
I think it is more secure and less error-prone to repack the kernel only once with this script and to include xposed and supersu already. If afterwards other installers again repack the boot image it is pretty likely that something goes wrong. In addition you need to be very careful in order not to introduce security holes.

Xposed can't be included directly in the boot image, as it is too big. So the new concept will be to create a loop filesystem on /opt for all add-ons as supersu and xposed. I think this is much cleaner than having another file system for each of them. /opt/xbin will also be placed in the path, so you can place conviently things like busybox and other stuff.

SuperSU and Xposed will then be automatically installed if they are found in the interal storage. It will be designed in a way with only minimal extra SE Linux rules in order to keep your phones secure.

The xposed system-less installer doesn't seem to be able to detect the platform properly. A 64bit recovery is not required for the installation. Anyway I consider to prepare seperate 32bit and 64bit TWRPs again as it seems that now it is more stable and we don't have an update every day.

I will encrypt my device and look into it.

Best regards,

Tobias
[Xperia Z5 Android Development] erveemoskovic:
Agreed.

That's awesome :D !

Thank you very much. If you need any testing done (on Z5 Compact), I'll be happy to help out where possible.
[Xperia Z5 Android Development] celderic:
Not sure if it's something I've removed in my rom, but I'm unable to encrypt my internal storage, it just hangs on the encrypting screen for hours on end and gets extremely hot, even after a full wipe. I'll try with the stock unmodified system.img and the only modification I'll do is repack the kernel with supersu.
[Xperia Z5 Android Development] tobias.waldvogel:
In the meanwhile I encrypted my phone and it worked flawlessly. I'm using the latest firmware .224 with SuperSU 2.71 integrated via my script. Uninstalling SuperSU before, as suggested on several sites, was not required.

As reported TWRP cannot access the encrypted /data partition but I will make it work ;)
[Xperia Z5 Android Development] sovanyio:
Yep, you're going to need to unlock the bootloader again. You should keep it unlocked so that you can flash new kernels as new system bases are released... Unless you're paranoid that someone else will reboot your phone into TWRP and tamper with it.

---------- Post added at 10:04 AM ---------- Previous post was at 09:57 AM ----------

That's how you do it.. any errors? I constantly have problems with Windows recognizing but not OS X or Linux, might be a driver issue.
[Xperia Z5 Android Development] LolaPalocz:
Thank you Tobias for your work ! Very clean and understandable script. I learnt a lot of things while reading it, and browsing thru the extracted ramdisk.

(Thank you also for the silent ipacm policy fix - it was adding noise to logcat for weeks !)

Just wanted to report something about SuperSU integration.

For weeks, i'd been installing SuperSu in a 2nd step, with it's own install zip. Some days ago, I tried your integrated SuperSu (2.74) installation. Seems to work fine for most things, but I got a few problems :

I use PowerToggle, and some of its functionnality (airplane mode toggle, gps toggle) fail. SuperSU prompts, gives access, but the commands fail. From SuperSU Pro logs :

Command issued by PowerToggle :

settings put secure location_providers_allowed +gps

Error logged and returned by SuperSU :

Error while accessing settings provided

java.lang.NullPointerException: Attempt to invoke interface method 'android.app.IActivityManager$ContentProviderHolder android.app.IactivityManager.getContentProviderExternal(java.lang.string, int, android.os.IBinder)' on a null object reference

Command issued by PowerToggle :

settings put global airplane_mode_on 1 ; am broadcast -a android.intent.action.AIRPLANE_MODE -- ez state true

Error logged and returned by SuperSU :

(same as previous one) + android.util.AndroidException: Can't connect to activity manager: is the system running ?

I then reflashed a repacked kernel without SuperSu, installed SuperSU 2.74 in a 2nd step, and these 2 power toggles features worked fine. Don't know enough to help more.

An other question, not related to the general use of your tool - but as you must have dig into selinux policy stuff, may be you have an idea, otherwise i'll dig into that.

Any idea what I could add (add_file_context, make_permissive, add_policy...) if I would like to allow an 'untrusted_app' (GSAM Battery Monitor) to read '/sys/kernel/debug/wakeup_sources' (it needs to read it to display kernel wakelocks - which it can after 'setenforce 0') ?

Thanks.
[Xperia Z5 Android Development] shoey63:
Setenforce 0 will never happen with this tool. The author is even more security concious than Chainfire ;)
[Xperia Z5 Android Development] tobias.waldvogel:
I will have a look into this.

The best way to debug this is running the command and afterwards look for the audit entry in "dmesg". It looks something like "avc denied". There you will find the source and target context, as well as the class and permission. With this information you can add a proper SE Linux rule to your policy ;)
[Xperia Z5 Android Development] tobias.waldvogel:
You are absolutely right :laugh:
[Xperia Z5 Android Development] erveemoskovic:
Someone can boot into TWRP now too :)

If I'm correct, on Sony phones we lose some functionality (DRM, X-Reality, some camera enhancements, etc) when you unlock the bootloader because it wipes (part of) the TA partition.

I backed up the TA (with the iovy temp-root exploit), unlocked the bootloader, flashed the modified kernel and then flashed back the TA with flash_dk. (I also might have flashed the TA back with flashtool...)

If I'm correct, that locked the bootloader again?

But I also half-read somewhere that I restored the TA to an alternate location and the modified, repacked kernel searches for it in the alternate location. Does that mean I can unlock the bootloader AND keep DRM, X-Reality, etc.?
[Xperia Z5 Android Development] sovanyio:
Yes if you follow the instructions in this thread then you can unlock and keep your DRM functions (with your relocated TA backup). flash_dk will not relock your bootloader.

---------- Post added at 04:39 PM ---------- Previous post was at 04:33 PM ----------

Glad to hear it, people are nuts that think disabling SELinux is a solution to a problem..
[Xperia Z5 Android Development] erveemoskovic:
Okay, when your next version comes out I'll reset my device to stock, wipe, unlock, etc. and try again.

Disabling security is never the solution! Keep up the good (secure) work! :good:
[Xperia Z5 Android Development] raphoun:
Hello,

I'm trying to install your patch on E5823_32.0.A.6.200_1299-8716_R2B.ftf

I have patched the boot.img successfully

C:\Users\fff\Desktop\Sony Z5 C\root>rootkernel.cmd kernel.elf boot.img
- Unpacking kernel
Found elf boot image
Kernel version: 3.10.49-perf-g75e6207
- Detected vendor: somc (Sony), device: suzuran (Z5C), variant: row
- Unpacking initramfs
- Detected platform: 64-bit
- Disabling dm-verity
- Sony RIC is enabled. Disable? [Y/n] N
- Skipping TWRP recovery. [B]No kernel modules for 3.10.49-perf-g75e6207 available[/B] Could you include the kernel module for this kernel? Maybe it's related?
Skipping SuperSU integration. Only supported for Android 6
- Install DRM fix? [Y/n] Y
Configuring keyprovd
Configuring tpm-service
Configuring credmgrd
Configuring secd
Configuring wvkbd
Configuring drmserver
- Creating new initramfs
- Creating boot image
- Cleaning up
Done

And send it to the phone

C:\Users\ffff\Desktop\Sony Z5 C\root>fastboot flash boot boot.img
sending 'boot' (28488 KB)...
OKAY [ 0.638s]
writing 'boot'...
OKAY [ 0.267s]
finished. total time: 0.908s

And then flashing DK.ftf in flashtool and when booting the phone I have this in the service menu:

And the phone is very unstable, I can't install applications (the download freeze around 90%)

On a another Z5 C phone I have used successfully your patch on Android 6.0 but I can't manage to make it work on Android 5.1, could you help me please? :(
[Xperia Z5 Android Development] knop3x:
Dear Tobias,

thanks a lot for your tool, and for the great support you provide in this thread.

I tried to patch my kernel.elf (I used the most recent firmware 32.2.A.0.224, the Australian generic for Z5C).

However, when I try to run the script this happens:

$ ./rootkernel.sh kernel.elf kernel-patched.elf
-n -e - Unpacking kernel

./rootkernel.sh: line 196: ./bootimg: cannot execute binary file
./rootkernel.sh: line 204: ./bootimg: cannot execute binary file
-n -e Unknown boot image format

-n -e Aborting

What am I doing wrong? I am on a Mac here, is that the problem?

Thx a lot for your help. Any tip is appreciated!
[Xperia Z5 Android Development] tobias.waldvogel:
Unfortunately there is still no Mac support (This is why the zip is called Windows / Linux ;) . My script uses several tools, which I combined in a multi-call binary bootimg. So far I provide binaries for Windows, Linux x86 and Android arm. You would need to compile it for Mac to make it run on Mac.

Probably the easiest way for now is to run the script in a virtual machine in Windows or Linux.
[Xperia Z5 Android Development] tobias.waldvogel:
It seems that it is incompatible with this kernel and it would be a lot of work to analyze why. You might understand that my priority for now is the system-less SuperSU and xposed and not backporting. I'm sorry for any inconvenience.
[Xperia Z5 Android Development] raphoun:
Thanks for your answer, don't worry I understand :) Could you tell me a 5.1 rom which is compatible?

I tried differents 32.0.A.6.200 version and none was working with your patch
[Xperia Z5 Android Development] knop3x:
Dear Tobias,

many thanks. That's what I feared. Anyway, today I tried in a virtual machine and I get this:

kernel.elf: kernel.elf: cannot execute binary file

I tried chmod a+x, and that doesn't help either. Maybe my kernel.elf is somehow wrong?

I also tried flash_dk:

./flash_dk.sh: 5: [: /bin/ls: unexpected operator
-e - Extracting device key
-e - Creating FTF file for device E5823
-e - Cleaning up
-e Done

Do I have to worry about the "unexpected operator"?

Thanks for your help. I really would like to find out what I do wrong.
[Xperia Z5 Android Development] knop3x:
Hey Tobias,

I tried again on a Windows PC of a friend - there the script completes just fine. So please ignore my last post.

Nevertheless, I now face another problem: When I open the SU app it tells me: "There is no SU binary installed and SuperSu cannot install it. This is a problem! ..."

I used SU 2.65 with your script (v 4.51) and it completed without any errors. I don't know what to do now... Maybe anyone has a suggestion? Should I use different versions?

Thanks a lot for your help!
[Xperia Z5 Android Development] KbaB.BroS:
I also noticed that SuperSU 2.65 is not working with the script, but 2.74 does, give that a shot.
[Xperia Z5 Android Development] knop3x:
Ok, thnak you. I just reread the OP and should have done so before asking:

So, that means 2.71 upwards. I just wanted to install the last "stable" SU and thought that was the safe choice. I thought wrong. :-/

Nevertheless, another question: Since I don't have a usable Windows or Linux at hand, can I just flash a newer SU.zip via TWRP? Or do I have to go through the full script procedure?

(I've tried to answer these questions by reading the OP, but there it only says "Please be aware that you can not update SuperSU within the application. For a newer SuperSU version you need to rerun the script." But if I install SuperSU through TWRP - that does not mean within the app, right?)

Also, can someone explain what this means: "There was a report that having SuperSU in the system partition installed may lead to a bootloop. Therfore you shoud first install the bootimage created by this script and then install SuperSU afterwards, as it will then use the system-less strategy."

Thanks so much once again!
[Xperia Z5 Android Development] Klaus N.:
That does mean, you've to run the spript again after placing the new SuperSU.zip into the rootkernel folder. After that, at first deinstall the old SuperSU from yiur device, boot into fastboot and flash the new boot.img via fastboot.
[Xperia Z5 Android Development] knop3x:
Thanks so much. Can you tell me if (and how) it is possible to simply remove SuperSU (e.g. by running the script again without the SU.zip in the rootkernel folder, then flash the new kernel) and after that install SU manually through TWRP? This way, my SuperSU installation is independent from the script, right?
[Xperia Z5 Android Development] Klaus N.:
I haven't tried it this way, and I don't know if that works. I suggest to do it as in the startpost described.

Otherwise, make a backup before you try.
[Xperia Z5 Android Development] erveemoskovic:
Hi Tobias. A couple of new versions of systemless Xposed came out in the last week, I assume you noticed ;)

Also a new Firmware for my device and region came available, so I'm preparing to erase my device and start fresh.

Is there by any chance a new version of you script available in the near future which has systemless Xposed or 64-bit TWRP?

I don't want to rush you of course. Just want to know if I can wait or go for another normal Xposed install :D
[Xperia Z5 Android Development] erveemoskovic:
Oops. Ignore double post.
[Xperia Z5 Android Development] tobias.waldvogel:
I almost completed my new solution for system-less add-ons. I think I will be able to release it beginning of next week.

It just takes the official SuperSU and xposed zip and places them into the new /opt filesystem. Probably I will start a new thread to give some more details and to discuss this.

Afterwards I'm going to continue to work on TWRP in order to support encrypted devices. Unfortunately that seems to be quite some work, as the access to TEE needs to be implemented in order to access the device encryption key. Anyway you will be able to install / update SuperSU and xposed directly in Android, without the need of a recovery, so you won't have to wait for this. ;)
[Xperia Z5 Android Development] erveemoskovic:
Cool! I'm holding my update plans for a while then!

Thank you for the update on matters and I hope all goes well for you.
[Xperia Z5 Android Development] doinkydoink:
hi all and I am stuck at the stage trying to create the kernel boot image.

I have manage to unlock bootlock but got the below error message using method 2

1|shell@E6653:/ $ find /dev -name boot

find: No /dev: Permission denied

1|shell@E6653:/ $

I cannot proceed with the next step - dd if=<output of the find command before> of=/sdcard/kernel.img

Any tips is very much appreciated

Will
[Xperia Z5 Android Development] nabeelahmad909:
Command file dont work. Close as launched.
[Xperia Z5 Android Development] tobias.waldvogel:
Hi Will,

this only works if you have root or from TWRP. If you have none of both then try method 2 (from ftf)

Gesendet von meinem E6683 mit Tapatalk
[Xperia Z5 Android Development] doinkydoink:
Thanks Tobias. I was on E6653_32.0.A.6.200_NCB.ftf when I backup my TA.img before i I use Sony Companion to repair and go back to 6.0. I do not have the ftf for 6.0.

Should I then flash back E6653_32.0.A.6.200_NCB.ftf and use it to get the kernel.elf?

I assume will can then flash back a MM firmware with preroot after I manage to install TWRP .

Thanks again in advance.

Will

*update

I went ahead to download the latest MM from Xperifirm and created a ftf with the .TA files. Flash my phone with it and also use the same file to create kernel.elf

Finally managed to root and lock back my Z5!
[Xperia Z5 Android Development] digitalSeb:
I used this to root my Z5 Android 6. Now Sony released 6.0.1 but OTA didnt work. How to I upgrade. Flash it? Will i loose my date when i flash it?
[Xperia Z5 Android Development] tobias.waldvogel:
You can safely create a ftf via xperiferm and flash it without loosing any data.