[Recovery] Unofficial TWRP 3.0.2-0 for ZUK Z1

btme

Member
Feb 18, 2016
32
12
0
www.bjoern-tantau.de
I've managed to compile TWRP with working decryption. The attached zip is not flashable by TWRP (at least I don't think it is). I just zipped it so that I could work around the 8 MB file limit for img files.

For anyone curious how I did this (or wants to do it himself):

I set up the cyanogenmod source using https://wiki.cyanogenmod.org/w/Build_for_ham.

Then I added a local manifest containing
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remove-project name="CyanogenMod/android_bootable_recovery" />
  <project path="bootable/recovery" name="omnirom/android_bootable_recovery" clone-depth="1" remote="github" revision="android-6.0" />
  <project path="external/busybox" name="omnirom/android_external_busybox" clone-depth="1" remote="github" revision="android-6.0" />
</manifest>
I added
Code:
-bin/linker
-firmware/keymaste.b00
-firmware/keymaste.b01
-firmware/keymaste.b02
-firmware/keymaste.b03
-firmware/keymaste.mdt
-firmware/cmnlib.b00
-firmware/cmnlib.b01
-firmware/cmnlib.b02
-firmware/cmnlib.b03
-firmware/cmnlib.mdt
to device/zuk/ham/proprietary-files-qc.txt.

Added the file device/zuk/ham/twrp.fstab
Code:
/cache            ext4       /dev/block/bootdevice/by-name/cache
/system           ext4       /dev/block/bootdevice/by-name/system
/data             ext4       /dev/block/bootdevice/by-name/userdata     nosuid,nodev,barrier=1,noauto_da_alloc                      wait,check,formattable,encryptable=footer,length=-16384
/persist        ext4    /dev/block/bootdevice/by-name/persist
/boot             emmc       /dev/block/bootdevice/by-name/boot
/recovery         emmc       /dev/block/bootdevice/by-name/recovery
#/misc  emmc    /dev/block/bootdevice/by-name/misc
/firmware       vfat    /dev/block/mmcblk0p1    ro,shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337,context=u:object_r:firmware_file:s0    wait
/usb-otg          auto       /devices/platform/xhci-hcd                     flags=display="USB OTG";storage;wipeingui;removable
/sdcard1        auto    /devices/msm_sdcc.2/mmc_host*   flags=storage;removable;encryptable=userdata
Added
Code:
# Recovery
#TARGET_RECOVERY_FSTAB := $(DEVICE_PATH)/rootdir/etc/fstab.qcom

# TWRP Settings
DEVICE_RESOLUTION := 1080x1920
TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
BOARD_USE_CUSTOM_RECOVERY_FONT := \"roboto_23x41.h\"
TW_INTERNAL_STORAGE_PATH := "/sdcard"
TW_INTERNAL_STORAGE_MOUNT_POINT := "sdcard"
TW_FLASH_FROM_STORAGE := true
TW_BRIGHTNESS_PATH := /sys/class/leds/lcd-backlight/brightness
RECOVERY_GRAPHICS_USE_LINELENGTH := true
BOARD_HAS_NO_SELECT_BUTTON := true
RECOVERY_SDCARD_ON_DATA := true
TW_INCLUDE_CRYPTO := true

COMMON_GLOBAL_CFLAGS += -DNO_SECURE_DISCARD
BOARD_SUPPRESS_EMMC_WIPE := true

PRODUCT_COPY_FILES += device/zuk/ham/twrp.fstab:recovery/root/etc/twrp.fstab

ifneq ($(TARGET_RECOVERY_ROOT_OUT),)
    $(shell mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/firmware/image)
    $(shell mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib/hw)
    $(shell ln -s /sbin $(TARGET_RECOVERY_ROOT_OUT)/system/bin)
endif

