yashsingh1/xdaforums huggingface dataset:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
They way I did was

Newflasher .25 firmware (with userdata.sin to fullwipe the phone) and the vbmeta parameters (without any error)

Boot it once to install the baseband, flash TWRP.img, install installer.zip, install magisk, reboot.

The phone was naked, because wiped, and worked.

Could you reproduce that?

You can secure your stuff with "migrate" or "titanium backup"

I use both now.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] meoman:
About XZ2 702SO Version

I got the phone real cheap here , unlocked the boot loader and stuff , i wonder if TWRP or custom room can be installed in this version of the phone. Sorry , i am very new here so dump question :o
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] dhacke:
Yes you can.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] meoman:
Sorry but i think it is in the wrong thread , but if this is the case , does that mean i can install other custom room to the system , even flash a global roms to my devices. Something like Pixel Experience GSI roms ?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
The hardware price doesn't change the hardware

I'm running the pure AOSP GSI
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] meoman:
Because my stock firmware number look like this (52.0.D.5.78) , and the other day i try to follow guide installing the custom roms(Pixel Experience GSI) with the boot.img file from your latest aosp firmware. But it result in a boot loop , so may be it is just because of your boot.img is from the global version like everyone else here (stock firmware number look like this: 52.0.A.X.XX). So i just need to follow this guide, install the twrp and then backup my boot.img from my stock firmware and it is all gonna work , am i right ?

Very sorry for asking too much , i am kind of noob here. Thanks.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
My aosp is sadly outdated until the build error got fixed

You can use the stock rom and my stock twrp for now.

I am running the pure AOSP gsi until OEMv8 for AOSP should fix our Tama camera.

Btw

Of course you could try the international firmware.

And look if every hardware feature (as example NFC and VoLTE) works.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] meoman:
Thank you , i will try to flash the global firmware first , my stock firmware have too many bloatware :D
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
A GSI is like antibloat :laugh:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Vladaha:
Yes.

I I established .25 firmware ,and than:

[FASTBOOT] fastboot flash boot twrp.img

[FASTBOOT] fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img <- IMPORTANT OR THE SYSTEM WON'T BOOT!

Reboot into RECOVERY/TWRP (Power + VOL DOWN)

[TWRP] flash twrp-stock-installer.zip

Reboot into SYSTEM, Install the official Magisk App to gain root/

Only this way could establish root.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Yeah

Only with the app

It's bundled with my twrp package

But the zip installer should install a minimal app by default notify you that you should install the full app :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] levone1:
Thanks for this... Just want to make sure before going forward - first instruction in post 3 says

fastboot flash boot twrp.img

Is that correct? (not ",,, flash recovery" or ",,, fastboot boot")
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] old.splatterhand:
It's correct, afaik there is no recovery partition anymore.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] levone1:
So, everything is working well. Installed TWRP and Magisk on Xz2 Compact. Only issue I'm having is that disabling force encryption and dm verity doesn't stick, so I can't install modified system apks... Anyone else? Maybe just a known issue with the current state of stock pie, and nothing to do with this...
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Nice to hear :)

Why doesn't modified system apks work after you patched your system with magisk and ussed the vbmeta parameters?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Klaus N.:
[MENTION=6283426]levone1[/MENTION]

Try the following:

Open the Magisk Manager app, and there in the extended options uncheck both. Right after that, install Magisk again (via Magisk Manager, choose "Direct install" and reboot). Most likely this will work :fingers-crossed:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] levone1:
I'm just guessing that it's because disable dm-verity and force encrypt doesn't persist... Maybe I should try to use params again after booting and installing Magisk...

---------- Post added at 07:35 PM ---------- Previous post was at 07:34 PM ----------

Ok, I'll check it out
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
Tested on my XZ3, that doesn't work.

I've downloaded all files from MartinX3, unlocked my bootloader on the Sony website, flashed the twrp img and the vbmeta.img

After the reboot that only bootloop on Sony logo.

Tested something like 3 times, redownloaded all files again, still same result.

That simply doesn't work.

The only way to solve the problem was to use Sony Emma to flashback a stock rom.

Now i'm screwed with black camera preview...relocking the BL won't solve the problem, sad.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Did you unlock the bootloader too early?

Before PIE .126?

Does your firmware match the twrp version number?

Did you use the AOSP twrp by mistake?

You could try newflasher from XDA to flash your rom.

I use it.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
I have the 52.0.A.3.84 Stock ROM, i've unlocked my BL yesterday and used this files : 2019-02-19_20-31-35_sony_stock_twrp_xz3_52.0.A.3.202.tar.gz

