[RECOVERY] TWRP v3.1.1-1 with full encryption support [2018-03-04] - Xperia Z4/Z3+ Android Development

Hello xda forums,
After a lot of experimentation I have been able to get TWRP working with /data decryption support (compatible with stock Sony ROM encryption) using LineageOS 14.1 sources. It is able to mount encrypted stock Sony ROM /data and install Magisk on it.
Credits / Special Thanks:
- LineageOS and @Quarx, @Olivier, @cdesai, Myself5, kali-, banmeifyouwant for android device ivy source tree (which I forked)
- @nailyk for help and ideas from effort on Sony Z3
- AndroPlus Kernel for providing ideas on things to try.
- @Captain_Throwback for help with hw crypto.
Warning:
Do not enable "Encrypt my phone" if you are running Magisk already on stock ROM! Encryption will hang because android will not be able to unmount /data to encrypt it and you will be forced to reboot and then you will be forced to wipe /data. If you plan to use Magisk, first uninstall it completely from recovery, THEN encrypt your phone, THEN install Magisk and whatever modules you want.
Developed on Sony E6533 (Z3+ Dual) but should work on both variants due to the efforts of @Quarx in unifying the device tree. Built from LineageOS 14.1 android ivy device tree.
How to install:
- Power off completely, then hold volume up key, then plug in USB to PC. If done correctly the front LED will light up BLUE.
- Make sure fastboot drivers are installed. If you have generic android drivers, you can install driver "Android bootloader interface" manually for the "S1Boot" entry in device manager on windows when phone is in fastboot mode.
- Download attachment and unzip it to get the img file.
- fastboot flash FOTAKernel recovery.img
How to enter:
- Power off completely.
- Hold volume down key, then push power also.
- Do not release volume down and power until sony logo appears.
- It will enter recovery flashed in FOTAKernel partition.
Help wanted:
- Testing all scenarios on encrypted /data such as backup / restore.
- Charging LED does not work (I don't know the changes needed to make it work in recovery).
Known issues:
- Battery charge indicator only updates once every minute but charging is working fine.
- Reboot to bootloader from within TWRP doesn't work (seems to be Sony bootloader issue, will remove in next build) (use power off, then hold vol. up + plug in usb instead).
- Reboot to recovery from within TWRP doesn't always work (sony bootloader issue, fixed by updating to sony nougat bootloader). (use power off, then hold vol. down + power until sony logo instead).
- "Hotbooting" (ie: fastboot boot recovery.img) this recovery does not work. Phone will hang on Sony logo and heat up and require hard power off using power off button inside side flap (or press Power + Vol Up + Vol Down simultaneously for 3 seconds).
Source:
Device tree: https://github.com/rwasef1830/android_device_sony_ivy/tree/cm-14.1-twrp
TWRP: https://github.com/omnirom/android_bootable_recovery/ (cherry pick https://gerrit.omnirom.org/#/c/22096/ thanks to @Captain_Throwback)

Changelog
2017-02-27:
- Initial release
2017-02-28:
- Embed minimum crypto blobs directly in recovery, now it is completely independent from /system and /firmware. Commented out /firmware from fstab to prevent accidental damage by users.
- Removed accidentally left debug messages in firmware_class.c in previous release.
2017-02-28-02:
- Moved qseecomd binary and libs outside /system to avoid becoming affected by mounting /system.
- Enable qualcomm hardware encryption engine (thanks to @nailyk and @Captain_Throwback for help).
- Use busybox instead of toolbox/toybox to avoid problems with scripts due to missing functions.
2018-03-04-01:
- Sync'd to latest ivy / kitakami sources.
- Updated to latest TWRP on android-7.1 branch.

Developer notes
- Encryption depends on binary blobs in phone "modem" partition: keymaste.* and kmota.* (shipped with firmware FTF). These blobs have now been embedded in the recovery image itself, so recovery runs completely standalone.
- Also needed are cmnlib.* files from /system/etc/firmware but they are embedded in this recovery image to allow crypto to work completely independently of /system.
- Sony firmware package can be flashed with @Androxyde flashtool.
Future ideas
- Generalize the changes needed for TWRP to make it compatible with Kitakami in general (z5 / z5 premium) and make the tree cleaner. If any devs want to help, please reply, I'm a noob myself at this
- Implement charging LED.

Updated 2017-02-28.

Now trying to get cryptfs hw encryption working!

Please!!! Help me....
I'm with boot loop in twrp, how to solve this? I have Dual version on stock ROM V278

EverCH said:
I'm with boot loop in twrp, how to solve this? I have Dual version on stock ROM V278
Click to expand...
Click to collapse
What does boot loop in twrp mean ? If you mean you are unable to reboot from TWRP to system, just go to reboot in menu and power off and then power on. It will go to system.
If you mean something else, please provide more details.

I do this, but when I try to restart the system, it goes back to the twrp, even if it turns off the phone and calls again, it starts directly in twrp, it does not start the OS, it stays in loop in recovery.

EverCH said:
I do this, but when I try to restart the system, it goes back to the twrp, even if it turns off the phone and calls again, it starts directly in twrp, it does not start the OS, it stays in loop in recovery.
Click to expand...
Click to collapse
Unplug phone. From inside TWRP go to reboot menu, and choose power off. Wait for few seconds after screen turn off, then power on using power button only.
Otherwise, try to go in fastboot mode again by doing vol. up + plug in, and then from console do fastboot reboot.

Work great on dual version:victory:

DiscMan55 said:
Unplug phone. From inside TWRP go to reboot menu, and choose power off. Wait for few seconds after screen turn off, then power on using power button only.
Otherwise, try to go in fastboot mode again by doing vol. up + plug in, and then from console do fastboot reboot.
Click to expand...
Click to collapse
I just did this however I got the same result, it never starts the OS, even turning it off for a few minutes when connecting it enters the twrp, remembering that I am with ROM 32.3.A.0.376 dual version

EverCH said:
I just did this however I got the same result, it never starts the OS, even turning it off for a few minutes when connecting it enters the twrp, remembering that I am with ROM 32.3.A.0.376 dual version
Click to expand...
Click to collapse
At this point, I don't know what can be wrong. I would try to reflash with sony flashtool all partitions (except userdata), then flash twrp again from fastboot. Maybe that will reset it.

To anyone familiar with BoardConfig.mk syntax:
I am trying to get TARGET_HW_DISK_ENCRYPTION working. There is a problem with TWRP, it expects libcryptfs_hw.so to be found in $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)/libcryptfs_hw.so but in sony tree, libcryptfs for qualcomm comes from default LineageOS qcom opensource cryptfs driver (which delegates to libQSEEComAPI.so which is pulled from blobs) in https://github.com/LineageOS/android_vendor_qcom_opensource_cryptfs_hw/
In the Android.mk in that driver https://github.com/LineageOS/android_vendor_qcom_opensource_cryptfs_hw/blob/cm-14.1/Android.mk LOCAL_MODULE_PATH_32 and LOCAL_MODULE_PATH_64 are not defined, so libcryptfs_hw.so gets built to default /lib and /lib64 location, so it is not found by TWRP (https://github.com/omnirom/android_bootable_recovery/blob/android-7.1/prebuilt/Android.mk#L172) .
Is there a way in my device BoardConfig.mk where I can make ninja understand to build libcryptfs_hw.so like normal and then have it copy it to where TWRP expects it before building TWRP ?
I'm trying to have my tree "just work" without having to fork the lineage os repo just to add 2 lines. If I add:
Code:
# in vendor/qcom/opensource/cryptfs_hw/Android.mk
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
It builds and works successfully, but I don't want this ugly hack.

DiscMan55 said:
To anyone familiar with BoardConfig.mk syntax:
I am trying to get TARGET_HW_DISK_ENCRYPTION working. There is a problem with TWRP, it expects libcryptfs_hw.so to be found in $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)/libcryptfs_hw.so but in sony tree, libcryptfs for qualcomm comes from default LineageOS qcom opensource cryptfs driver (which delegates to libQSEEComAPI.so which is pulled from blobs) in https://github.com/LineageOS/android_vendor_qcom_opensource_cryptfs_hw/
In the Android.mk in that driver https://github.com/LineageOS/android_vendor_qcom_opensource_cryptfs_hw/blob/cm-14.1/Android.mk LOCAL_MODULE_PATH_32 and LOCAL_MODULE_PATH_64 are not defined, so libcryptfs_hw.so gets built to default /lib and /lib64 location, so it is not found by TWRP (https://github.com/omnirom/android_bootable_recovery/blob/android-7.1/prebuilt/Android.mk#L172) .
Is there a way in my device BoardConfig.mk where I can make ninja understand to build libcryptfs_hw.so like normal and then have it copy it to where TWRP expects it before building TWRP ?
I'm trying to have my tree "just work" without having to fork the lineage os repo just to add 2 lines. If I add:
Code:
# in vendor/qcom/opensource/cryptfs_hw/Android.mk
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
It builds and works successfully, but I don't want this ugly hack.
Click to expand...
Click to collapse
Weird way to include it into twrp. Is it the same into 6.0 branch or does they use dependencies system?
You can try to replace with something like:
Code:
ifneq ($(strip $(TARGET_ARCH)),arm64)
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
else
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
endif
but I think a better way would be to change the include into twrp.

nailyk said:
Weird way to include it into twrp. Is it the same into 6.0 branch or does they use dependencies system?
You can try to replace with something like:
Code:
ifneq ($(strip $(TARGET_ARCH)),arm64)
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
else
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
endif
but I think a better way would be to change the include into twrp.
Click to expand...
Click to collapse
When I modify vendor/qcom/opensource/cryptfs_hw/Android.mk as I quoted, ninja picks up that it is dependency, and it compiles libcryptfs_hw first, and then copies to where TWRP wants, but I can't make it understand to "alias" or build it manually in its default location and then put it where ninja wants to be still recognized as dependency.
I don't want to hack qcom source because I want my same BoardConfig to work for LineageOS build as well as TWRP (I want to make 100% compatible encryption in LineageOS 14.1 with stock sony rom with best performance and lowest battery with hw crypto).

DiscMan55 said:
When I modify vendor/qcom/opensource/cryptfs_hw/Android.mk as I quoted, ninja picks up that it is dependency, and it compiles libcryptfs_hw first, and then copies to where TWRP wants, but I can't make it understand to "alias" or build it manually in its default location and then put it where ninja wants to be still recognized as dependency.
I don't want to hack qcom source because I want my same BoardConfig to work for LineageOS build as well as TWRP (I want to make 100% compatible encryption in LineageOS 14.1 with stock sony rom with best performance and lowest battery with hw crypto).
Click to expand...
Click to collapse
Does TARGET_RECOVERY_DEVICE_MODULES := libcryptfs_hw get the module be built at the right location?
(it should be something like LOCAL_DEPENDENCIES += TARGET_RECOVERY_DEVICE_MODULES into twrp makefiles but can't find it again. I hope they don't remove it...)
I know they get encryption working because pixel is encrypted and afaik it is qcom arm 64 too.