PRODUCT_COPY_FILES += \
    vendor/zuk/ham/proprietary/bin/qseecomd:recovery/root/system/bin/qseecomd \
    vendor/zuk/ham/proprietary/bin/linker:recovery/root/system/bin/linker \
    vendor/zuk/ham/proprietary/vendor/lib/libssd.so:recovery/root/vendor/lib/libssd.so \
    vendor/zuk/ham/proprietary/vendor/lib/librpmb.so:recovery/root/vendor/lib/librpmb.so \
    vendor/zuk/ham/proprietary/vendor/lib/libdiag.so:recovery/root/vendor/lib/libdiag.so \
    vendor/zuk/ham/proprietary/vendor/lib/libdrmfs.so:recovery/root/vendor/lib/libdrmfs.so \
    vendor/zuk/ham/proprietary/vendor/lib/libQSEEComAPI.so:recovery/root/vendor/lib/libQSEEComAPI.so \
    vendor/zuk/ham/proprietary/vendor/lib/libdrmtime.so:recovery/root/vendor/lib/libdrmtime.so \
    vendor/zuk/ham/proprietary/lib/hw/keystore.msm8974.so:recovery/root/vendor/lib/hw/keystore.msm8974.so \
    vendor/zuk/ham/proprietary/firmware/image/keymaste.b00:recovery/root/firmware/image/keymaste.b00 \
    vendor/zuk/ham/proprietary/firmware/image/keymaste.b01:recovery/root/firmware/image/keymaste.b01 \
    vendor/zuk/ham/proprietary/firmware/image/keymaste.b02:recovery/root/firmware/image/keymaste.b02 \
    vendor/zuk/ham/proprietary/firmware/image/keymaste.b03:recovery/root/firmware/image/keymaste.b03 \
    vendor/zuk/ham/proprietary/firmware/image/keymaste.mdt:recovery/root/firmware/image/keymaste.mdt \
    vendor/zuk/ham/proprietary/firmware/image/cmnlib.b00:recovery/root/firmware/image/cmnlib.b00 \
    vendor/zuk/ham/proprietary/firmware/image/cmnlib.b01:recovery/root/firmware/image/cmnlib.b01 \
    vendor/zuk/ham/proprietary/firmware/image/cmnlib.b02:recovery/root/firmware/image/cmnlib.b02 \
    vendor/zuk/ham/proprietary/firmware/image/cmnlib.b03:recovery/root/firmware/image/cmnlib.b03 \
    vendor/zuk/ham/proprietary/firmware/image/cmnlib.mdt:recovery/root/firmware/image/cmnlib.mdt
to device/zuk/ham/BoardConfig.mk. Please note the commented TARGET_RECOVERY_FSTAB.

And added
Code:
on fs
    service qseecomd /system/bin/qseecomd
to device/zuk/ham/rootdir/etc/init.recovery.qcom.rc.


Then I just compiled TWRP and it finally (after many trials and errors) worked.

acran from https://github.com/TeamWin/android_device_oneplus_oneplus2/issues/1 gave me the final tips needed to get it working.

Next I'll try to get it pulled into official TWRP. But I don't know if that is possible with all the proprietary files needed.

Edit: I tried it with a password and a PIN. I didn't test it with a pattern. But as I had to enter the PIN via a normal keyboard I guess that it will be the same with a pattern.
 

Attachments

Last edited:

eagleeyetom

Retired Developer Committee Lead / Retired Senior
Jan 22, 2011
7,713
14,658
113
34
Gdańsk
xda-developers.com
I've managed to compile TWRP with working decryption. The attached zip is not flashable by TWRP (at least I don't think it is). I just zipped it so that I could work around the 8 MB file limit for img files.

For anyone curious how I did this (or wants to do it himself):

I set up the cyanogenmod source using https://wiki.cyanogenmod.org/w/Build_for_ham.

Then I added a local manifest containing
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remove-project name="CyanogenMod/android_bootable_recovery" />
  <project path="bootable/recovery" name="omnirom/android_bootable_recovery" clone-depth="1" remote="github" revision="android-6.0" />
  <project path="external/busybox" name="omnirom/android_external_busybox" clone-depth="1" remote="github" revision="android-6.0" />
</manifest>
I added
Code:
-bin/linker
-firmware/keymaste.b00
-firmware/keymaste.b01
-firmware/keymaste.b02
-firmware/keymaste.b03
-firmware/keymaste.mdt
-firmware/cmnlib.b00
-firmware/cmnlib.b01
-firmware/cmnlib.b02
-firmware/cmnlib.b03
-firmware/cmnlib.mdt
to device/zuk/ham/proprietary-files-qc.txt.

