yashsingh1/xdaforums huggingface dataset:
[ZenFone 2 Android Development] TheSSJ:
Update 07-02-2015

ADB sideload works now (thanks [MENTION=2836769]jrior001[/MENTION] & [MENTION=3857343]crpalmer[/MENTION])! Make sure to download the latest ADB version: http://xdaforums.com/showthread.php?p=42407269, credits for this to [MENTION=3558630]shimp208[/MENTION]

Update 06-30-2015

NTFS Support tested extensively and proved to be stable (not elegant, but functional)

Added recovery partition back to recovery.fstab to make it flashable via recovery itself

Update 06-28-2015

Moved to stable state

Added Beta version for NTFS support (twrp_ntfs.img)

Update 06-23-2015b

Upgraded source to TWRP 2.8.7.0

Update 06-23-2015

Functional TWRP with fast wipe/restore (-DNO_SECURE_DISCARD, thanks crpalmer)

ADB works

Just have fun in fiddleing around with the recovery

If no bugs will be reported we can declare this recovery stable

Update 06-10-2015

Boardconfig parameters changed, seems to back up, restore and flash even with USB cable attached

Update 06-04-2015b

Rolled back to 2.8.5.0 as restoring threw out the error that system was not being able to mount rw

Everything works now!

Update 06-04-2015

Built a version optimized for x86, fixes UI lags

Added Crypto Support again

Update 06-02-2015b

Removed TW_INCLUDE_CRYPTO flag as it caused backup operation to freeze

Update 06-02-2015

Moved to Beta stage

Fixed mounting of external SD

Update 06-01-2015

Completely reworked BoardConfig.mk

Removed all modules

Added [MENTION=2472806]vampirefo[/MENTION] 's adbd and adbd-recovery binaries from his TWRP builds (dunno why, but there aren't any binaries in my builds?) - thanks!

Graphics work now (still slow, need to fine tune with the correct boardconfig flags), no double backups, no flickering!

Update 05-31-2015

Included USES_ION flag into boardconfig.mk

Removed cpu temperature to reduce redraws

a little more stable now!
[ZenFone 2 Android Development] Pilz:
Nice I can't wait for the BL to be fully unlocked so we van get native TWRP.
[ZenFone 2 Android Development] jejemc:
Hello recovery or rest and it just temporary? thank you ;);)
[ZenFone 2 Android Development] TheSSJ:
Hi,

yes, after rebooting no trace of TWRP is left :)

I have updated the zip now. It is a little stabler after I removed the CPU temperature, but still I have the feeling there are 2 GUIs sharing the same screen. Weird - I have to do more research - maybe I have to write my own UI updater...

Cheers
[ZenFone 2 Android Development] cjvzla:
the gears are slowly moving! i hope BL gets unlocked by the time my ZF2 arrives..

is this for any ZF2 variant or just 551ML (4gb ram/2gb ram versions)?

thanks for taking the time with this (hopefully) awesome device!
[ZenFone 2 Android Development] backdown:
This is awesome..thanks for your contribution! I am hoping for some custom roms..the stock ZenUI isn't the greatest :/
[ZenFone 2 Android Development] crpalmer:
Do you have a link to your device repo?

Are there specific instructions for using it to build a tethered recovery (I'm familiar with building twrp, including within CM, but I haven't looked much into what the tethered exploit does to boot the recovery).
[ZenFone 2 Android Development] sunshine333:
It seems I have successfully completed a Backup! As mentioned, the interface is painfully slow at times, but this is serious progress. Has anybody tried restoring a backup yet?
[ZenFone 2 Android Development] joel george alex:
Could you please develop twrp or cwm for asus 450cg
[ZenFone 2 Android Development] 29y6145:
NOTE:

1 backup successfully

2 Use Very lag

3 flash zip not work
[ZenFone 2 Android Development] TheSSJ:
Hi,

unfortunately I don't have any. Basically I wrote a BoardConfig.mk based on the data provided by the Nexus Player (Asus Fugu, which is also Intel based). Then I took 2 modules (one for the display and one for the support of exfat partitions) and compiled a normal TWRP. The output folder holds the compiled img as well as the ramdisk in a simple folder. I put the ramdisk content into a simple zip file and included an update-script to have it unpacked properly. What the recovery-trigger exactly does is not clear to me. It seems it temporarily overwrites the logcat binary with itself and then gets executed at a reboot directly. The recovery trigger just unpacks the zip and executes the recovery binary if I understood correctly.

If you want I can upload my device configuration, it's better if there are more ppl looking at this :)

Thanks for the feedback!