nailyk said:
Does TARGET_RECOVERY_DEVICE_MODULES := libcryptfs_hw get the module be built at the right location?
(it should be something like LOCAL_DEPENDENCIES += TARGET_RECOVERY_DEVICE_MODULES into twrp makefiles but can't find it again. I hope they don't remove it...)
I know they get encryption working because pixel is encrypted and afaik it is qcom arm 64 too.
Click to expand...
Click to collapse
Nope, it gets built but at the default location (which is wrong for twrp) as the normal behavior for android.mk without explicit local_module_path.
Now I am only stuck on how to just copy it to /vendor/ before TWRP builds (how to say that in BoardConfig.mk)
Here's the relevant part of my BoardConfig.mk:
Code:
TARGET_HW_DISK_ENCRYPTION := true
TARGET_CRYPTFS_HW_PATH := vendor/qcom/opensource/cryptfs_hw
TARGET_SWV8_DISK_ENCRYPTION := true
TARGET_RECOVERY_DEVICE_MODULES := libcryptfs_hw
# latest attempt, doesn't work, still complains file is missing
PRODUCT_COPY_FILES += ${TARGET_OUT_SHARED_LIBRARIES}/libcryptfs_hw.so:$(TARGET_OUT_VENDOR_SHARED_LIBRARIES)/libcryptfs_hw.so

Cherry-pick this: https://gerrit.omnirom.org/22096