I've found on https://androidfilehost.com/?fid=1395089523397937214 a more recent file : 2019-04-09_23-19-24_sony_stock_twrp_xz3_52.0.A.8.25.tar.gz should use this one?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
.84 was too early to unlock.

The camera preview will only come back with a custom ROM or if a PIE drmfix appears.

Maybe it comes back if you upgrade to the newest stock firmware, but I don't think so.

Please install the newest firmware, if you want to use the newest TWRP.

The twrp firmware number and your own firmware number must match.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
So how i'm suppose to flash a 52.0.A.8.25 ROM? i've tested Flashtool that doesn't even recognize my FTF files

that will match with your latest file right?

PS: My Xperia Companion says that i have the lateste updat with the 52.0.A.3.84 so i ignore if there is a more recent update.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Just use xperifirm and newflasher (both on XDA) together. :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
You're great!

Thanks a lot i'm doawloading it and testing your file with the 52.0.A.8.25 ROM then give you feedback :good:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
You're welcome! :)

In the end you could test a custom rom.

But I still don't recommend it, if you need the camera.

The may 2019 security level custom ROM's with OEMv8 support should bring a better camera support.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
Sadly absolutely no change, same bootloop with the 52.0.A.8.25 ROM and your 2019-04-09_23-19-24_sony_stock_twrp_xz3_52.0.A.8.25.tar.gz file

That never boot on TWRP, i need again to flash back the 52.0.A.8.25 ROM with newflasher.

Did i missed something?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Following the exact instructions is mandatory

Btw

Do you use a Chinese or America firmware?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
I did, that doesn't change anything, still bootloop.

I use this ROM : H8416_Orange MCV FR-ES-PL-SK-RO_1316-5268_52.0.A.8.25_R26B taken on xperifirm
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
And you used the installer.zip and magisk?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
Oh wait a sec...the twrp-xz3.img is not the one i need to use?

In the zip i see those files, so i extracted the twrp-xz3.img and the vbmeta to my adb folder then i followeds your tutorial command in the first page to flash those 2 files then reboot

Is that the good way to do it?

Do i need to use your fix for the camera or the other one?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
The twrp zip needs to get executed in twrp, after that execute the magisk.zip please

Like described in the instructions in the 3. Post :silly:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
I think we're not understanding each others, let me explain :

First i have flashed the 52.0.A.8.25 ROM and DL your 2019-04-09_23-19-24_sony_stock_twrp_xz3_52.0.A.8.25.tar.gz file

Then i followed this :

First time installation of STOCK TWRP & after newflasher installation: <== It's exactly what i did previously, so it's Ok

[FASTBOOT] fastboot flash boot twrp.img <== OK

[FASTBOOT] fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img <- IMPORTANT OR THE SYSTEM WON'T BOOT! <== Ok

Reboot into RECOVERY/TWRP (Power + VOL DOWN) <== THAT BOOTLOOP HERE, I CAN'T GO TO THE TWRP, the Led become green if i press Power and Vol Down, blue if press Power and Vol Up, but it never load TWRP, i'm stuck here!

I can't go any further of that bootloop.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Thank you for the nice explaining :)

Green LED and a black screen = download mode

Blue LED and a black screen = fastboot Mode

Was the usb cable connected?

In this case the bootloader may ignore the power button and do what it does if you only press VDOWN (download) or VUP (fastboot)

I hope it works now :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
Tested without the USB câble plugged => that stuck Sony logo and nothing happens. :eek:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Did you press VOLDOWN before first boot vibration and until Sony logo appears?

The Sony logo could indicate the failed normal boot into the system, which doesn't worked without the flashed .zip file :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
Tested before or after the first vibration or the sony logo appears, that doesn't change anything, that bootloop.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
[MENTION=6710662]fastbooking[/MENTION]

Can you confirm that?

You are a xz3 owner
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
I'm not sure he will answer, his last activity was on december 2018.

Do you never tested it on Xepria XZ3 phone?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Yes, he is active on telegram