2. Yeah, the lags are a pain, also because it seems to execute every touch twice and I don't know how to fix this at the moment (maybe it is sufficient to increase the time to determine when a longpress is executed and when a normal touch is done, but this is strongly theoretical.

3. I tested flashing a zip and it does work, which error message do you get?

Anyways, today is a new day, so I will get to work on this (I am on vacation right now fortunately).

Cheers!
[ZenFone 2 Android Development] crpalmer:
If you can upload the device config to github I can try to take a look tonight or tomorrow and see if I can see anything wrong that would explain your "double ui".

Either way, it is good to upload it as you'll have a history saved of when it last worked if you screw it all up! :)
[ZenFone 2 Android Development] vampirefo:
Is your problems due to recovery or modules you added? My tethered twrp doesn't have the problems yours does, so I wonder if it's the modules, your packaging perhaps and not the recovery?
[ZenFone 2 Android Development] sorg:
Dees_Troy is lying. TWRP graphic engine isn't optimized for any architecture. Even on my SGS4 (ARM) it's slow as snail. Higher resolution - more slower. I see, they've added some code for Qualcomm overlay support. I didn't try it yet, but support only for one CPU manufacturer is nothing. Especially, there is another way to accelerate at around 1000% by SIMD instuctions. Although i've liked TWRP originally, i see developers have no intentions to improve graphics which is the key feature. So, i've decided to throw away TWRP and look at Aroma File Manager.

It has very fast graphics engine with ARM NEON optimization (and with some effort it become SSE4.2 optimized). The only feature missing is backup/restore, but i'm working on that. Actually, Backup/Restore works now. Just thinking about better backup format.
[ZenFone 2 Android Development] vampirefo:
tar is the best.
[ZenFone 2 Android Development] sorg:
I know. The problem is how to split the archive. Currently i split by size. In this case you cannot use parts independently. For example, if you want to extract some file, you have to concatenate whole backup first and then extract.

The better way is to split tar at header boundary but so far in many decades of years nobody created such split tool. Also, if there is a file bigger than desired part size, it won't be split and may even produce error if target disk (where backup is saving to) is FAT and file size is bigger than 4GB (extreme case).
[ZenFone 2 Android Development] social-design-concepts:
[MENTION=912474]Dees_Troy[/MENTION] actually is not lying pixelflinger_static isn't optimize for x86 and Intel used to add libenc to speed up pixelflinger a little, intel later decided to use the more recent version of libminui cause it doesn't use pixelflinger_static and from what i read it a whole lot faster. i imagine [MENTION=912474]Dees_Troy[/MENTION] and team-win are looking into moving away from pixelflinger because of it's draw backs but that is a very big task.

i plan to build against the windriver android-5.0.0_r2.0.1 source this evening cause it includes the icc tool chain when i built the new recovery.launcher against it , it was much much much much much faster hope it has the same affect on twrp
[ZenFone 2 Android Development] TheSSJ:
I assume maybe I am

missing

some modules. There is a .ko file named fps_throttle...this led me to the conclusion that maybe the framerate is awefully high (or awefully low :D), which could explain this flickering text maybe...

I will include all of the modules in my next build to see if it works better, thanks for the tip!
[ZenFone 2 Android Development] sorg:
I think, you've missed the point. I've said current TWRP graphics isn't optimized for ALL platforms (besides very specific Qualcomm overlay which i had no chance to try). Nothing to do with x86. Even on ARM device it's very slow. In several years of TWRP existence, i didn't see any progress in GUI, so i don't hope it will be changed anytime soon.

From other side, Aroma File Manager uses NEON(which can be translated to SSE) optimization making interface very fast. Thus, you don't need any special compiler. But due to very different internal GUI engines, it's hard to port TWRP to Aroma GUI. Using 3rd party compiler give you other problems if you try to compile something requiring Android NDK.

Anyway, let me know if your approach with different compiler will make rocket from snail TWRP GUI ;)
[ZenFone 2 Android Development] TheSSJ:
https://en.m.wikipedia.org/wiki/EGL_(API)

Thanks for testing :highfive:
[ZenFone 2 Android Development] taylor.fowler:
Typical needed to unplug from usb and give it a few, but then it loks like it's running fine. Creating a backup now...