Added the file device/zuk/ham/twrp.fstab
Code:
/cache            ext4       /dev/block/bootdevice/by-name/cache
/system           ext4       /dev/block/bootdevice/by-name/system
/data             ext4       /dev/block/bootdevice/by-name/userdata     nosuid,nodev,barrier=1,noauto_da_alloc                      wait,check,formattable,encryptable=footer,length=-16384
/persist        ext4    /dev/block/bootdevice/by-name/persist
/boot             emmc       /dev/block/bootdevice/by-name/boot
/recovery         emmc       /dev/block/bootdevice/by-name/recovery
#/misc  emmc    /dev/block/bootdevice/by-name/misc
/firmware       vfat    /dev/block/mmcblk0p1    ro,shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337,context=u:object_r:firmware_file:s0    wait
/usb-otg          auto       /devices/platform/xhci-hcd                     flags=display="USB OTG";storage;wipeingui;removable
/sdcard1        auto    /devices/msm_sdcc.2/mmc_host*   flags=storage;removable;encryptable=userdata
Added
Code:
# Recovery
#TARGET_RECOVERY_FSTAB := $(DEVICE_PATH)/rootdir/etc/fstab.qcom

# TWRP Settings
DEVICE_RESOLUTION := 1080x1920
TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
BOARD_USE_CUSTOM_RECOVERY_FONT := \"roboto_23x41.h\"
TW_INTERNAL_STORAGE_PATH := "/sdcard"
TW_INTERNAL_STORAGE_MOUNT_POINT := "sdcard"
TW_FLASH_FROM_STORAGE := true
TW_BRIGHTNESS_PATH := /sys/class/leds/lcd-backlight/brightness
RECOVERY_GRAPHICS_USE_LINELENGTH := true
BOARD_HAS_NO_SELECT_BUTTON := true
RECOVERY_SDCARD_ON_DATA := true
TW_INCLUDE_CRYPTO := true

COMMON_GLOBAL_CFLAGS += -DNO_SECURE_DISCARD
BOARD_SUPPRESS_EMMC_WIPE := true

PRODUCT_COPY_FILES += device/zuk/ham/twrp.fstab:recovery/root/etc/twrp.fstab

ifneq ($(TARGET_RECOVERY_ROOT_OUT),)
    $(shell mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/firmware/image)
    $(shell mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib/hw)
    $(shell ln -s /sbin $(TARGET_RECOVERY_ROOT_OUT)/system/bin)
endif

PRODUCT_COPY_FILES += \
    vendor/zuk/ham/proprietary/bin/qseecomd:recovery/root/system/bin/qseecomd \
    vendor/zuk/ham/proprietary/bin/linker:recovery/root/system/bin/linker \
    vendor/zuk/ham/proprietary/vendor/lib/libssd.so:recovery/root/vendor/lib/libssd.so \
    vendor/zuk/ham/proprietary/vendor/lib/librpmb.so:recovery/root/vendor/lib/librpmb.so \
    vendor/zuk/ham/proprietary/vendor/lib/libdiag.so:recovery/root/vendor/lib/libdiag.so \
    vendor/zuk/ham/proprietary/vendor/lib/libdrmfs.so:recovery/root/vendor/lib/libdrmfs.so \
    vendor/zuk/ham/proprietary/vendor/lib/libQSEEComAPI.so:recovery/root/vendor/lib/libQSEEComAPI.so \
    vendor/zuk/ham/proprietary/vendor/lib/libdrmtime.so:recovery/root/vendor/lib/libdrmtime.so \
    vendor/zuk/ham/proprietary/lib/hw/keystore.msm8974.so:recovery/root/vendor/lib/hw/keystore.msm8974.so \
    vendor/zuk/ham/proprietary/firmware/image/keymaste.b00:recovery/root/firmware/image/keymaste.b00 \
    vendor/zuk/ham/proprietary/firmware/image/keymaste.b01:recovery/root/firmware/image/keymaste.b01 \
    vendor/zuk/ham/proprietary/firmware/image/keymaste.b02:recovery/root/firmware/image/keymaste.b02 \
    vendor/zuk/ham/proprietary/firmware/image/keymaste.b03:recovery/root/firmware/image/keymaste.b03 \
    vendor/zuk/ham/proprietary/firmware/image/keymaste.mdt:recovery/root/firmware/image/keymaste.mdt \
    vendor/zuk/ham/proprietary/firmware/image/cmnlib.b00:recovery/root/firmware/image/cmnlib.b00 \
    vendor/zuk/ham/proprietary/firmware/image/cmnlib.b01:recovery/root/firmware/image/cmnlib.b01 \
    vendor/zuk/ham/proprietary/firmware/image/cmnlib.b02:recovery/root/firmware/image/cmnlib.b02 \
    vendor/zuk/ham/proprietary/firmware/image/cmnlib.b03:recovery/root/firmware/image/cmnlib.b03 \
    vendor/zuk/ham/proprietary/firmware/image/cmnlib.mdt:recovery/root/firmware/image/cmnlib.mdt