DiscMan55 said:
Nope, it gets built but at the default location (which is wrong for twrp) as the normal behavior for android.mk without explicit local_module_path.
Now I am only stuck on how to just copy it to /vendor/ before TWRP builds (how to say that in BoardConfig.mk)
I tried PRODUCT_COPY_FILES but it didn't work
Click to expand...
Click to collapse
Product copy_files on Lineage is parsed only at bacon time. The only way is to create a dummy target like:
Code:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILE := out/target/product/device/xxx/yyy/zzz/libcryptfs_hw.so
LOCAL_MODULE := libcryptfs_hw64
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/lib64/
LOCAL_POST_INSTALL_CMD += \
ln -sfT libcryptfs_hw64.so $(TARGET_RECOVERY_ROOT_OUT)/lib64/libcryptfs_hw.so;
include $(BUILD_PREBUILT)
Or to put it as prebuilt into device/sony/ivy/recovery/root/lib64/ (symlink doesn't get copied, that was my problem )
Maybe you should try the twrp IRC chan, probably somebody had already solved this.
Haha Captain is here your are in good hands now

nailyk said:
Product copy_files on Lineage is parsed only at bacon time. The only way is to create a dummy target like:
Or to put it as prebuilt into device/sony/ivy/recovery/root/lib64/ (symlink doesn't get copied, that was my problem )
Maybe you should try the twrp IRC chan, probably somebody had already solved this.
Click to expand...
Click to collapse
You missed my post .

Related

LG V30 kernel build tools & other stuff [snapdragon devices kernel build procedure]

LG V30 kernel build tools & other stuff [snapdragon devices kernel build procedure]
LG V30 kernel build tools & other stuff [snapdragon devices kernel build procedure]
Hi guys,
attaching here tools to manage boot.img, extract ramdisks and other tasks as I move along getting to know this device better
split_boot - used to extract/split ramdisk from kernel
.
split_boot.zip
is a perl script included in that zip-file. So extract it and run it like e.g.
perl ./split_boot boot_v30_debloated_stock-oreo.img
other references:
https://forum.xda-developers.com/showthread.php?t=2670512 [DEV][TEMPLATE] AnyKernel2 - Easily Mod ROM Ramdisk + Pack zImage [Flashable Zip]
kudos:
CNexus https://forum.xda-developers.com/showthread.php?t=2319018
.
Default command line & arguments for (custom selinux=permissive) Stock ROM related LG kernel is:
perl ../split_boot boot_v30_debloated_stock-oreo.img
Page size: 4096 (0x00001000)
Kernel size: 17903786 (0x011130aa)
Ramdisk size: 5353096 (0x0051ae88)
Second size: 0 (0x00000000)
Board name:
Command line: 'console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=2048 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 androidboot.hardware=joan buildvariant=user androidboot.selinux=permissive'
Base address: (0x00000000)
Writing boot_v30_debloated_stock-oreo/boot_v30_debloated_stock-oreo.img-kernel ... complete.
Writing boot_v30_debloated_stock-oreo/boot_v30_debloated_stock-oreo.img-ramdisk.cpio.gz ... complete.
Unpacking ramdisk... complete.
Click to expand...
Click to collapse
so:
base 0x00000000
kernel offset 00008000 (0x00008000)
tags offset 00000100 (0x00000100)
second offset 00f00000 (0x00f00000)
ramdisk offset 01000000 (0x01000000)
the kernel still doesn't boot for me - must be the specific mkbootimg binary that is needed (ran into a similar issue on Sony, Z5 where only a very specific mkbootimg would lead to a booting kernel & the limitation of specific ramdisk makeup on Stock ROM allowing boot)
another reference post (2nd)
another reference post (3rd, in case it's needed)
Any idea if color controls can be built into kernel?
suzook said:
Any idea if color controls can be built into kernel?
Click to expand...
Click to collapse
KCAL ?
most likely yes
zacharias.maladroit said:
KCAL ?
most likely yes
Click to expand...
Click to collapse
Yes. That's good news.
Yes you could..but are you realy interesst in this?
LG but a lot of own code inside the kernel.
I complete removed a lot of it, but the downside is, batterie life is not as good as with stock kernel from lg
djsven said:
Yes you could..but are you realy interesst in this?
LG but a lot of own code inside the kernel.
I complete removed a lot of it, but the downside is, batterie life is not as good as with stock kernel from lg
Click to expand...
Click to collapse
Sure, I got the device and now I have to deal with it, it seems the best in functionality out there (microSD, headphone jack, etc.)
Why remove lots of stuff in the first place (too much or diverge too much from Stock behavior) ?
Battery in the debloated ROM + custom Kernel (from SGCMarkus or you ?) runs way better than Stock kernel right now (almost horizontal battery line in Airplane Mode, Standby drain)
and I'll carefully add modifications to improve upon that
Thanks for the warning though
Glad to see someone who knows their way around the Linux kernel doing this. I am out of work for another month or two so I decided to download the kernel source and various tools/tutorials and start learning how to create a custom kernel. I believe I've got my environment setup and will be following this closely in hopes of learning more along the way!
djsven said:
Yes you could..but are you realy interesst in this?
LG but a lot of own code inside the kernel.
I complete removed a lot of it, but the downside is, batterie life is not as good as with stock kernel from lg
Click to expand...
Click to collapse
Apologies if the immediate reply to your post came off as arrogant or standoffish - that wasn't my intention,
I'm just starting to see and realize what a big mess and if-def hell this whole source is
Sure, I am still interested in it - there are surefire ways to improve battery significantly and I'll be tackling several of those one by one - it'll take time but I'll get there.
I've had similar experience with Sony source where it was significantly less bad but some vendor changes are still weird and break with upstream & make updates hard
so I was already kind of pissed somewhat - this isn't supposed to get directed at you or others in the community.
Where it's possible I'll leave the if-defs and add the changes,
it might not be the cleanest way but sometimes it's necessary.
e.g. I realize we might actually need download mode or at least easy access to get to the bootloader since the phone doesn't appear to shut down properly even with the 8 second power + vol down combo
so we want to have a guarantee to recover the device if it's stuck in a bootloop.
[correct me if I'm wrong, that's at least my first impression to see how the device works and behaves]
Thanks
Have you tried initiating the factory reset via hardware buttons? It boots to recovery. If you have twrp that's it. At least the one time I boot looped. On stock recovery I imagine it issues commands. But twrp must not understand them
Edit. Just tried. Confirmed working
zacharias.maladroit said:
Apologies if the immediate reply to your post came off as arrogant or standoffish - that wasn't my intention,
I'm just starting to see and realize what a big mess and if-def hell this whole source is
Sure, I am still interested in it - there are surefire ways to improve battery significantly and I'll be tackling several of those one by one - it'll take time but I'll get there.
I've had similar experience with Sony source where it was significantly less bad but some vendor changes are still weird and break with upstream & make updates hard
so I was already kind of pissed somewhat - this isn't supposed to get directed at you or others in the community.
Where it's possible I'll leave the if-defs and add the changes,
it might not be the cleanest way but sometimes it's necessary.
e.g. I realize we might actually need download mode or at least easy access to get to the bootloader since the phone doesn't appear to shut down properly even with the 8 second power + vol down combo
so we want to have a guarantee to recover the device if it's stuck in a bootloop.
[correct me if I'm wrong, that's at least my first impression to see how the device works and behaves]
Thanks
Click to expand...
Click to collapse
8 sec Power + Vol-, and when it shuts off, release both, immediatly press both again (at the same time), and as soon as the LG V30 logo appears, release power and press/hold it again.
Should get you to the factory reset menu, confirm twice with "yes" (navigate via vol/power buttons), and TWRP should boot fine.
Might take a few tries to get the right timing for that ^^
TotallyAnxious said:
Have you tried initiating the factory reset via hardware buttons? It boots to recovery. If you have twrp that's it. At least the one time I boot looped. On stock recovery I imagine it issues commands. But twrp must not understand them
Edit. Just tried. Confirmed working
Click to expand...
Click to collapse
TWRP would understand them, but they are disabled, because via button dance you initiate a factory reset on stock recovery. TWRP just ignores that wipe command entirely, and just boots normally
TotallyAnxious said:
Have you tried initiating the factory reset via hardware buttons? It boots to recovery. If you have twrp that's it. At least the one time I boot looped. On stock recovery I imagine it issues commands. But twrp must not understand them
Edit. Just tried. Confirmed working
Click to expand...
Click to collapse
SGCMarkus said:
8 sec Power + Vol-, and when it shuts off, release both, immediatly press both again (at the same time), and as soon as the LG V30 logo appears, release power and press/hold it again.
Should get you to the factory reset menu, confirm twice with "yes" (navigate via vol/power buttons), and TWRP should boot fine.
Might take a few tries to get the right timing for that ^^
TWRP would understand them, but they are disabled, because via button dance you initiate a factory reset on stock recovery. TWRP just ignores that wipe command entirely, and just boots normally
Click to expand...
Click to collapse
@TotallyAnxious @SGCMarkus
thanks !
So that button combo and timed press dance seems to lead it now (re)booting to bootloader/fastboot mode where I'm able to shut it off and flash or boot something else after a failed bootup of the kernel.
This was clearly solved in a more easier & convenient way on Sony (at least Z5).
It's still weird that the kernel wouldn't boot, even with the mentioned superr kitchen and re-used ramdisk + google's 4.9 toolchain and unmodified kernel config from the lge-oreo branch.
references:
https://github.com/SGCMarkus/android_kernel_lge_msm8998/commits/lge-oreo
https://forum.xda-developers.com/ap...chen-superr-s-kitchen-v1-1-50-v2-1-6-t3597434
zacharias.maladroit said:
@TotallyAnxious @SGCMarkus
It's still weird that the kernel wouldn't boot, even with the mentioned superr kitchen and re-used ramdisk + google's 4.9 toolchain and unmodified kernel config from the lge-oreo branch.
Click to expand...
Click to collapse
Hello.
I've tried to build kernel from official H930DS sources, version v22j. And I've got the same issue. What have I tried and what tools I have used:
1. Linaro 4.5.4 toolchain
2. Google official toolchain 4.9 from Android NDK 17c package.
3. mkbootimg for unpacking/repacking boot.img
4. abootimg for unpacking/repacking boot.img
I have used joan_global_com-perf_defconfig and followed the instructions in README.txt in sources package. The config was not changed. Kernel has compiled without any errors. Than I repack boot.img from my current firmware v22j with new kernel. And tried to boot in fastboot. An have no luck. Then I just took unchanged boot.img, unpacked it and packed again, boot from fastboot. And it has booted. I did it just to ensure, that unpack utility works fine.
I have tried different sources, different toolchains, different configs with no luck. I'm not newbie in this, I compiled kernels for linux, for lenovo A850, for LG G2 and always it worked fine. Now I don't know what to do, I try to compile it and handle for a week without any success. I didn't have any logs or LLCON, or any other debug info.
Could you please tell me how did you compile your kernels and what am I doing wrong?

[RECOVERY] [UNOFFICIAL] TWRP 3.4.0 for Galaxy S10 Exynos [G970F/G973F/G975F/G977B]

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
​
Preamble
When TWRP first appeared for the S10 range of devices, it quickly became clear that there were some major issues with the initial builds.
Many users were understandably frustrated at losing the ability to boot their device after shutting it down, and at being unable to update Magisk after installing TWRP.
A number of users took to contacting me privately for support. I answered their questions and even shared fixed images in a few cases, but the number of support requests was rising daily and I could not keep pace with the demand.
Given that the poster of the original images (Geiti94) was evidently unable to offer fixed TWRP images in a timely fashion, I ultimately took the liberty of doing so myself in a posting to the original TWRP thread as a service to the community.
Whilst this served to relieve the immediate pressure, the ongoing need to fix bugs and make further enhancements to the software made a fork of the original project inevitable, so I have taken the step of promoting it to its own DevDB project and thread here on XDA.
Credit goes to Geiti94 for conducting the time-consuming initial legwork and releasing the original builds. His is the foundation on which this work now builds. This fork in no way implies any disrespect to him, but does strongly acknowledge the need of the S10 user base to be supplied with proper, working images and timely updates.
Samsung system-as-root devices
All new devices launched with Android 9 are required to be factory-configured as system-as-root devices. The ramdisk image formerly found in boot.img is now merged with system.img.
For Samsung devices such as the Galaxy S10 series, this means that boot.img can no longer be used to root the device. Instead, Magisk is installed to the recovery partition and the user must subsequently always boot from that partition, regardless of whether TWRP or Android is desired. The device's hardware keys are used at boot time to select between Magisk-rooted Android and TWRP.
This configuration dictates that TWRP and Android share a common recovery kernel. However, because TWRP cannot function with a stock kernel, a modified kernel must be compiled from Samsung's source code. Unfortunately, this kernel is sensitive to changes in Samsung's firmware releases from one month to the next, meaning that problems can arise if a given kernel is used with firmware newer than the version the kernel was intended for.
This unfortunate situation necessitates semi-regular maintenance releases of TWRP to keep the kernel in step with the latest version of the S10 series firmware. This requirement is further complicated by the fact that any given release of Samsung's modified kernel source code typically trails the associated firmware release by anything from a few days to a few weeks.
TWRP without Magisk
If your device is currently still unrooted and running stock firmware, you are strongly advised not to proceed with installing TWRP. First root your device with Magisk, using John Wu's excellent Samsung system-as-root-instructions for patching the firmware's AP file. Only when you have completed that procedure should you return here and continue from the Image Preparation section.
If you insist on proceeding with installing TWRP to a stock device without Magisk, you will need — at a minimum — to flash a vbmeta.img with verity disabled or you will render your device unable to boot. You can construct such an image using the following command:
Code:
$ avbtool make_vbmeta_image --out vbmeta.img
Alternatively, if you don't have a copy of avbtool at hand, the following piece of shell code will do the trick on the device itself:
Code:
h=$(printf '4156423%08d1%0240d617662746f6f6c20312e312e3%0230d')
d=''
i=0
while [ $i -lt ${#h} ]; do
d="$dx${h:$i:2}"
i=$((i+2))
done
printf "$d" > vbmeta.img
Next, flash this to the vbmeta partition, using either Heimdall or Odin.
Code:
# heimdall flash --VBMETA vbmeta.img
You may then proceed with installing TWRP according to the instructions below.
Image preparation
In contrast to the original Geit94 release, these and subsequent TWRP images will not be supplied pre-rooted with Magisk. Whilst it would be trivial to offer them in this format, this kind of binary distribution of Magisk is against the terms of use laid out by Magisk's developer, John Wu.
To root the TWRP image yourself, simply use Magisk Manager to Select and Patch a File. Provide your freshly downloaded TWRP image file as the input.
Installation
You are now ready to flash the resulting magisk_patched.img image file to your device's recovery partition.
One quick and easy way to do this on an already rooted device is from a root shell:
Code:
# f=/storage/emulated/0/Download/magisk_patched.img; dd if=$f of=/dev/block/sda15 bs=$(stat -c%s $f)
1+0 records in
1+0 records out
61734912 bytes transferred in 0.426 secs (144917633 bytes/sec)
If TWRP is already installed and you are merely updating it, you may, of course, use TWRP itself to flash the new version.
If the device is not yet rooted (or even if it is), you may use Odin in Windows, but you will need to rename and tar the image first. Otherwise, Odin will not understand what to do with the image.
For example:
Code:
$ mv twrp-beyond[012]lte.img recovery.img
$ tar cf twrp-beyond[012]lte.img.tar recovery.img
And if rebooting to Windows is too disruptive, there's always Heimdall:
Code:
$ sudo heimdall flash --RECOVERY twrp-beyond[012]lte.img
Download
The latest unofficial local builds currently available are:
Android 10
G970F (S10e): twrp-beyond0lte-3.4.0-4_ianmacd.img
G973F (S10): twrp-beyond1lte-3.4.0-4_ianmacd.img
G975F (S10+): twrp-beyond2lte-3.4.0-4_ianmacd.img
G977B (S10 5G): twrp-beyondx-3.3.1-100_ianmacd.img
Android 9
G970F (S10e): twrp-beyond0lte-3.3.1-13_ianmacd.img
G973F (S10): twrp-beyond1lte-3.3.1-13_ianmacd.img
G975F (S10+): twrp-beyond2lte-3.3.1-13_ianmacd.img
G977B (S10 5G): twrp-beyondx-3.3.1-7_ianmacd.img
Official builds were also offered by me until the release of Android 10 for the S10 series, but have been discontinued. They offered no practical advantage over the unofficial builds, yet added considerably to the administrative burden. Any build for Android 10 and tagged official has not been built by me.
These builds are based on the latest version of TWRP and include a kernel compiled from Samsung's latest available source code. The kernel runs in SELinux enforcing mode and its configuration has intentionally been kept as close to stock as possible in order to provide maximum compatibility with both Android and TWRP.
The builds have been well-tested and are known to work as intended on supported firmware versions. See posting #2 of this thread for details of which TWRP builds work with which versions of Samsung's firmware.
If you later find yourself running on updated firmware that is incompatible with this kernel, you have the option of flashing and rebooting to TWRP on demand. When you are finished in TWRP, you can replace your recovery image with Magisk-rooted stock recovery and reboot back to Android.
If installing TWRP on your device for the first time or reinstalling it following a firmware upgrade, do not forget to disable file-based encryption (FBE) immediately after flashing TWRP or you won't be able to read files on /data in TWRP. To achieve this (and to protect yourself against various anti-root protection mechanisms that Samsung have booby-trapped the device with), flash the latest version of the multidisabler as soon as you have installed TWRP.
Device firmware updates
When it comes time to update your device's firmware, please follow John Wu's excellent instructions for patching the firmware's AP file. Do not skip any of the steps.
Next, use Odin to flash the patched AP file, together with the stock BL, CP and HOME_CSC files. Never leave the CSC slot empty when flashing an AP file, or your /data partition may be shrunk and your data damaged during the flash.
When finished, immediately reboot back to download mode and reflash your Magisk-patched TWRP image. Alternatively, you may replace recovery.img in the patched AP file with your rooted TWRP image, thereby avoiding the need to separately reflash TWRP afterwards:
Code:
$ tar f magisk_patched_twrp.tar --delete recovery.img && tar rf magisk_patched_twrp.tar recovery.img
Lastly, boot to TWRP and reflash the latest version of the multidisabler. Note that your first boot to TWRP after installing new firmware may just run a post-installation recovery script that wipes /cache, so you may need to trap the automatic reboot that follows and boot to TWRP a second time.
Do not skip rerunning the multidisabler, as flashing new firmware will have re-enabled critical security features that you must now re-disable.
Frequently Asked Questions
Q. I've just updated my G97[035]F device to ASIG firmware and now I can no longer boot to TWRP, which means I also can't flash the multidisabler to keep encryption disabled. What can I do?
Samsung's new ASIG firmware for the S10 series has proven to be incompatible with any kernel compiled for an earlier version of the firmware. You are urged to upgrade to TWRP version 3.3.1-10_ianmacd or later to avoid problems with this firmware.
If you are unable or unwilling to do this, the following procedure should be observed:
If you simply upgrade to this new firmware as usual, by patching the AP file with Magisk Manager, you will find yourself unable to boot TWRP afterwards, and therefore also unable to flash the multidisabler. This is a potentially dangerous situation, as it can lead to data loss if not properly tackled.
1. When flashing the new full firmware in Odin, use the BL file from the previous ASH6 firmware, not the one from ASIG. Include the latest version of TWRP as recovery.img in the AP file, as per usual.
2. After flashing the firmware, reboot to TWRP as usual. Flash the multidisabler and any other files you usually flash as part of the post-upgrade process.
3. Make a copy of the ASIG BL tar file. From this copy, either remove vbmeta.img or replace it with a benign copy constructed as per the #vbmeta note in this group.
4. Use Odin to flash your modified BL file, together with a Magisk-patched copy of the stock ASIG recovery image in the AP slot.
5. Reboot to rooted Android.
If you follow these instructions, you will successfully upgrade your device to ASIG firmware, whilst retaining a decrypted /data file-system, etc.
TWRP can still be used on demand, but you will need to add the swapping of the bootloader to your existing procedure for switching between stock and custom recovery. Or you can simply wait a couple of weeks for Samsung to release updated kernel source code for ASIG, at which time I will issue new builds of TWRP.
Lastly, there are apparently some new TWRP builds currently doing the rounds that deal with the ASIG incompaibility issue by including a kernel hacked together from a mixture of S10 and Note10 source code. Approach such hybrids with due caution.​
Q. I don't want to dual-boot Android using the custom kernel from my TWRP image. The latest TWRP kernel is often compiled for older firmware. Even if there are no visible issues using this older kernel, I'm probably missing out on improvements and fixes made in the latest kernel. Is there really no other way to run TWRP on these devices?
A. Actually, there is another way and it's actually simpler than and therefore preferable to dual-booting. You can opt to simply flash and boot TWRP on demand, leaving a Magisk-rooted stock recovery on your device the rest of the time.
For example, the following simple script could be used to toggle your recovery partition between stock and TWRP images.
Copy the following (not as the superuser) into a file, for example /storage/emulated/0/switch-recovery:
Code:
#!/bin/sh
twrp_img=/storage/9C33-6BBD/twrp-3.3.1-4.img
# Path to ext. SD is different in TWRP.
stock_img=/external_sd/recovery-asf3-magisk.img
if [ -f /sbin/magisk ]; then
# We're in Android: Switch to TWRP.
#
infile=$twrp_img
su='su -c'
else
# We're in TWRP: Switch to Android.
#
infile=$stock_img
fi
$su dd if=$infile of=/dev/block/sda15 bs=$(stat -c%s $infile) && reboot recovery
Then run it in Android in a terminal session:
Code:
# sh /storage/emulated/0/switch-recovery
It will flash your TWRP image and reboot the device to recovery. If the TWRP image is rooted, you'll still need to press the usual key combo to force pass-through to TWRP.
Do your work in TWRP and then run the script again from the TWRP terminal. This time, it will reflash your stock recovery image and reboot again to recovery. There's no need to press the hardware keys this time, because you are booting to Magisk-rooted Android.
Obviously, you must change the paths in the script to match where your own images are stored.​
Q. Somewhere in upgrading my firmware, rooting and installing TWRP, my /data file-system mysteriously shrank to a fraction of its former size and appears to have been wiped. What happened? Is TWRP responsible for this?
A. No. This appears to be a side-effect of using Odin to flash an AP file to these devices with the CSC slots left empty. Never flash a full AP file on this range of devices without also filling at least the HOME_CSC slot. It is safe, however, to flash only a recovery image in the AP slot.
To attempt to repair the damage, you need to boot to TWRP, select Advanced Wipe, tick Data, select Repair or Change File System followed by Resize File System. Your /data will return to its former size, but you will probably find you have lost some data. Restore a /data back-up afterwards to be sure of having all your data.​
Q. When I mount /system and execute commands in the TWRP terminal or over adb, I get a lot of noise about problems with the dynamic linker.
A. This problem is fixed as of version 3.3.1-1_ianmacd.
It is caused by /etc/system becoming a symlink to itself when /system is mounted, resulting in infinite recursion when followed.
The screen on your text is just a warning, not an error. Your commands are still being executed.
Nevertheless, noise annoys, so you can silence the warning by pasting the following commands into the terminal (with thanks to John Wu):
Code:
# mount --move /system /system_root && mount -o bind /system_root/system /system
Q. My favourite zip doesn't flash properly using this TWRP. Someone said these TWRP builds are to blame, because they don't include BusyBox. Why don't you fix them?
A. Because there's actually nothing wrong with them. It's the installer code of your favourite zip that is broken. TWRP is merely exposing that fact. Don't shoot the messenger.
A lot of poorly written legacy installer code lazily assumes the presence of certain binaries, in particular BusyBox. However, the inclusion of BusyBox in TWRP is a compile-time option entirely at the discretion of the builder. It is not a requirement.
Not only that, but the inclusion of BusyBox in builds of TWRP targeting Android 9.0 and later is officially deprecated. Maintainers of such devices are instead advised by the TWRP team to use Toybox, and these builds for the S10 series comply with that advice. Furthermore, it's actually currently impossible to even build an official TWRP image for these devices with BusyBox included. Compilation of TWRP on the official build server will fail if this is attempted.
In short, the assuming BusyBox's presence on the device is unsafe and your favourite zip's author should fix his installer code. Supply him with an installation log and politely ask him to rewrite the installer code to be independent of this historical TWRP implementation detail.
Anyone who maintains that TWRP is broken without the inclusion of BusyBox is simply either unwilling or unable to grasp the facts.​
Q. When I boot to Android, I can no longer log in. Why?
:victory:
A. Probably because of a mechanism called rollback protection. What has most likely happened here is that you have previously booted the device from a boot image with a later security patch level than the one from which you are trying to boot now.
As an example, let's say you are currently booting your device from a TWRP image with a security patch level of 2019-06. Then, Samsung issues a firmware update with a patch level of 2019-07. You update to that firmware, but immediately replace the stock recovery image with your trusty TWRP image and keep booting from that. Everything continues to work as it did before.
However, one day, you accidentally boot the device from the boot partition instead of the recovery partition. The device predictably comes up unrooted, but more significantly, it has now been booted from a (stock) boot image with a patch level of 2019-07, a fact that the device has now also committed to memory.
If you now reboot from the recovery partition, you will find that Android will no longer allow you to log in when the lock screen appears. This is because you are attempting to boot from an image with a patch level (2019-06) that is now earlier than the latest one previously used to boot the device (2019-07). Android considers this insecure and will not allow it. This mechanism is called rollback protection.
The simplest solution and the one with the least negative impact is to update the security patch level of the TWRP image to match that of the latest image used to boot the device. You can achieve this using magiskboot unpack -h or with AIK.​
Links
TWRP source code for Android 9.0
Unofficial device tree for the G970F
Unofficial device tree for the G973F
Unofficial device tree for the G975F
Unofficial device tree for the G977B
Combined kernel source code for the G97[035]F
Kernel source code for the G977B
Telegram group
XDA:DevDB Information
TWRP for Galaxy S10 Exynos series, Tool/Utility for the Samsung Galaxy S10+
Contributors
ianmacd, Geiti94
Version Information
Status: Stable
Current Stable Version: 3.4.0-4_ianmacd
Stable Release Date: 2020-11-17
Created 2019-04-25
Last Updated 2020-11-17
Changelog
v3.4.0-4_ianmacd for G97[035]F [inc. DTJA kernel] (2020-11-17)
Rebase kernel on Samsung's DTJA source code.
Merge all outstanding fixes and enhancements from the TWRP source tree.
This version is intended for use only with Android 10.
v3.4.0-3_ianmacd for G97[035]F [inc. DTH7 kernel] (2020-09-11)
Rebase kernel on Samsung's DTH7 source code.
This version is intended for use only with Android 10.
v3.4.0-2_ianmacd for G97[035]F [inc. CTG4 kernel] (2020-08-14)
Rebase kernel on Samsung's CTG4 source code.
This version is intended for use only with Android 10.
v3.4.0-1_ianmacd for G97[035]F [inc. CTF1 kernel] (2020-06-30)
Update TWRP to version 3.4.0.
This version is intended for use only with Android 10.
v3.3.1-105_ianmacd for G97[035]F [inc. CTF1 kernel] (2020-06-18)
Rebase kernel on Samsung's CTF1 source code.
This version is intended for use only with Android 10.
v3.3.1-104_ianmacd for G97[035]F [inc. CTD1 kernel] (2020-05-31)
Rebase kernel on Samsung's CTD1 source code.
This version is intended for use only with Android 10.
v3.3.1-103_ianmacd for G97[035]F [inc. CTC9 kernel] (2020-03-31)
Rebase kernel on Samsung's CTC9 source code.
This version is intended for use only with Android 10.
v3.3.1-102_ianmacd for G97[035]F [inc. BTA8 kernel] (2020-02-08)
Rebase kernel on Samsung's BTA8 source code.
This version is intended for use only with Android 10.
v3.3.1-101_ianmacd for G97[035]F [inc. BSKO kernel] (2019-12-20)
Fix for cosmetic Unable to decrypt FBE device message that was sometimes displayed in the previous Android 10 release (-100).
This version is intended for use only with Android 10.
v3.3.1-13_ianmacd for G97[035]F [inc. ASJG kernel] (2019-12-20)
Fix for cosmetic Unable to decrypt FBE device message that was sometimes displayed in the previous Android Pie release (-12).
This version is intended for use only with Android 9.
v3.3.1-100_ianmacd for G977B [inc. BSL2 kernel] (2019-12-20)
Rebase kernel on Samsung's BSL2 source code.
This version is intended for use only with Android 10.
v3.3.1-7_ianmacd for G977B [inc. ASJ7 kernel] (2019-12-19)
Rebase kernel on Samsung's ASJ7/ASK1 source code.
Merge latest upstream TWRP commits.
v3.3.1-100_ianmacd for G97[035]F [inc. BSKO kernel] (2019-12-07)
Rebase kernel on Samsung's BSKO source code.
This version is intended for use only with Android 10.
v3.3.1-12_ianmacd for G97[035]F [inc. ASJG kernel] (2019-12-03)
Rebase kernel on Samsung's ASJG source code.
v3.3.1-11_ianmacd for G97[035]F [inc. ASIG kernel] (2019-10-11)
Add support for Samsung DeX for PC.
v3.3.1-10_ianmacd for G97[035]F [inc. ASIG kernel] (2019-10-07)
Rebase kernel on Samsung's ASIG source code.
Merge latest upstream TWRP commits.
v3.3.1-9_ianmacd for G97[035]F [inc. ASH6 kernel (which also works with ASH1 firmware)] (2019-09-17)
Restore working MTP functionality to TWRP. With thanks to bigbiff for the reference and to Geiti for his commit embodying the same fix.
v3.3.1-8_ianmacd for G97[035]F [inc. ASH6 kernel (which also works with ASH1 firmware)] (2019-09-06)
Kernel rebased on Samsung's ASH6 source code.
v3.3.1-7_ianmacd for G97[035]F [inc. ASG8 kernel (which also works with ASH1 firmware)] and v3.3.1-6_ianmacd for G977B [inc. ASF5 kernel] (2019-08-20)
File-based System back-up option was missing in v3.3.1-6_ianmacd.
v3.3.1-6_ianmacd for G97[035]F [inc. ASG8 kernel (which also works with ASH1 firmware)] and v3.3.1-5_ianmacd for G977B [inc. ASF5 kernel] (2019-08-18)
Use $ANDROID_ROOT to set the mount point for the system block device to /system_root on these system-as-root devices.
This change renders this and future TWRP releases incompatible with previous versions. Any existing zip file installer code that attempts to mount /system or expects the system block device to be mounted on /system will now fail under this new version and will require modification.
Solved infinite recursion of symbolic links when resolving /system paths.
v3.3.1-5_ianmacd for G97[035]F [inc. ASG8 kernel (which also works with ASH1 firmware)] (2019-08-07)
Kernel rebased on Samsung's ASG8 source code.
v3.3.1-4_ianmacd for G977B [inc. ASF5 kernel] (2019-07-06)
Kernel rebased on Samsung's ASF5 source code.
Hugely improved Dutch translation.
v3.3.1-4_ianmacd for G97[035]F [inc. ASF3 kernel] (2019-07-05)
Kernel rebased on Samsung's ASF3 source code.
Hugely improved Dutch translation.
v3.3.1-3.1_ianmacd for G977B [inc. ASEC kernel] (2019-06-21)
First production release for the G977B (beyondx).
v3.3.1-3.1_ianmacd for G97[035]F [inc. ASE7 kernel] (2019-06-12)
Removed an experimental patch that was accidentally included in v3.3.1-3_ianmacd.
Previous releases were for the G97[035]F only:
v3.3.1-3_ianmacd [inc. ASE7 kernel] (2019-06-12)
Kernel rebased on Samsung's ASE7 source code.
v3.3.1-2_ianmacd [inc. ASD5 kernel] (2019-05-21)
Image back-ups of /product now possible.
v3.3.1-1_ianmacd [inc. ASD5 kernel] (2019-05-17)
Updated to upstream v3.3.1-0.
Fix linker warnings when binaries are executed while /system is mounted.
v3.3.0-2_ianmacd [inc. ASD5 kernel] (2019-05-11)
Kernel rebased on Samsung's ASD5 source code.
v3.3.0-1_ianmacd [inc. ASCA kernel] (2019-04-26)
Add support for mounting, backing up and restoring /product.
Add support for backing up and restoring /vendor.
Partitions now listed alphabetically.
Default brightness now 66% of maximum brightness (was 50%) to aid reading.
v3.3.0-0 [inc. ASCA kernel] (2019-04-21)
First ianmacd release.
TWRP updated to 3.3.0-0.
Fixes death on power-off issue, which left device unable to boot when turned back on.
Fixes inability to upgrade Magisk via Magisk Manager.
Replaces SELinux permissive kernel with enforcing kernel.
Reserved
Well done sir, well done!
Thank you for your continued work and support for TWRP.
Just to confirm the process if we want root and are already rooted -
follow your steps to root the new TWRP Image you posted today and zip it as a tar file in 7Zip
Flash rooted twrp in Odin
Reboot to Recovery
Format Data
Flash New Disabeler Script
Format Data again
Reboot in recovery (to reboot into magisk
Is that correct? (I read somewhere the other day that we needed to wipe again AFTER flashing the Disabler script and I didn't know if that was really necessary or if someone had mispoke?
Sorry to bother you but I have been trying to do as your OP outlines - but everytime I create a TAR File using the TWRP you provided patched with Magisk, when I try to flash in ODIN - nothing happens. The file won't flash. I have started over 5 times - created new Patched images in Magisk each time - but for some reason I am not having any luck getting this to flash in odin.
Can I flash the MAgisk patched Recovery Image in TWRP ?
EDIT - I answered my own question - I went ahead and tried to flash in TWRP and it flashed perfectly. All is good. But still curoiuos why I couldn't get the Patched Twrp File to fliash via odin - ?
Geekser said:
Sorry to bother you but I have been trying to do as your OP outlines - but everytime I create a TAR File using the TWRP you provided patched with Magisk, when I try to flash in ODIN - nothing happens. The file won't flash. I have started over 5 times - created new Patched images in Magisk each time - but for some reason I am not having any luck getting this to flash in odin.
+1
Click to expand...
Click to collapse
Great thread @ianmacd
By clicking on the button below you will get a set of instructions, step-by-step, on how to install Ians excellent work with TWRP as a recovery for your device and John Wu's root via Magisk.
This is not the fastest or most uncomplicated tutorial to do this. It is, however, made to make sure as many as possible succeed. So if you feel that a step or two is uncessesary, this tutorial is probably not for you since you most likely already know enough to just go by Ians more direct instructions. So dont PM me with tips on how to simplify these steps, I already know about that and that is not the point of the tutorial.
The instructions are intended for:
The user that either is completely new to this world but have managed to get an unlocked bootloader beforehand
The user that just want to have some instructions to follow to not forget a step in the process
Please note that the tutorial should work just fine for the S10E-device, but there might be another set of key combinations for your device, please take care to understand what you need to do in specifics to do the same presses of buttons.
It is strongly encourage to flash lates stock firmware and do a complete clean system install before using this tutorial. However, if you know what you are doing, it will work fine with an already rooted system as long as you have the latest Canary build (both magisk and magisk manager) on your device when patching the TWRP-image and the firmware AP-file per instructions below.
Where ever you decide to start, know that your device will be wiped and you need backups for your relevant data before you begin.
These instructions are ...
.. an "add-on" till John Wu's Magisk solution that will make your device rooted with Magisk and having Ian Macdonalds TWRP-recovery
.. for those who have already an unlocked bootloader - DO NOT attempt this without first making sure you have "OEM Unlocked" enabled
Step-by-step guide:
A) Follow John's instructions HERE until you get to step 5, then return here
B) Download latest TWRP-image by Ian Macdonald for your type of device in the first post in this thread
C) Download latest multidisabler-zip by Ian Macdonald and copy it to your SD-CARD - download here
D) Copy the TWRP-image to your device and do the same as you did with the AP-file in Magisk Manager (Install->Install->Patch file and choose the TWRP-image)
E) Copy the patched TWRP-image and magisk_patched.tar to your computer
F) Rename the patched TWRP-image to "recovery.img" on your computer
G) With your own choice of program on your computer, open the "magisk_patched.tar"-file, remove the existing recovery.img and replace it with your newly patched recovery.img and save the tar-file
H) Boot your device to download mode
I) Go back to John's instructions and IGNORE step 6 and DO step 7 and come back here!
J) We now need to factory reset our device:
-> Press Power + VolDown for a few seconds to get out of download mode
-> AS SOON AS THE SCREEN GOES BLACK: Press Power + Bixby + VolUP and HOLD THESE KEYS FOR A LONG TIME until you see the bootlogo of TWRP, then release the keys
K) In TWRP, install your downloaded multidisabler-zip from your SD-CARD and DO NOT REBOOT
L) In TWRP, format data (not only wipe, choose specifically "Format data" and write "yes" and go ahead and after DO NOT REBOOT
M) In TWRP, go back to the start screen - choose "Reboot" and choose "Recovery" AND NOTHING ELSE - DONT touch any keys on the device
N) Go back to John's instructions and begin from step 12
O) All done - you know have a rooted device by Magisk, with TWRP as recovery - enjoy and be sure to thank Ian Macdonald for the help with TWRP and John Wu for Magisk root!
hanspampel said:
Here are the magisk patched files for all devices. Only tried my s10+, but all the others should work too with odin.
Click to expand...
Click to collapse
Did you not read the OP?
John Wu does not allow the distribution of Magisk binaries in this way. If he did, I would have supplied pre-patched images myself. Post reported for removal.
Ian, does it matter the MM version when patching the AP and twrp img or all MM versions are doing the same job?
Thanks you.
starbucks2010 said:
Ian, does it matter the MM version when patching the AP and twrp img or all MM versions are doing the same job?
Click to expand...
Click to collapse
You need a recent Canary or ianmacd build, certainly from April. I would upgrade to the most recent build if I were you.
Great work Ian greatly appreciated that your placing your time into the community.
Don't copy me (got lazy) but I currently had twrp, so I just patched (the new img) flashed in Odin, and all appears to be good.....
ianmacd said:
changelog
v3.3.0-1_ianmacd (2019-04-26)
Add support for mounting, backing up and restoring /product.
Add support for backing up and restoring /vendor.
Partitions now listed alphabetically.
Default brightness now 66% of maximum brightness (was 50%) to aid reading.
Click to expand...
Click to collapse
Thank you for the decision to do this.
I made some backups on v3.3.0-0 and I believe /vendor was also included. Would there be anything wrong with these backups made on v3.3.0-0 now that I see such a line in the changelog? Did /vendor not backup correctly on TWRP 3.3.0-0?
So it is /vendor and /vendor image like with with system and system image. I flashed the latest TWRP and saw this..
But my Magisk manager patches my recoveries. badly
This is the 3rd time this happens to me.
After patching v3.3.0-1 i used the dd command to flash it. Then booted in TWRP, confirmed it was v3.3.0-1 and even made me a backup.
But I rebooting to rooted system isn't possible. The phone only boots to recovery no matter what. So I flashed patched v3.3.0-0 back. Things worked and booted to system. There I found that this latest "magisk_patched.img" is ~6 mb less than the raw "twrp-beyond2lte-3.3.0-1_ianmacd.img"
So I patched again. And again the produced "magisk_patched.img" was the same as the first one. How can I help myself here?
My Magisk Manager is 7.1.1 -54d1207f (207)
I am attaching the log file from MM for patching process .
tiho5 said:
So it is /vendor and /vendor image like with with system and system image. I flashed the latest TWRP and saw this..
But my Magisk manager patches my recoveries. badly
This is the 3rd time this happens to me.
After patching v3.3.0-1 i used the dd command to flash it. Then booted in TWRP, confirmed it was v3.3.0-1 and even made me a backup.
But I rebooting to rooted system isn't possible. The phone only boots to recovery no matter what. So I flashed patched v3.3.0-0 back. Things worked and booted to system. There I found that this latest "magisk_patched.img" is ~6 mb less than the raw "twrp-beyond2lte-3.3.0-1_ianmacd.img"
So I patched again. And again the produced "magisk_patched.img" was the same as the first one. How can I help myself here?
My Magisk Manager is 7.1.1 -54d1207f (207)
I am attaching the log file from MM for patching process .
Click to expand...
Click to collapse
When that symptom shows, only booting to recovery no matter what, it is always a sign that the recovery you flashed wasn't patched with Magisk.
Are you sure you are flashing the right file? I don't use dd but if you have Odin available, try instead to tar that magisk_patched.img and flash that tar in Odin instead.
Because if you are sure that the IMG is patched alright, then something with dd is not working.
/P
Edit: The shrinking you observe is normal and is as expected.. so it should be patched and then I suspect something in the process of using dd.
PiCkLeS said:
When that symptom shows, only booting to recovery no matter what, it is always a sign that the recovery you flashed wasn't patched with Magisk.
Are you sure you are flashing the right file? I don't use dd but if you have Odin available, try instead to tar that magisk_patched.img and flash that tar in Odin instead.
Because if you are sure that the IMG is patched alright, then something with dd is not working.
/P
Edit: The shrinking you observe is normal and is as expected.. so it should be patched and then I suspect something in the process of using dd.
Click to expand...
Click to collapse
No mate... The patching process is done right, I'm sure. And I also tried with Odin before I posted although I was sure it was not going to help. The recovery simply doesn't get patched right for some reason. This happened to me a few times before.
There is a log attached and one can see what happened and if I'm doing anything wrong (which indeed I doubt).
And also the patched files that I had done successfuly were more or less the same size as the raw file, only slightly bigger. This time it's not like that at all.
I was sure there's no working Magisk in that package.
The dd commands work and they're very convenient. I've used them for years. After I dd'd it, I indeed booted to the new recovery, saw that it's the new version, saw the changed things, the alphabetic order, even made a backup.
I didn't look much at the log file as it doesn't make too much sense to me, but I sure hope that Ian could investigate it.
Thanks anyway, mate.
I just ordered an S10e SM-G9700 with the unlocked Snapdragon bootloader (unlike the locked North American version). Will this work on that or is this purely for Exynos-based devices?
tiho5 said:
No mate... The patching process is done right, I'm sure. The recovery simply doesn't get patched right for some reason. This happened to me a few times before.
There is a log attached and one can see what happened and if I'm doing anything wrong (which indeed I doubt).
I didn't look much at the log file as it doesn't make too much sense to me, but I sure hope that Ian could investigate it.
Click to expand...
Click to collapse
Your log file shows this:
Code:
- Unpacking boot image
Parsing boot image: [/data/user_de/0/com.topjohnwu.magisk/install/boot.img]
It appears you patched a boot image, not a recovery image. Further output in the log show that it was, indeed, treated as a boot image, not a recovery image.
ianmacd said:
Your log file shows this:
It appears you patched a boot image, not a recovery image. Further output in the log show that it was, indeed, treated as a boot image, not a recovery image.
Click to expand...
Click to collapse
Why did Magisk Manager take the twrp-beyond2lte-3.3.0-1_ianmacd.img for a boot image? How can we avoid that.
There am I in need of a prepatched TWRP file, which is against the rules.
Do you have any idea how could I help my situation.