You are the first one reporting me this issue :(

At least it should show the TWRP logo

Is the LED red?

Then the bootloader wants to boot into recovery.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
Yep the led is red when the USB cable is plugged then switch to green or blue if i press vol+/-

Without the usb cable that blink extremely quickly i can't see the color.

A video of the full process could help you? I can make you a one if u need.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Did you tried to turn off the phone with PVOLUP until it vibrated 3 times in a row?

Then the phone is OFF and you cold try to boot it with PVOLDOWN.

maybe you need to flash the firmware again, flash the twrp.img on the boot partition and the vbmeta parameter and try to boot it again straight into recovery without an usb cable.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
[MENTION=4912298]QualQuek[/MENTION]

You could try if you find the March firmware and try the March twrp, too.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
Yep it's the first trick i've tested to reboot the phone with Power+vol up until the 3 vibrations.

In fact when i've finished flashing i entenr fastboot reboot, that automatically shut down the phone, then press power and vol down => nothing change bootloop on Sony logo.

I've flashed the firmware something like 20 times since yesterday you know lol

I'm nearly sure that doesn't work on XZ3.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
That would be weird, the MARCH TWRP worked perfectly.

Did you try a fullwipe, too?

Does the firmware boot without TWRP?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
[MENTION=4912298]QualQuek[/MENTION]

Btw

I used the boot.img from the Ukrainian (UA) region for the XZ3 TWRP.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
Yep without TWRP that boot perfectly, if i flash the TWRP img that's done the phone bootloop.

I've flashed again the real stock ROM with Sony Emma, sadly my camera doesn't work now :crying:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
I wonder if you need the Ukrainian firmware to use my twrp because the Ukrainian is different.

Hmmm.

The Chinese firmware had this problem.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
Is it a way you make it with a European firmware?

I would be glad to help you and test it!
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Nice to hear :)

I thought the ukrainian country is part of the european continent. :silly:

Will download the Central European 1 region for the XZ3 now. :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
I was talking about European Union not the continent sorry for the mistake lol

I can't wait to test it :fingers-crossed: thank you so much!
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
No problem, I thought it shouldn't make any problems using a region somewhere on our continent :silly:

And thank you and you're welcome :D

Btw. if I have luck, one of the next releases (depends how much time I have) will support "fastboot boot twrp.img".

We made further progress on STOCK and AOSP. :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
Anyway even if that doesn't worked atm we moved forward that's the essential.

Good to know that will solve many problem.

For my trouble, how many time do u need to make another twrp with european central firmware?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
At the moment it compiles. :)

If you use telegram, I could give you the twrp.img to test directly.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] QualQuek:
I've sent you a PM for telegram :o)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] levone1:
That did it, thanks...
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
I was able to produce a working stock XZ2 "fastboot boot boot.twrp" recovery.

Now I can refactor my work and release it.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
The new magisk repack twrp tool works nice too.

Now we don't need a .zip installer anymore.

Just "fastboot boot twrp.img"

In the advanced menu is now a "install ramdisk" button.

You need to choose the previously booted twrp.img file to get its ramdisk.

Yeah, you need to copy it on your device storage.

PS:

I don't think AOSP TWRP and STOCK TWRP would be compatible, due to different dtbo partitions.

But that's just the theory until now.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] ELDadda:
Mmm my device is blocked on sony logo since a lot after twrp and magisk installation. Any suggest or i just have to wait?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Stock?

Please flash newest april firmware via newflasher (download via xperifirm) and then install the newest STOCK twrp.

Is your firmware from usa or china?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] ELDadda:
Yes stock, ok i try it i guess is eu firmware

---------- Post added at 08:11 PM ---------- Previous post was at 08:03 PM ----------

Ok i'll try

---------- Post added at 09:00 PM ---------- Previous post was at 08:11 PM ----------

M8, i don't know how much i could thank you. The device is running again. Really really thank you <3
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] ELDadda:
Well now the problem is that is not going on, i'm trying to get root again but not going... Again sony logo...
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
vbmeta parameters, twrp installer zip file, magisk 18.1 zip file ?

PS: Next stock twrp version will be easier to install and make it impossible to forget the twrp installer zip file.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] ELDadda:
I used the things in your drive, i can check if i used the wrong one, but for now i restore the system again and retry another day...
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
17.04.2019
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
22.04.2019
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
adb reboot into bootloader -> fastboot boot twrp.img is okay

software reboot into bootloader -> fastboot boot twrp.img is okay

twrp reboot into bootloader -> fastboot boot twrp.img is okay

hardware buttons reboot into bootloader -> fastboot boot twrp.img DOESN'T WORK
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Airgio:
Hi, i've a Xperia s and i want to install a custom rom. Can anyone help me in order to install the right kernel+twrp? (My phone Is with stock android 4.1.2, rooted and with bootloader unlocked)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] dhacke:
Wrong thread my friend. This is for the Xperia XZ2, XZ2p, XZ2c, and XZ3 devices; not for the xperia s.

So first step: Look in your device specific forum section here at xda:)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MDLB:
This trick should be pinned to the top thread
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
It's in the bug list of the first post and now in the instructions of the 3rd post. :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] serajr:
Martin, the new twrp and its installation procedure are amazing! Great job bro (as always)!!:good:

Btw,

fastboot reboot bootloader

command between steps 1 and 2 did the trick.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Thank you very much :)