to device/zuk/ham/BoardConfig.mk. Please note the commented TARGET_RECOVERY_FSTAB.

And added
Code:
on fs
    service qseecomd /system/bin/qseecomd
to device/zuk/ham/rootdir/etc/init.recovery.qcom.rc.


Then I just compiled TWRP and it finally (after many trials and errors) worked.

acran from https://github.com/TeamWin/android_device_oneplus_oneplus2/issues/1 gave me the final tips needed to get it working.

Next I'll try to get it pulled into official TWRP. But I don't know if that is possible with all the proprietary files needed.

Edit: I tried it with a password and a PIN. I didn't test it with a pattern. But as I had to enter the PIN via a normal keyboard I guess that it will be the same with a pattern.
Great stuff!
I've been trying to fix it for a long time, but finally gave up on this. Definitely try to make a pull request to fix the official TWRP. You'll have to switch to Omni tree anyway. I'm thinking about releasing an unofficial version with more things enabled, so users will have a choice. The only thing that drives me crazy is AROMA which simply doesn't work as intended.
 

xstarlightx

New member
Aug 21, 2016
2
0
0
Hi,
Can I install the TWRP without losing data?
My phone has continuous reboots every minute (probably broke the bateria after prolonged exposure to the sun) and I can not save data.
While in recovery mode (stock) is not restarted. I enabled USB debugging
I need to make a mount of the internal storage of the recovery.
Can you advise me how to solve?
Thanks in advance
 

acuicultor

Recognized Contributor / Recognized Developer
Jan 3, 2013
3,037
10,864
263
Palma de Mallorca
Hi,
Can I install the TWRP without losing data?
My phone has continuous reboots every minute (probably broke the bateria after prolonged exposure to the sun) and I can not save data.
While in recovery mode (stock) is not restarted. I enabled USB debugging
I need to make a mount of the internal storage of the recovery.
Can you advise me how to solve?
Thanks in advance
If you don't have problems in recovery mode i bet your issue is software related, by flashing a recovery you don't loose any data btw you can use adb pull (all folders you want in your internal storage) with stock recovery.

Enviado desde mi Z1 mediante Tapatalk
 

vwfreak2001

Senior Member
Mar 27, 2011
95
35
0
Hi!

I'm having a problem encyrpting my Zuk. I flashed the above mentioned TWRP from @btme and it's working.

But when I try to encrypt the phone I see the green robot fpr 1-2 seconds. Now the phone reboots and I only see the blue Cyanogen head.
Nothing happens for hours. After a whole night I rebooteed the phone and everything was working as before.

What could be the problem? I'm using CM13 nightlies.
 

btme

Member
Feb 18, 2016
32
12
0
www.bjoern-tantau.de
Hi!

I'm having a problem encyrpting my Zuk. I flashed the above mentioned TWRP from @btme and it's working.

But when I try to encrypt the phone I see the green robot fpr 1-2 seconds. Now the phone reboots and I only see the blue Cyanogen head.
Nothing happens for hours. After a whole night I rebooteed the phone and everything was working as before.

What could be the problem? I'm using CM13 nightlies.
You should ask in the CM thread. But which nightly are you using exactly? I had problems with encryption in 20160830 (probably still in 20160831).
 

pd555

Senior Member
Mar 27, 2010
155
5
18
It's been a while since I flashed anything in recovery. Whenever I try to install this (or anything else) I get an error. "This package is for device Z1; this device is k9"

I have searched around but cannot find any solution to this. Can anyone help?

Thanks
 

eagleeyetom

Retired Developer Committee Lead / Retired Senior
Jan 22, 2011
7,713
14,658
113
34
Gdańsk
xda-developers.com
It's been a while since I flashed anything in recovery. Whenever I try to install this (or anything else) I get an error. "This package is for device Z1; this device is k9"

I have searched around but cannot find any solution to this. Can anyone help?

Thanks
You can edit the updater-script within ZIP file and delete a few first lines responsible for checking asserts.
 

pd555

Senior Member
Mar 27, 2010
155
5
18
You can edit the updater-script within ZIP file and delete a few first lines responsible for checking asserts.
I have tried that, unpacked with 7zip, made the change then archived it back to zip. It now just errors straight away with no clue to what the error is. I am wondering if I am creating the zip wrong?

Thanks for any help