[RECOVERY][Android 10/11][Stock/SODP][XZ2/C/P/3] TWRP 3.4.0-0 [UNofficial]

The Sony Open Devices Project is always happy about volunteers (coding, testing, etc)
Also mainlining your favorite snapdragon powered xperia device into the mainline kernel is possible and we will be glad to help you!
Official site
Unofficial site
Code:
#include <std_disclaimer.h>
/*
*
* We are 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 us for messing up your device, we will laugh at you.
*
*/
Team Win Recovery Project 3.x, or twrp3 for short, is a custom recovery built with ease of use and customization in mind. Its a fully touch driven user interface no more volume rocker or power buttons to mash. The GUI is also fully XML driven and completely theme-able. You can change just about every aspect of the look and feel.
FAQ:
Just wiping your phone in TWRP lead into an encrypted & not readable userdata in the stock system.
You need to open advanced wiping and check the entries data and internal storage.
Of course clear the dalvik, too.
If you backed up system and/or vendor partitions and you want to restore them, make sure that TWRP setting "Use rm -rf instead of formatting" is set!.
If after the usage of NewFlasher or the OTA Updater or something else, which installs stock firmware parts you get stuck into the TWRP or SONY Logo, you need again to disable the verification with the vbmeta.img file and its parameters in fastboot.
fastboot & adb
https://developer.sony.com/develop/open-devices/get-started/flash-tool/useful-key-combinations/
https://wiki.lineageos.org/adb_fastboot_guide.html
https://developer.android.com/studio/releases/platform-tools
Weird problems not easily to reproduce by other users require that you make sure, that you
Use the newest platform tools (adb & fastboot)
Downloaded the newest firmware via Xperifirm from XDA and installed the newest firmware via Newflasher from XDA
Newflasher from XDA
Xperifirm from XDA
Removing the stock bloat apps via titanium backup may result in a boot loop. Use a file explorer to remove them, disable them or try to use my unfinished bloat removal script at github.
Your phone reboots into recovery, instead of system? Maybe it crashed too often due to a wrong installation or whatever?
In TWRP:
Code:
cat /dev/block/bootdevice/by-name/misc
shows you the reason.
TWRP -> [WIPE] -> [Advanced Wipe] -> Tick only the misc -> [Swipe to Wipe]
Known Bugs:
The "fastboot boot twrp.img" doesn't work, if you use the hardware buttons to open the blue fastboot bootloader mode. Only use adb, twrp or the android system to reboot into blue fastboot bootloader mode or flash the twrp.img, boot the device, reboot into bootloader and flash the original boot.img back, before booting into twrp.
You can also "fastboot reboot bootloader" in the blue fastboot mode.
This is a bootloader bug, maybe it gets fixed with the stock Q bootloader.
If "fastboot boot twrp.img" results into a blackscreen and reboot of the phone, take a look if you modified the DTBO partition.
It requires a special TWRP for every modified kernel/dtbo until I find some way to unify the twrp kernel with the DTBO (if the bootloader supports it).
Bugtracker:
TWRP Bugtracker -> If you think the problem is in TWRP
My Bugtracker -> If you think the problem is in my implementation
Bugreport:
A bugreport needs your device name, dmesg, the /tmp/recovery.log and a way to reproduce the issue.
If possible use
Code:
logcat -b all
instead of just a dmesg.
If ADB is not working to provide logs
VOLUP+POWER for 1 Seconds -> Forced crash to create a pstore
Boot the normal system.
Give me the files in
Code:
/sys/fs/pstore/
If the TWRP is stuck at the TWRP logo, the chances are high, that the decryption didn't succeed.
To rescue a not responding phone:
VOLUP+POWER for 3 Seconds -> RESTART with one Vibration.
VOLUP+POWER for 20 Seconds -> SHUTDOWN with 3 Vibrations.
VOLUP+POWER+CAMERA for 30 Seconds -> HARDWARE SHUTDOWN by discharging a capacitor.
Thank you very much for your help, code contribution & testing! (Random order):
@dees_troy and his team of volunteers for the TWRP code
@dhacke thank your for providing a download server
Shame on me if I forgot someone after searching through the thread and my PM's!
And many thanks to the few donators!
A telegram group for technical SODP stuff:
https://t.me/xda_tv
XDA:DevDB Information
TWRP, ROM for the Xperia XZ2
Contributors
MartinX3, Sony
Source Code: https://github.com/MartinX3-AndroidDevelopment
ROM OS Version: Android 10
ROM Kernel: Linux 4.x
ROM Firmware Required: Newest recommended
Based On: AOSP
Version Information
Status: Stable
Current Stable Version: 3.4.0-0
Stable Release Date: 2020-06-13
Created 2020-03-29
Last Updated 2020-06-20
Download & Installation
Download:
https://androidfilehost.com/?w=devices&uid=11410963190603893035
https://www.dhsfileserver.de/ftp/martinx3/ Thank you @dhacke for the second download server
Installation:
Update to newest stock firmware before unlocking!!!
Unzip the *.gz files with https://7-zip.org/ or Linux.
Enter fastboot via software, not hardware buttons. See "Known Bugs".
fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img
fastboot boot twrp.img
Advanced menu -> "Install recovery ramdisk" -> Choose twrp.img
Reboot into installed TWRP
Want Root? -> Magisk
(Only if your phone doesn't boot to system anymore) Advanced menu -> "Fix recovery bootloop"
(Optional; Security degradation; Only if you know what you're doing) Switch SELinux to permissive (with my permissive.zip)
News
02.03.2021
Reuploaded the SODP TWRP with a workaround for Android 11 compatibility.
Click to expand...
Click to collapse
15.06.2020
reuploaded the stock twrp for the xz2 premium with a completely fixed touch.
Click to expand...
Click to collapse
14.06.2020
reuploaded the stock twrp with a later touch kernel modules initialization.
Hopefully fixing the randomly happening not working touch.
Click to expand...
Click to collapse
13.06.2020
thanks to the fixes in 3.4.0 we got now a twrp with the following enhancements for stock and sodp:
- this twrp will work with future 10.0 roms, you don't need a new build matching the security patch level of your rom.
- you can install this twrp again with the buildin ramdisk patcher. Please follow the installation instructions.
Click to expand...
Click to collapse
11.06.2020
switch to twrp 3.4.0
sodp twrp 2020-06 security patch level
stock twrp 2020-05 security patch level for firmware 52.1.a.2.1
now both twrp should work without a rom being installed (empty system/vendor/oem partitions) and still be able to decrypt your userdata.
Also the stock twrp touch should now always work instead of playing russian roulette.
Click to expand...
Click to collapse
11.05.2020
reuploaded sodp twrp for 2020-05 security patch level.
It didn't boot with the newest aosp.
Click to expand...
Click to collapse
07.05.2020
sodp twrp for 2020-05 security patch level.
Click to expand...
Click to collapse
14.04.2020
removed stock twrp for firmware 52.1.a.0.672 until sony releases the kernel sources of the new security patch level.
Otherwise the keymaster won't decrypt the userdata for twrp and twrp gets stuck on the twrp logo.
Click to expand...
Click to collapse
13.04.2020
stock twrp for firmware 52.1.a.0.672
sodp twrp for 2020-04 security patch level
hopefully fixed the touch problems of the stock twrp
fixed the forced read only partition mountings of system, vendor, odm
Click to expand...
Click to collapse
31.03.2020
stock twrp for firmware 52.1.a.0.618
Click to expand...
Click to collapse
30.03.2020
sodp twrp for 2020-03 security patch level
installing in ramdisk (to make it persistent) is impossible at the moment, because it is a 9.0 twrp which makes its ramdisk incompatible to the rom.
Of course monthly twrp releases in sync with the current patch level need to be released or i would need to remove the userdata decryption completely.
The stock twrp will follow, after it became ready.
Click to expand...
Click to collapse
30.03.2020
SODP TWRP for 2020-03 security patch level
Installing in Ramdisk (to make it persistent) is impossible at the moment, because it is a 9.0 TWRP which makes its ramdisk incompatible to the ROM.
Of course monthly TWRP releases in sync with the current patch level need to be released or I would need to remove the userdata decryption completely.
The Stock TWRP will follow, after it became ready.
Click to expand...
Click to collapse
PS: AndroidFileHost blocked me for doing too many actions at the same time.
Maybe I can upload it there tomorrow.
Done
can't wait for possibility to install in ramdisk
but now there is a working recovery :highfive:
31.03.2020
Stock TWRP for firmware 52.1.A.0.618
Click to expand...
Click to collapse
xz3 twrp
MartinX3 said:
31.03.2020
Click to expand...
Click to collapse
xz3 twrp won't boot, sodp version is good but there's no install on ramdisk?
hafiidh said:
xz3 twrp won't boot, sodp version is good but there's no install on ramdisk?
Click to expand...
Click to collapse
You mean SODP TWRP works, but not the stock TWRP on your XZ3?
You are stuck on sony logo?
Or on TWRP logo?
I need a bugreport with "logcat -b all" via adb.
Install ramdisk doesn't work at the moment, because it is a TWRP 9.0 hack, since TWRP 10.0 is ready.
But I wrote it in the news
Edit:
Reworked the thread a bit for more clarification
First! Wonderful job!
---EDIT------
Everything works fine! So nice!
@MartinX3 Great job as always bro! :good:
I ran it on my XZ2 (stock 52.1.A.0.618).
Phone has booted to the twrp screen (till the unlock pattern), but the touch is not working (log).
I didn't start from scratch (fresh install), for the record.
Tia!
serajr said:
@MartinX3 Great job as always bro! :good:
I ran it on my XZ2 (stock 52.1.A.0.618).
Phone has booted to the twrp screen (till the unlock pattern), but the touch is not working (log).
I didn't start from scratch (fresh install), for the record.
Tia!
Click to expand...
Click to collapse
Thank you
Are you sure the touch doesn't work?
I tested this release on the same firmware on my XZ2 in stock.
This confuses me now.
You booted stock .618 before and you tried to deactivate & activate the display?
Here it worked right out of the box.
And if it happens again, could you execute "start preptouch"
And if that not works, could you execute "/sbin/preptouch.sh"?
Sjll said:
First! Wonderful job!
---EDIT------
Everything works fine! So nice!
Click to expand...
Click to collapse
Thank you
MartinX3 said:
[...] Are you sure the touch doesn't work?
And if it happens again, could you execute "start preptouch"
And if that not works, could you execute "/sbin/preptouch.sh"?
Click to expand...
Click to collapse
I am. I have tried at least three times so far. Tried turning off and on the screen, but the slide to unlock didn't work, too.
"start preptouch", no response, no working touch
"/sbin/preptouch.sh"...
Code:
insmod: failed to load /sbin/clearpad_rmi_dev.ko: File exists
insmod: failed to load /sbin/clearpad_core.ko: File exists
insmod: failed to load /sbin/clearpad_i2c.ko: File exists
akari:/sbin # ls -l
Tia again
serajr said:
I am. I have tried at least three times so far. Tried turning off and on the screen, but the slide to unlock didn't work, too.
"start preptouch", no response, no working touch
"/sbin/preptouch.sh"...
Code:
insmod: failed to load /sbin/clearpad_rmi_dev.ko: File exists
insmod: failed to load /sbin/clearpad_core.ko: File exists
insmod: failed to load /sbin/clearpad_i2c.ko: File exists
akari:/sbin # ls -l
Tia again
Click to expand...
Click to collapse
And the service menu of android should also say that you use the clearpad driver.
And I assume the 9.0 stock twrp did always touch fine?
The script say that the kernel modules for the touch driver got loaded and I assume the sys path in the script file got executed too, after loading the .ko files.
And you have a normal European firmware?
That's now a mystery for me why it works for me and others, but not in your phone
Especially if you have the clearpad touch hardware
MartinX3 said:
And the service menu of android should also say that you use the clearpad driver.
And I assume the 9.0 stock twrp did always touch fine?
The script say that the kernel modules for the touch driver got loaded and I assume the sys path in the script file got executed too, after loading the .ko files.
And you have a normal European firmware?
That's now a mystery for me why it works for me and others, but not in your phone
Especially if you have the clearpad touch hardware
Click to expand...
Click to collapse
I got the touch working after copying the three .ko libs to the ramdisk /sbin folder, and a small editing (below) in the permissive.sh (also removed "$touch_id" == "3" from preptouch.sh).
Code:
setenforce 0
insmod /sbin/clearpad_rmi_dev.ko
insmod /sbin/clearpad_core.ko
insmod /sbin/clearpad_i2c.ko
echo 1 > /sys/devices/virtual/input/clearpad/post_probe_start
I know this is an awful workaround, but maybe this give you some hint (or sets you more confusing yet )
I'm with the sony stock customized_br fw, as always!
serajr said:
I got the touch working after copying the three .ko libs to the ramdisk /sbin folder, and a small editing (below) in the permissive.sh (also removed "$touch_id" == "3" from preptouch.sh).
Code:
setenforce 0
insmod /sbin/clearpad_rmi_dev.ko
insmod /sbin/clearpad_core.ko
insmod /sbin/clearpad_i2c.ko
echo 1 > /sys/devices/virtual/input/clearpad/post_probe_start
I know this is an awful workaround, but maybe this give you some hint (or sets you more confusing yet )
I'm with the sony stock customized_br fw, as always!
Click to expand...
Click to collapse
Ah you have a XZ2C, not a XZ2?
Because the removed ID 3 is for the XZ2 with clearpad touch.
But the script did already copy the .ko files into your /sbin before and executed the same code, you did now manually.
And according to your logs the setenforce 0 was already executed earlier.
So you just did the same the script did.
Well, yes you confuse me more
Could you try to just execute "echo 1 > /sys/devices/virtual/input/clearpad/post_probe_start" if the touch doesn't work again?
I wonder if the initialization is too early on your device.
Then I could try to delay the preptouch service to a later stage of the device boot.
MartinX3 said:
Ah you have a XZ2C, not a XZ2?
Because the removed ID 3 is for the XZ2 with clearpad touch.
But the script did already copy the .ko files into your /sbin before and executed the same code, you did now manually.
And according to your logs the setenforce 0 was already executed earlier.
So you just did the same the script did.
Well, yes you confuse me more
Could you try to just execute "echo 1 > /sys/devices/virtual/input/clearpad/post_probe_start" if the touch doesn't work again?
I wonder if the initialization is too early on your device.
Then I could try to delay the preptouch service to a later stage of the device boot.
Click to expand...
Click to collapse
I have a regular XZ2 (H8216), and its touch_id is 3 (customized_br fw), so I removed the Id 3.
"Could you try to just execute..." I've already tried that, with no success.
"Then I could try to delay the preptouch..." Cool... As you could notice, it worked here with that awful way I did it, so why not?
:good:
serajr said:
I have a regular XZ2 (H8216), and its touch_id is 3 (customized_br fw), so I removed the Id 3.
"Could you try to just execute..." I've already tried that, with no success.
"Then I could try to delay the preptouch..." Cool... As you could notice, it worked here with that awful way I did it, so why not?
:good:
Click to expand...
Click to collapse
But you tried it also yourself later.
You executed the script again without success at a later stage.
And adding it to the permissive.sh is like executing the script, just earlier.
I assume `cat /sys/devices/dsi_panel_driver/panel_id` gives you the "3" as result?
MartinX3 said:
But you tried it also yourself later.
You executed the script again without success at a later stage.
And adding it to the permissive.sh is like executing the script, just earlier.
I assume `cat /sys/devices/dsi_panel_driver/panel_id` gives you the "3" as result?
Click to expand...
Click to collapse
I ran the scripts/codes manually in the trwp root shell (with the no working touch screen).
Yep, running the script earlier (permissive.sh) did the trick (*.ko files in the ramdisk).
And 3 is the output of the panel_id (that's why I removed the 3 from the preptouch.sh).
Edit: I've noticed this...
The permissions of the libs copied from vendor to sbin (preptouch), as you could see here
Code:
-rw------- 1 root root 1070630 1972-01-22 17:46 clearpad_core.ko
-rw------- 1 root root 251702 1972-01-22 17:46 clearpad_i2c.ko
-rw------- 1 root root 296934 1972-01-22 17:46 clearpad_rmi_dev.ko
Patched twrp
Code:
-rwxrwxrwx 1 root root 1070902 2020-04-02 21:48 clearpad_core.ko
-rwxrwxrwx 1 root root 251830 2020-04-02 21:48 clearpad_i2c.ko
-rwxrwxrwx 1 root root 297054 2020-04-02 21:48 clearpad_rmi_dev.ko
Edit 2: chmod on copied files did the trick (preptouch.sh) - but sometimes still not working (need to boot twice, three times...):
Code:
#XZ2 "3" XZ2C "4" Clearpad
if [[ "$touch_id" == "3" ]] || [[ "$touch_id" == "4" ]]; then
cp /v/lib/modules/clearpad_rmi_dev.ko /sbin/
cp /v/lib/modules/clearpad_core.ko /sbin/
cp /v/lib/modules/clearpad_i2c.ko /sbin/
[B]chmod 777 /sbin/clearpad_rmi_dev.ko
chmod 777 /sbin/clearpad_core.ko
chmod 777 /sbin/clearpad_i2c.ko[/B]
insmod /sbin/clearpad_rmi_dev.ko
insmod /sbin/clearpad_core.ko
insmod /sbin/clearpad_i2c.ko
echo 1 > /sys/devices/virtual/input/clearpad/post_probe_start
fi
Maybe you find out a more elegant way to handle with that!
Edit 3:
I also got it permanently installed on kernel (combo keys does work, too), it's a bit tricky I gotta say, but it works.
You know, twrp's ramdisk.cpio kernel hack (old install procedure).
Hi Martin,
just wanted to let you know that your latest version for Sony stock (0.618 fw) does also not work for me (touch does not respond). Even 'fastboot reboot bootloader' before 'fastboot boot twrp-xz2.img' doesn't change anything.
Device:
Xperia XZ2 (H8216) running Android 10 stock (52.1.A.0.618)
Customized CH
Clearpad Touch version: 3

[ROM][OFFICIAL][Pie][Dipper][PORT]Ubuntu Touch port for Xiaomi Mi 8

View attachment 5376913
What is it? What is Ubuntu Touch?
Ubuntu Touch, as comes from naming, is Ubuntu managed to run on phone.
Well, Canonical abandoned it, so community organization, UBports, now develops, maintains, and ports UT to new devices.
And this is what the thread is about. The amount of devices able to run UT was 63(as written on website at the time of writing this post). But now it is 64 devices.
The 64th port to Xiaomi Mi 8.​So, lets talk now what works, and what is not(you will also be able to see that on website, as soon as merge request will be accepted).
​What works:
Actors​
Manual brightness(auto seems not supported by UT, idk)​
Notification LED​
Vibration​
Torchlight​
Camera​
Flashlight​
Photo​
Video​
Switch between front and rear cameras​
Cellular​
Carrier info​
Calls​
SMS​
Audio routings (switching between main speaker, and phone speakers)​
Volume control​
Misc
Battery percentage
Online charging(while phone is on, or in sleep/standby state)
UBports recovery
Network
WiFi(2.4GHz, 5GHz)
Bluetooth
Hotspot(partially, seems that 5G is not supported)
Flight Mode
Sensors
Fingerpring
GPS
Rotation
Touchscreen(ofc, otherwise I would write this post)
Sound
Microphone
Earphones
Loudspeaker
Volume Control
USB
ADB
MTP
Several things, are not tested, such as Wireless Display, NFC, SIM PIN Unlock, MMS, Dual SIM.
Non working features are Offline Charging, Auto-brightness, Proximity Sensor(you need to click the Power Button, that won't stop the call).
Big thanks to TheKit who helped me with the port.
TheKit's Gitlab and UBports forum profile.
Right now, config for UBports Installer is waiting approval of pull request, and merge request for devices.ubuntu-touch.io is still not approved, you will have to do everything manually. UBports Installer config PR finally merged, but only Global versions are supported, since firmware files that are flashed by Installer are for Global. If you do install, be sure to flash vendor and firmware packages for your variant after.
WARNING! YOU MUST HAVE UNLOCKED BOOTLOADER! EVERY THING YOU DO, YOU DO ON YOUR RISK, IF YOU BRICKED DEVICE, THATS YOUR FAULT, NOT MY! I DO NOT TAKE ANY RESPONSIBILITY FOR YOUR BRICKED DEVICE!
Preparations before installation.
Flash TWRP recovery
You need to download and flash stock firmware and vendor from Android 9, MIUI V11.0.6.0.PEAMIXM(be aware that this Vendor+Fw is for Global, if your Device is Chinese or Russian variant, or any other, flash vendor package according your phone variant). It is compressed into ZIP file, so you will have to flash it though TWRP. Do not use adb sideload, push file to any directory you want, and install it from phone.
Download boot.img, system.img, recovery.img from here.
In TWRP go to "Wipe" ==> "Format Data" ==> Type "yes" ==> Enter. Then go to Reboot ==> Recovery. After restarted. Again go to Wipe ==> Advanced Wipe, and select all partition except USB-OTG
Now we have two ways of installation, from TWRP, and from Fastboot.
TWRP
On PC:
Code:
$ adb push system.img /tmp
$ adb push boot.img /tmp/
Now go to "Install"
Get to /tmp/ directory
"Install Image"
Flash boot.img to Boot partition, system.img to System.
Then reboot to system.
If system works, reboot to TWRP again and push recovery.img to /tmp/, then flash it to Recovery partition.
Fastboot method:
Code:
#Simple as that
$ fastboot flash boot boot.img
$ fastboot flash system system.img
$ fastboot flash recovery recovery.img
#Flash recovery only after you are sure system works.
Or you can just install a installable zip archive I've recently made. All my builds will be hosted on GitHub Releases on my repo. New builds will come by every new official OTA release. UBports recovery is not included, installation goes proceeds from TWRP, install just as simple as custom ROM installation. Btw, do you want me to add notch patches to system image, so it doesn't look awkward?
Note: this zip is not signed, so disable signature verification before installing, or installation will fail.
Optionally you can adjust your panel so it doesn't look weird. Rn idk how to move panel below the notch(display cutout, I hate Apple for that). It moves buttons in Panel below, and adjusts height of the panel. This repo will do everything for you. Just download it to device. And run apply-notch-hax.sh. It will automatically find device name, apply patches, and restart Unity.
Note: run the script as standard user, not root.
Note2: if you get bootloop, wipe system, format data, restart bootloader, flash everything again, but before rebooting to system try flashing SELinux permissiver. And don't flash Magisk, it's useless, and may destroy your system.
Device source: Gitlab
Kernel source: Gitlab
Gitlab CI build artifacts: Gitlab
Join Telegram support group if you need any help.
See all supported devices at official website.
P.S. Since you have to use fastboot, and UBports Installer uses fastboot, there may be some difficulties for Ryzen CPU users. I attached zip file with executable (.bat file). It will allow you use fastboot with USB 3.x + Ryzen. Unpack it. And run .bat file as admin. Reboot. Voila, fastboot works as should.
Linux users should either use another laptop with Intel CPU, or flash from Windows, or use USB 2.0 hub.
P.S.S. Ok, I managed to get GitHub CI to work, so now if any of you want to test fixes and new features, head to this GitHub repo, and download artifacts from "Make OTA images"(in Actions tab), and flash them using fastboot.
Amazing work! I've always wanted to port UBTouch to Mi 8 but I couldn't get WiFi and mobile data to work on my attempts. As my primary phone, I needed it to be online as much as possible. Really happy to be able to use it on our devices
I've noticed an issue (I haven't managed to recreate this however):
- The OS can't switch between audio outputs, for example I need to restart my phone to hear sounds from loudspeaker after making a phone call. Please let me know if there's a workaround for this issue.
I'll be looking out for more issues to report. Once again, thanks for this port it's amazing
someone plz port Ubuntu to poco f1 too
gamerlucky said:
someone plz port Ubuntu to poco f1 too
Click to expand...
Click to collapse
It is already ported, a long before Mi 8
@itagizade have you tried waydroid on this?
nSKN3i said:
@itagizade have you tried waydroid on this?
Click to expand...
Click to collapse
No still not.
this amazing work. i have ran some x11 app on my phone,jt works. now i can say hava a pc in my pocket . one problem i found is system partion size too small (only 3g), this not enough if i want install more linux package lije chrome firefox
I updated download link, so if you have already flashed everything, I suggest you to flash a new recovery, as previous one, identified device as Mi MIX 3.
it is still complex for my level of knowledge to install this rom on my Mi 8 and it is with great joy that we have a port like this from Ubuntu Touch and that in the future it will be easier to install and maybe other ports as well as SailfishOS in the menu. Mi 8 great job Dev.
itagizade said:
It is already ported, a long before Mi 8
Click to expand...
Click to collapse
link please
gamerlucky said:
link please
Click to expand...
Click to collapse
See on devices.ubuntu-touch.io.
tried it out and worked great, glad to see something different, keep up the excellent work bro!
hey i was wondering about file system can we use f2fs ?
I tried installing apk files but getting error
Also notch fix gives me this error in terminal
EDIT: nevermind the apk i forgot to run anbox-tool install
EDIT2: nevermind notch fix i just pushed the file to downloads and run sh command
Amazing work! It is the fastest rom I have ever installed! The SIM PIN unlock works well and the offline charging partially (approximately, five minutes after connecting the charger). I hope NFC works, too. In the future, it would be nice if apply-notch-hax.sh was fixed (error, line 57). Anyway, thank you for porting and providing this rom!
For Waydroid support, there are some instructions here. To start the container service, use the following command:
Code:
sudo waydroid container start
Advanced Gears said:
Amazing work! It is the fastest rom I have ever installed! The SIM PIN unlock works well and the offline charging partially (approximately, five minutes after connecting the charger). I hope NFC works, too. In the future, it would be nice if apply-notch-hax.sh was fixed (error, line 57). Anyway, thank you for porting and providing this rom!
For Waydroid support, there are some instructions here. To start the container service, use the following command:
Code:
sudo waydroid container start
Click to expand...
Click to collapse
Glad you enjoy it. Right now I'm a little busy, but asap I will continue the work on this. Gotta make it daily-driver ready.
About error with `apply-notch-hax.sh`, other people have successfully used that script. Could you please specify the error?
The touch has been dead since I flash This rom
MilkywayOpenSource said:
The touch has been dead since I flash This rom
Click to expand...
Click to collapse
You mean Touchscreen is not working? Did you change you stock panel?
No,
MilkywayOpenSource said:
No,
Click to expand...
Click to collapse
Is your device Chinese version, or any other that Global?
It is global and after I install Ubuntu touch the screen never response to touch even in twrp

How to build a vendor image?

I'm trying to create a working vendor.img, however so far unsuccessful.
It does create a flashable ROM just fine, however I'm stuck at the Samsung (init) bootscreen/logo (last_kmesg).
Is it possible? How do I need which files to extract? I'm now searching for reference from other sources.
Thanks!
were you able to progress in this?
poppopret_ said:
were you able to progress in this?
Click to expand...
Click to collapse
Yes, I was able to boot, everything worked except the camera and SELinux.
Unfortunately, I don't have a S9 anymore. However you may want to use the linked Github as reference.
francoism90 said:
Yes, I was able to boot, everything worked except the camera and SELinux.
Unfortunately, I don't have a S9 anymore. However you may want to use the linked Github as reference.
Click to expand...
Click to collapse
I'm working with pixel 4a. I had made changes to device.mk to remove some files from being copied to vendor under
PRODUCT_COPY_FILES but vendor.img provided by google gets copied as a whole ignoring these changes. Do you have any idea on how to edit/override or build vendor.img?
I also tried to use proprietary files provided here in vendor folder and included the mk file in aosp-sunfish.mk but every other images get built except vendor.img.
You need to set the following:
Code:
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
TARGET_COPY_OUT_VENDOR := vendor
BOARD_VENDORIMAGE_PARTITION_SIZE := 679...
Otherwise, it will copy the files to /system/vendor (if I'm not mistaken).
I was able to generate vendor.img successfully, but after I flashed the images, phone gets stuck in google logo. How can this be debugged? Is there a way to retrieve logs?
I tried accessing it through adb but the device is not recognised by adb at this point.
@poppopret_ Are you using TWRP or LineageOS recovery? When booting back to your recovery, they can be used to get the last_kmesg log, which should hopefully provide you with debugging.
francoism90 said:
Yes, I was able to boot, everything worked except the camera and SELinux.
Unfortunately, I don't have a S9 anymore. However you may want to use the linked Github as reference.
Click to expand...
Click to collapse
sir can u please tell me the steps to create vendor.img
francoism90 said:
You need to set the following:
Code:
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
TARGET_COPY_OUT_VENDOR := vendor
BOARD_VENDORIMAGE_PARTITION_SIZE := 679...
Otherwise, it will copy the files to /system/vendor (if I'm not mistaken).
Click to expand...
Click to collapse
where i write this

Categories

Resources