Weird, this command did always a normal restart at my site :eek:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] serajr:
It just does the job here (fastboot ver. 28.0.1-4986621, for the records).
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
I did a mistake.

Every twrp (stock and aosp) was the xz2 stock/aosp twrp.

If you got a mount failed message, that's why.

Rebuilding and reuploading today!
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
24.04.2019
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Airgio:
Really Sorry guys, Hope the best for You, and your smartphones ?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] barret95:
hi,

I am on 51.1.A.11.51 for the XZ2C, I cannot go to android PIE as the WiFi + Mobile service does not work.

I am trying to install twrp, I have followed instructions however after "fastboot boot twrp.img" I get boot loop over and over.

I am not sure what the issue is...
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] old.splatterhand:
You need to download the correct twrp version for your firmware number.

And the Oreo twrp could not boot the twrp from "fastboot boot twrp.img" cmd.

That boot-option is as far as i remember availabe from ~ beginning of april twrp.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] barret95:
I downloaded the twrp for XZ2C from the link in the download section.

I've read the "Known bugs STOCK"

I presume the Stockkernel-xz2c-installer zip is the original boot.img?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Hey :)

Sad that you can't upgrade.

Did you report your bugs at sony?

I did it with my bluetooth problems and they fixed them.

As far as I remember, you needed to flash the vbmeta with the parameters, the twrp.img on boot partition to boot twrp, then flash the stockkernel zip and the twrp installer zip.

Maybe the twrp version for your firmware has already a single zip with both the twrp and the stock kernel.

Then flash only this.

At the end you need to flash magisk.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] mirhl:
Why don't you try to get Tama TWRP upstream?

It seems smooth enough that it could be accepted by now. And I guess like it would be easier if you got access to their build servers.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
I want it too of course :)

I just need to wait for this to get merged

https://gerrit.omnirom.org/#/c/android_device_sony_tama-common/+/33806/

And to get the -eng mode into the vendorsetup files of the omnirom files

There is a bit resistance of the omnirom maintainer :silly:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] levone1:
Brightness still dark, any hope?

Thanks for all your work...
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Thx, you're welcome :)

Did you try to set the brightness in the twrp settings?

The settings should survive a twrp restart.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] boringpie:
Does anyone know how to resolve the issue where Google Pay doesn't work? Xperifix still doesn't support Pie after 6 months, so I wonder if there is another way to do this. Thanks.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] levone1:
Yes. It was set to max by default. I slid the slider back and forth to see if any effect, but still the same after restart. Anyone else?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
did you redownload the fastboot boot twrp?

I uploaded the xz2 one first for all devices by accident.

Or are you using a xz2?

Brightness always the same?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] levone1:
What's happening when you try?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] levone1:
Sorry, forgot to mention - I have Xz2c... I think it gets dimmer if you set it dimmer, but maximum brightness is not bright, (very hard to see in daylight).

I am using the one from the zip you posted on 4/17... All functions working fine.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] FartyParty:
So when you upload a new version a simple test would be to try and boot it via adb?

Although I realized since you said there's no recovery anymore I guess you would need a kernel from a XZ2P fw?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Yes, but with fastboot :)

Aaand, erm, i don't know.

But I think so, because of the different display.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] FartyParty:
I can give you the kernel from the fw and maybe you can do your fix on it as well?

So I can try it as well on the XZP2.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
If this twrp work, I could try to repackage it with your kernel.

Buuut you should first give us the output of

"fastboot getvar all"
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] FartyParty:
(bootloader) unlocked:yes
(bootloader) off-mode-charge:0
(bootloader) charger-screen-enabled:0
(bootloader) battery-soc-ok:yes
(bootloader) battery-voltage:3957
(bootloader) version-baseband:1311-7919_51.1.A.12.48
(bootloader) version-bootloader:1310-7079_X_Boot_SDM845_LA1.0_O_60
(bootloader) variant:SDM UFS
(bootloader) partition-type:userdata:ext4
(bootloader) partition-size:userdata: 0xBFA96C000
(bootloader) partition-type:system_a:ext4
(bootloader) partition-size:system_a: 0xFC000000
(bootloader) has-slot:modem:yes
(bootloader) has-slot:system:yes
(bootloader) current-slot:a
(bootloader) has-slot:boot:yes
(bootloader) slot-retry-count:b:0
(bootloader) slot-unbootable:b:no
(bootloader) slot-successful:b:no
(bootloader) slot-retry-count:a:6
(bootloader) slot-unbootable:a:no
(bootloader) slot-successful:a:yes
(bootloader) slot-count:2
(bootloader) secure:no
(bootloader) product:H8166
(bootloader) max-download-size:536870912
(bootloader) kernel:uefi