Edit: backup/restore went A-OK
[ZenFone 2 Android Development] TheSSJ:
Thanks for the feedback...basically you're saying that it's still freezing sometimes? :(
[ZenFone 2 Android Development] ravian29:
going to try on my end and will report you back
[ZenFone 2 Android Development] fuzzybuffalo:
Hmmmmm...

The first two times worked flawlessly. I did not have to unhook USB cable, like I was before.

Restarted in between backups. Made 2 backups, played with settings and the file manager. Very smooth.

The next 3 times it hung at TEAMWIN splash screen. Gave it a couple of minutes and then long pressed power button to restart.

Finally rebooted computer and it worked again. Did an advanced wipe of Dalvik, system, and cache and then restored the backup.

Backup booted fine, so I ran the script again and it started TWRP fine, so I started another backup, which is running normally.

Will keep trying the script and see if it hangs again. Will let you know if it does. Might just be my comp.
[ZenFone 2 Android Development] taylor.fowler:
It did that blurry lines on the screen thing for like 60 secs before it loaded up twrp.
[ZenFone 2 Android Development] TheSSJ:
The blurry lines are normal ^^ would like to know what these distorted graphics are :silly:
[ZenFone 2 Android Development] fuzzybuffalo:
Well, you know its not the EGL. :laugh:
[ZenFone 2 Android Development] ravian29:
i tested it almost 20 times without unhooking cable, it hanged twice only on twrp recovery splash screen but once i am in recovery, backing up, restoring, flashing works flawlessly. The bugs i found are hanging up on the splash screen ( this happens only coming from bootloader / fastboot to recovery, adb worked perfectly) and vibration does not work. Restoring cache took 245 seconds to restore only 4mb, restoring system of 1844mb took 122 seconds and wiping took more time than restoring

second attempt went smooth, no more waiting in wiping system and restoring is normal

thanks mate for your amazing work, In my opinion you should release untethered beta 1 for unlocked bootloaders
[ZenFone 2 Android Development] taylor.fowler:
Outside of that normalcy, then, I didnt have any distorted graphics navigating through menus and whatnot.

Drop that .img already :D
[ZenFone 2 Android Development] TheSSJ:
Gee, you guys are impatient :D

I will unlock my phone myself and try it out first

/Edit: First test leaded to stuck at splashscreen - will try some more with other builds
[ZenFone 2 Android Development] taylor.fowler:
Hah, it's all good man. Take your time, and thanks for your work :good:
[ZenFone 2 Android Development] jrior001:
I have some twrp skills if you want some assistance, link me a tree and I can build/test.
[ZenFone 2 Android Development] TheSSJ:
So I tried to pack the whole bunch with many different methods (mkbootimg, abootimg from ubuntu repository, pack_intel tools) but the outcome is everytime the same - just hangs at ASUS splashscreen...

I need to investigate which exact arguments are needed in order to create a bootable recovery. When I compared the stock recovery with a stock one I repacked myself, I expected just the signatures to be missing, but there is a looooooot more - so my assumption is that packing such images could be a little trickier...

Going to sleep now, enough action for me :)
[ZenFone 2 Android Development] Techronico:
Edit: Deleted comment, I forgot about the separation of church and sta...I mean Dev Thread and Q&A Thread.
[ZenFone 2 Android Development] TheSSJ:
Source is linked on OP now, I just have difficulties in building the img-file even when using as much info from the original file as possible (base address, kernel address, etc. etc.)...dunno what I am doing wrong honestly
[ZenFone 2 Android Development] social-design-concepts:
Post the stock recovery image I'll look.

I think 2nd stage bootloader bootstub is needed like the nexus player has I would start their. Just checked the boot images I have for similar devices with the sl_vmm.bin and they all have the 2nd stage bootloader.

Add this to your board config :

# bootstub as 2nd bootloader

TARGET_BOOTLOADER_IS_2ND := true
[ZenFone 2 Android Development] TheSSJ:
Hi,

added it now and retried, still stuck at bootscreen :silly:

I have uploaded the stock recovery to my github

Cheers
[ZenFone 2 Android Development] social-design-concepts:
I'll take a look just wanna confirm you never get the twrp curtain just the asus splash screen?
[ZenFone 2 Android Development] TheSSJ:
corrrrrect, just ASUS - if I would have seen the curtain I'd been the happiest guy in this forum :D
[ZenFone 2 Android Development] social-design-concepts:
OK hopefully i can lend a hand Intel images suck
[ZenFone 2 Android Development] jrior001:
https://github.com/jrior001/device_asus_zenfone2

I made some changes based on building kernel from source and board changes based on fugu. I had to run before I could test it but it will build. Building kernel from source removes the issues w/repacking properly. Build system already handles packing for fugu.

Kernel source I've uploaded to https://github.com/cm-zenfone2 where we will be working on CM bringup for the near future.
[ZenFone 2 Android Development] 29y6145:
tks for share [MENTION=2836769]jrior001[/MENTION]
[ZenFone 2 Android Development] deadman96385:
Compiled it against the latest cm12 source and got pretty far but its missing firmware

make[3]: *** No rule to make target `firmware/dfw_sst.bin', needed by `firmware/dfw_sst.bin.gen.o'. Stop.

which looks like is supposed to be located in the kernel source but it isn't by these lines in the defconfig

CONFIG_FW_LOADER=y

CONFIG_FIRMWARE_IN_KERNEL=y

CONFIG_EXTRA_FIRMWARE="dfw_sst.bin"

CONFIG_EXTRA_FIRMWARE_DIR="firmware"
[ZenFone 2 Android Development] crpalmer:
Update the source and try again.
[ZenFone 2 Android Development] deadman96385:
With that i successfully compiled a recovery.img, i fastboot flashed it and booted to recovery and it just hangs on the splash screen

Compiled recovery img:

http://www.drdevs.com/devs/teamliquid/Test/recovery.img
[ZenFone 2 Android Development] TheSSJ:
Which splashscreen? Asus or TWRP?
[ZenFone 2 Android Development] deadman96385:
Asus sorry forgot to mention that
[ZenFone 2 Android Development] TheSSJ:
Same as me then :D I think I am on the right track though - I assume mkbootimg can't be used to pack the image. I am in the process to modify [MENTION=1813976]shakalaca[/MENTION] 's zenfone boot tools to match it with the ZF2 bootheader (got pretty far). When I unpack and repack the stock image it works to boot from it, but when I replace the ramdisk with the TWRP it won't boot anymore.

Need to do some fixes and will report back.
[ZenFone 2 Android Development] crpalmer:
mkbootimg can unpack and repack the image. Make sure you are using the latest from:

https://github.com/xiaolu/mkbootimg_tools.git

I can unpack and repack stock images. It needs to be the latest because I added second stage bootloader support to it not too long ago (since I bought my zenfone2).
[ZenFone 2 Android Development] TheSSJ:
Hi,

indeed, this seems to work with the stock image too. When replacing the ramdisk it's stuck again at ASUS splash...I am really out of options now...
[ZenFone 2 Android Development] crpalmer:
Selinux problems?
[ZenFone 2 Android Development] TheSSJ:
Can't possibly imagine that it's Selinux related - it doesn't work when Selinux is set to false also :D

If the repacked stock is able to boot, we can exclude now the building process. It's so difficult to debug without any interface to the booting process.......
[ZenFone 2 Android Development] vampirefo:
Have you guys disabled encryption?

I saw nothing special about your stock recovery simply unpack and repack, unless you guys are trying to flash on an encrypted tablet, then I doubt it would boot just freeze.
[ZenFone 2 Android Development] TheSSJ:
Afaik the phones are not encrypted, can be mistaken of course.

Maybe i know what could be missing: can someone of you insmod tngdisp.ko...maybe the recovery is just missing a/some kernel module/s (when I did an lsmod with the tethered twrp I saw this specific module loaded...), could be worth a try!

I will be able to do so tomorrow as it's 1:00 AM here ^^

Find the module in the stock recovery img
[ZenFone 2 Android Development] vampirefo:
Sounds good, can you or some else upload stock boot.img ?
[ZenFone 2 Android Development] fuzzybuffalo:
I'm assuming you want the 2.19 stock boot.img.

I would upload it, but I don't know the commands to pull it from the phone.

It is not posted anywhere that I know of.
[ZenFone 2 Android Development] vampirefo:
It's ok I got the info I was looking for.

---------- Post added at 07:15 PM ---------- Previous post was at 07:06 PM ----------

Hi, I just downloaded your recovery.img this isn't close to being bootable, When you guys repack use stock recovery, as a base then add twrp files to it.

You are missing to many important files, plus you have boot cmdline not recovery.

This is what I would use to pack the recovery.

./mkbootimg --kernel ./recovery.img-zImage --ramdisk ./recovery.img-ramdisk.gz --cmdline 'init=/init pci=noearly loglevel=0 vmalloc=256M androidboot.hardware=mofd_v1 watchdog.watchdog_thresh=60 androidboot.spid=xxxx:xxxx:xxxx:xxxx:xxxx:xxxx androidboot.serialno=01234567890123456789 snd_pcm.maximum_substreams=8 ip=50.0.0.2:50.0.0.1::255.255.255.0::usb0:on debug_locks=0 n_gsm.mux_base_conf="ttyACM0,0 ttyXMM0,1" bootboost=1' --base 10000000 --pagesize 2048 --output ./test_recovery.img

You need to add and replace these files from stock recovery.img

twres

res

etc

sbin "you need to keep stock adbd, as the one that is built for twrp during compile wont work"

You need to edit these two files, then repack, to enable adb

default.prop

init.rc

all you are doing is upacking stock recovery, replace some folders and some files from twrp and repack, then you have a complete working twrp, built off of stock recovery.img
[ZenFone 2 Android Development] jrior001:
I've got unpack/repack working so that should be simple enough to handle

Edit: got an image that boots, needs graphics and fstab issues solved before i can release. Still working....

Edit2: Got IMG that boots, no adb and won't mount /data. That's it for today, more work on it tommorrow
[ZenFone 2 Android Development] vampirefo:
Look at your stock recovery fstab and make changes as needed.
[ZenFone 2 Android Development] iqbal_mahmuda:
Can I use it for rooting the zf2 with this recovery and the official flashable zip supersu ? I use latest ota update. I don't want lose my guarantee. When the phone is unrooted, can i have my guarantee back? I don't want to reflash my zf2, the rom file is too big for me :(
[ZenFone 2 Android Development] TheSSJ:
Got mine booting, too, finally - as you said - we had to use the stock recovery as base, thanks [MENTION=2472806]vampirefo[/MENTION]

EDIT: Current status is, that the recovery gets a permission denied when trying to mount /data and subsequently the internal sd card (as it's located on data/media). So the fstab itself is okay, there is something else under the hood to be changed. Also the reboot commands to do not work :D selecting any option yields in restarting TWRP. You have to turn off using the power button and then start the phone...At least it can mount a MicroSD if available
[ZenFone 2 Android Development] crpalmer:
I just pushed a few kernel commits that make it so that you don't need any modules to boot. I am currently booting my own kernel (with no modules installed) with the stock ROM to test it. That should be sufficient for building twrp.
[ZenFone 2 Android Development] TheSSJ:
Sounds nice :)

When the TWRP is ready for publishing I would like to include your kernel :)

Current progress: ADB works when system is mounted (unfortunately it looks for sh in /system/bin even if /sbin is set as first path. Unfortunately I have no root privileges with adb at the moment, so that I cannot check what's wrong with data, but I'm getting there. I think simple changes to default.prop are needed to get root privileges

/EDIT: By the way, to anyone else trying to build twrp, you might want to change the following in

init.rc

Line 10 add the following: setenforce 0

init.recovery.mofd_v1.rc:

Line 30: change 8087 to 18D1

Line 31: change 0A5D to D001
[ZenFone 2 Android Development] knoneNull:
check fstab add the encryptable if ever in twrp.fstab

try to run on permissive mode in twrp find old zenfone 2 ramdisk from recovery.img to run permissive on recovery if you can build a kernel together with twrp add permissive mode on kernel and enable on init.rc
[ZenFone 2 Android Development] TheSSJ:
If you mean i should add a flag to the data partition (length=-16384) and add setenforce 0, I did it,but it still says permission denied for mounting data (also sbin is not accessible,permission denied :-[ )

Adb works,but can't get it to become root...

Gee, I am struggling Oo
[ZenFone 2 Android Development] jrior001:
I got data mount but still have all the other issues.
[ZenFone 2 Android Development] TheSSJ:
What did you do to have it working?
[ZenFone 2 Android Development] jrior001:
use this in the recovery.fstab for the data line

/data ext4 /dev/block/by-name/data flags=encryptable=/factory/userdata_footer
[ZenFone 2 Android Development] TheSSJ:
If you want adb, just take the binary from stock recovery and put it into sbin...shell will work when system is mounted (dunno why,but there is no adb binary compiled when my build is completed :/)

Edit: by the way, the only modules needed in lib/modules are tngdisp and texfat

There are only small issues left now,let's get them fixed :)
[ZenFone 2 Android Development] social-design-concepts:
When I get home i'll post a patch for adbd so you can add it to init.rc so adbd points to /sbin/sh instead of /system/bin/sh

Then use the adbd binary from tethered recovery and adding a couple of lines to default.prop should fix the adbd issues.
[ZenFone 2 Android Development] TheSSJ:
As sbin is not accessible (permission denied) shell won't work unfortunately, as I patched adb for testing already..

Why is sbin not accessible? :confused:
[ZenFone 2 Android Development] social-design-concepts:
/sbin is only accessible as root

add these to the deafult.prop

ro.adb.secure=0
ro.debuggable=1
ro.secure=0
persist.sys.root_access=true

View attachment 3372555 Be sure thee patch is ran in init.rc before the adbd service is started use the adbd binary from the tethered recovery as it has root support the only thing the patch does is change the pointer from /system/bin/sh to /sbin/sh

personally i recommend adding logcat to /sbin too