yashsingh1/xdaforums huggingface dataset:
[Huawei Ascend Mate 2] tomlogan1:
Following the above process but changing to installing boot from a previous 320 backup achieved the same results. It looks like the only way back is to revert to JB and build back to 318 and stay there.
[Huawei Ascend Mate 2] :
I'm sorry to hear this. I am pretty confident the goal you aim for can be achieved but I do not have this device so I can not play around with it.
[Huawei Ascend Mate 2] :
[MENTION=668326]tomlogan1[/MENTION] please send me your boot.img. There is something I want to look at. Something that I believe by modifying I can prevent TWRP from being overwritten.
[Huawei Ascend Mate 2] :
Well was hoping for a response by now lol. So, anyone else who is having troubles with TWRP being replaced by the stock recovery, could you send me your boot.img.

[MENTION=6755755]Davinci50[/MENTION], if you are currently on the same Rom that is overwriting TWRP with the stock recovery then can you send me your boot.img?
[Huawei Ascend Mate 2] tomlogan1:
How do I send the boot.img?
[Huawei Ascend Mate 2] :
Don't worry about it. I already got it. Thanks though.

---------- Post added at 02:36 PM ---------- Previous post was at 02:26 PM ----------

[MENTION=668326]tomlogan1[/MENTION], is your device rooted while trying to get TWRP to stick?
[Huawei Ascend Mate 2] tomlogan1:
Yes rooted. Thought of doing a complete reload of 320 then getting the 321 update then trying TWRP for recovery and root, but wasn't sure if that would improve anything.
[Huawei Ascend Mate 2] Davinci50:
[MENTION=668326]tomlogan1[/MENTION] did you try to update to b 321 while still rooted by any chance?

I was going to go all the way back to JB and start over, when I have the time. LMk if b320 does the trick. I have the file if you need it for sd card.
[Huawei Ascend Mate 2] tomlogan1:
Was rooted on 320 and could not take the 321 upgrade. Had to do a fresh install of 320 then upgrade. Rooted 321 but cannot get TWRP to stick
[Huawei Ascend Mate 2] :
TWRP can't patch your system to prevent TWRP from being overwritten. TWRP looks for /system/recovery-from-boot.p and renames it to /system/recovery-from-boot.bak. This path doesn't exist on the device. So either Huawei located it elsewhere or they are going about it with the same logic but different method. Ramdisk isn't showing any hints. Closest I see in the ramdisk is starting up install-recovery.sh. At best, you could remove that part from init.rc then repack the boot.img and flash. Afterwards, flash twrp and see if TWRP sticks. If it does then that is your culprit. However, I feel as though that isn't it simply because SuperSU takes over that file. Since I do not have the device you guys need to do some digging.

---------- Post added at 05:38 PM ---------- Previous post was at 05:26 PM ----------

Also, when I unpacked the boot.img it showed the kernel cmdline using, androidboot.selinux=enforcing.

If you change enforcing to permissive that too may or may not resolve any issues you experience on the preview Rom.
[Huawei Ascend Mate 2] :
[MENTION=668326]tomlogan1[/MENTION], [MENTION=6755755]Davinci50[/MENTION],

Does /system/etc/install-recovery-2.sh exist on your device?

Need to know if contents are identical inside both files as shown below:

/system/etc/install-recovery.sh

/system/bin/install-recovery.sh
[Huawei Ascend Mate 2] Davinci50:
https://drive.google.com/file/d/0BzGnKi7IAOqUcGdGc2NISVdmc2s/view?usp=sharing

https://drive.google.com/file/d/0BzGnKi7IAOqUMmdCWk9TRDloNkE/view?usp=sharing

I think they are the same.
[Huawei Ascend Mate 2] :
Ok, [MENTION=668326]tomlogan1[/MENTION] or [MENTION=6755755]Davinci50[/MENTION]

Either one will do, but I need only one of you to boot up TWRP even if that means flashing it to your boot partition and make a backup of your system partition. Then I need you to upload that system backup and send me the link to download it. I am about to get knees deep in this mess :).
[Huawei Ascend Mate 2] Moody66:
Ya goes back to what I said earlier. Huawei has made changes. This is what is causing a lot of people issues now I think. Ill rip into the spare and post.
[Huawei Ascend Mate 2] tomlogan1:
Uhh how do I make a copy of the system partition when flashing TWRP to boot causes it to continue to boot to itself? Never claimed to know Linux but seems to be a recursive loop to me. Am game to try it with some guidance.

Thanks.
[Huawei Ascend Mate 2] :
Hmmm, ok. Create a random folder on your PC. Change directories to that folder on your PC. Insure adb is in your path. Plug device to computer, then type and enter:

adb pull /system

If done right it will dump your entire system onto your computer in that folder. Zip it all up and upload :)
[Huawei Ascend Mate 2] tomlogan1:
So If I flash TWRP to boot, do I reboot back to TWRP to get \system or do I just flash and pull?

---------- Post added at 06:50 PM ---------- Previous post was at 06:45 PM ----------

C:\sysdump>adb devices

List of devices attached

582af71e319e recovery

C:\sysdump>adb pull /system

pull: building file list...

0 files pulled. 0 files skipped.

---------- Post added at 06:54 PM ---------- Previous post was at 06:50 PM ----------

Had to do a reflash of system (from 321) to boot back to Android. Pulling that now and will have a txt of what displays on the console. Will send a pm for you to get it from dropbox.
[Huawei Ascend Mate 2] :
Don't really need the txt. Just all the files it pulled from your /system. When its done, just zip it all up. I have to review all the binaries to locate the culprit. An entire system dump will be needed.
[Huawei Ascend Mate 2] tomlogan1:
Please PM me so I can get you to dropbox. File will be huge. 1.5 GB raw.
[Huawei Ascend Mate 2] :
Will be playing a game of chess while I wait.
[Huawei Ascend Mate 2] tomlogan1:
885 MB is uploading at a snails pace to my google drive. how do I get it to you?
[Huawei Ascend Mate 2] :
[MENTION=668326]tomlogan1[/MENTION], It should offer you to share the link. See picture below for a simple example (I am using the Google Drive app):
[Huawei Ascend Mate 2] tomlogan1:
just like dropbox. will pm the link when done. gonna be a while till it finishes.
[Huawei Ascend Mate 2] Moody66:
Curious as to what you are looking for? Lol share your thought process with us. Something new?
[Huawei Ascend Mate 2] :
Most roms that restore the stock recovery on each boot implements a tactic where in the init.rc file it kick starts a shell script that applys a patch. This patch is the stock recovery. It's ran on each boot. However, after digging through the system dump provided to me I cannot find anything similiar to this method. I'm still digging deep though. Meanwhile, I am also looking into modifying the boot.img to kick start a personally made patch that is based on the diff of TWRP and the stock recovery. So that after booting when the stock recovery is restored, the personally made modification will kick in and restore TWRP. Just not sure how effective that will actually be. :-p
[Huawei Ascend Mate 2] Moody66:
Ahhhh. Makes sense. Wonder why huwaei made the changes with the new rom. I am thinking they are trying to prevent modifications so they can get reliable feedback. Dunno. Thanks for sharing that thought. Anything I can do let me Know.
[Huawei Ascend Mate 2] :
This mess has actually been around since ICS believe it or not lol. It was just never common to see. Since Lollipop it has become really popular for some reason. Typically, in the roms that do implement this, there is a file, /system/recovery-from-boot.p, that is used to patch the recovery partition on each boot. Huawei isn't using this though. I want to believe that there is some kind of emmc write protection going on here in relation to the kernel but I find that hard to believe since the bootloader is unlocked. Which gives me the reason to believe that what I am looking for is in fact in the system dump provided to me but with a different naming convention to better disguise it. More or less, a signature move from Huawei lol. These are just merely theories though at the moment. Still got to keep digging and I have been on the #twrp IRC channel discussing this mess with other Devs since Huawei is using a tactic that differs to what is seen in the Google source.
[Huawei Ascend Mate 2] Moody66:
Lol I am going to have to check into it now. Lol you have my curiosity going. This being the first time I have had a Huawei device. And only second L device. Got burned out on Android tampering year or so ago. Curiosity killed the cat. You sound addicted to it like me. My touchpads are not liking L. So not fun with them. If you find something please post about it. I wanna know if its L or Huawei.
[Huawei Ascend Mate 2] Davinci50:
[MENTION=6367467]SHM[/MENTION] The Man likes a good challange. Redid device to JB and backup to 321. Still cannot get Twrp to stick, but at least now I have the use of adb back.

Lmk if you need anything else.
[Huawei Ascend Mate 2] Kostyan_nsk:
If flash TWRP via fastboot and then boot into recovery without booting into system, there's stock recovery but not TWRP, am I right? If so, then system is not related anyhow for patching recovery image.

I think it's worth try to unlock bootloader again. On Kirin devices it's common that some new firmware version re-locks bootloader even though in fasboot mode it writes "Phone unlocked".
[Huawei Ascend Mate 2] Davinci50:
[MENTION=6152035]Kostyan_nsk[/MENTION] Just tried that Failed (already in unlocked state)
[Huawei Ascend Mate 2] Moody66:
Huawei doesn't relock bootloader. They even supply unlocking online. They would have no reason to relock it.
[Huawei Ascend Mate 2] Kostyan_nsk:
I'm not talking about state, it will be "Phone unlocked" anyway. Try to apply 'fastboo oem unlock' command with your unlock code again.

---------- Post added at 14:50 ---------- Previous post was at 14:49 ----------

You are mistaken.
[Huawei Ascend Mate 2] Moody66:
As stated. They are not relocked. As my daughters is not relocked.

[MENTION=6152035]Kostyan_nsk[/MENTION] Just tried that Failed (already in unlocked state)"

This means he did try unlocking again...... Not trying to sound snotty. I have a spare to play with. I too had already thought of that as well. It's not the issue here. It was am issue when L cane outto get twrp installed. Took some people several tries to get it to stick.
[Huawei Ascend Mate 2] Davinci50:
I did that was the result that it said "Failed" already in an unlocked state
[Huawei Ascend Mate 2] Moody66:
https://community.gethuawei.com/developers/f/48/t/1048

---------- Post added at 03:20 AM ---------- Previous post was at 03:18 AM ----------

Same thing for me. Obviously not the problem. Checked on two phones.
[Huawei Ascend Mate 2] :
[MENTION=6152035]Kostyan_nsk[/MENTION] did bring up something that I do need verified since I do not recall getting a complete answer on this previously.

Someone do the following:

fastboot flash recovery twrp.img

Do not reboot; but now do:

fastboot boot twrp.img

Do you see twrp? Is twrp functional?
[Huawei Ascend Mate 2] tomlogan1:
Works like it should following the above process.. If you are in TWRP and select boot to recovery you end up in EMUI.
[Huawei Ascend Mate 2] :
This sounds kernel related.

---------- Post added at 11:20 AM ---------- Previous post was at 11:11 AM ----------

[MENTION=668326]tomlogan1[/MENTION] can you send me the stock recovery?
[Huawei Ascend Mate 2] tomlogan1:
Happy to send, but don't know how to retrieve it. I have a few backups for 321 from TWRP. Unzip them?
[Huawei Ascend Mate 2] :
On phone in android terminal type and enter:

su

Then type and enter:

dd if=/dev/block/platform/msm_sdcc.1/by-name/recovery of=/sdcard/stockrecovery.img

This will pull it from your partition and store it on your sdcard and name it stockrecovery.img. Upload on Google Drive good sir :).

Want to unpack it and verify the offsets, kernel command-line and other additional files in the ramdisk. For clues and to compare against the device tree used to build twrp.
[Huawei Ascend Mate 2] tomlogan1:
Ran the command and it dumped 600k somewhere I can't find. Will find later today and upload. Gotta to to work.
[Huawei Ascend Mate 2] :
600k is way too small. Should be more like 60 mb give or take due to the padding. Make sure a typo isn't made when using the command, and check the root of your internal sdcard. You should find it there named, stockrecovery.img.
[Huawei Ascend Mate 2] tomlogan1:
https://drive.google.com/file/d/0Byzj0voY5a-8b2RCMHZSYnJwelU/view?usp=sharing
[Huawei Ascend Mate 2] :
Just unpacked it. You sent me the TWRP recovery :-p
[Huawei Ascend Mate 2] tomlogan1:
Used your command as written. TWRP manager shows TWRP as being installed!
[Huawei Ascend Mate 2] :
Oh Huawei and your sneakiness lol. TWRP is definitely installed on your device. That is confirmed after having you dump the recovery partition and me reviewing that dump lol. Something is masking it though. This is something I have not seen before. Will talk with some devs about this and brainstorm.

---------- Post added at 01:54 PM ---------- Previous post was at 01:52 PM ----------

Meanwhile, get on that test group page and speak with some Huawei employees and see if they can provide some insight on this matter. They should since Huawei is supposedly Dev friendly.
[Huawei Ascend Mate 2] Davinci50:
I was trying to say that I tried that method above and every concievable way to boot recovery and landed in EMUI every time.

Thanks for your dedication to the cause.
[Huawei Ascend Mate 2] foltz61:
Nandroid manager sees TWRP as being installed too.
[Huawei Ascend Mate 2] tomlogan1:
AS I have already demonstrated I don't know Linux or Unix for that matter, it seems like in the boot process, Huawei is calling ( your choice, subroutine, batch file etc.) to circumvent recovery. When I run the TWRP manager it shows I have TWRP installed, but EMUI is what survives reboots. If I disect one of my TWRP backups would that help? And by the way, the lock came from the 321 OTA. 320 could live with TWRP.
[Huawei Ascend Mate 2] xordos:
Thanks [MENTION=6367467]SHM[/MENTION] and others that is helping our Mate2 users even without the phone.

I feel bad that didn't do anything, so today, I re-upgraded my downgraded-from-B320-to-B309 phone to B320, then to B321, and re-produced the exact same problem.

Basically, the recovery partition is indeed twrp, but it always boot into EMUI stock recovery.

So, I dump all partitions ( don't laugh at me ), and grep keyword on all the partition, and found out the problem:

root@hwMT2L03:/ # ls -l /firmware/image/update*

ls -l /firmware/image/update*

-r--r----- system system 38337960 2008-08-01 12:00 updatex.appx

Above file is already renamed, its oringnal name is update.app.

So, after root the phone first ( fastboot boot twrp.img; install SU.zip inside twrp), then rename above file, then twrp will stick.

Cheers, :)

xordos.

PS. I have attached the one SU.zip, which I am using right now, but it maynot be the latest version. Directly install the zip inside twrp.
[Huawei Ascend Mate 2] :
I want to buy you a beer lol

---------- Post added at 03:15 AM ---------- Previous post was at 03:08 AM ----------

[MENTION=3266877]xordos[/MENTION], what is the size of that update.app file? Could you send it to me? I want to poke around. :)
[Huawei Ascend Mate 2] xordos:
We should thank you for your help and support all the time.

The file is 37MB, and is inside the B321 upgrade package which is ~37MB after zip, so I have upload the whole upgrade package to google drive.

http://tinyurl.com/qzxkm4x

The upgrade package is under the B321 folder.

The update.app is located inside upgrade_sign.zip:/firmware/image/.

37970392 Aug 17 20:09 update_sign_B321.zip

897aa1e41fb0bb3dc16536f8152e38f2 update_sign_B321.zip

Let me know if you need anything else.

P.S., Just uploaded stock boot and recovery images to above google drive, HTH. :)
[Huawei Ascend Mate 2] :
Awesome, and I also wish to show a little trick you can do ;)

If you want TWRP to look for /firmware/media/update.app and rename it automatically so that when you reboot the TWRP recovery will stick then unpack the TWRP recovery image and look inside the /sbin directory within the ramdisk. You will see a binary called, recovery. Open it with a hex editor and use the below pictures as a mirror to modify. Once done, save the changes and repack the TWRP recovery. When you flash and boot up the modified TWRP recovery it will find the file and rename it automatically for you so that when you reboot TWRP will still be there.

This method will be much easier than modifying the TWRP source and making a new TWRP build lol. Currently the TWRP source only looks for /system/recovery-from-boot.p which does not exist on this device. Try it out on your end :D

BEFORE:

AFTER:

Notice how I can do this on my own device - yea, it is that easy :).
[Huawei Ascend Mate 2] xordos:
Lol, yeah, that should work, but to be honest, no, I won't mod the twrp that way. TWRP is kinds of the most critical tools that I always treat very gentle/carefully. :D
[Huawei Ascend Mate 2] Moody66:
LOL Slick Huawei...
[Huawei Ascend Mate 2] Kostyan_nsk:
There's no need to mod recovery binary, actually. You can just repack twrp image adding /sbin/postrecoveryboot.sh script for mount system partition and rename needed file. For example:

#!/sbin/sh
/sbin/mount -t ext4 -o rw /dev/block/platform/msm_sdcc.1/by-name/system /system
/sbin/mv -f /system/firmware/image/update.app /system/firmware/image/update.appx

After TWRP will start, it will execute this script (if I'm not mistaking).

There is only need to find out where /firmware located actually. Is it symlinked directory in system partition or is it mounted from separate partition?
[Huawei Ascend Mate 2] _that:
Your replacement text has a different length - have you ever actually tested this?
[Huawei Ascend Mate 2] :
Correct, as long as the bytes changed are equal to or less then it is fine.

Edit: If the modified string is longer in length than the original string then it will fail. As stated, new string must be equal in length or less than the original string. :)
[Huawei Ascend Mate 2] xordos:
/firmware is partition p11, aka 'modem' partition. And it is vfat, following is the OS mount with options, guess that make the file name lowercase.

/dev/block/platform/msm_sdcc.1/by-name/modem /firmware vfat ro,context=u:object_r:firmware_file:s0,relatime,uid=1000,gid=1000,fmask=0337,dmask=0227,codepage=cp437,iocharset=iso8859-1,shortname=lower,errors=remount-ro 0 0

ps, I feel this file/mechanism is as early as in B148 update package, and we also get similar 'twrp cannot stick' at that time for some people. Now I don't know it is because Huawei fixed something to make it really work, or maybe less people is updateing to B321 and install twrp, all with bad luck and hit a bug.

Is anyone install twrp after b321 update, and it just works fine?
[Huawei Ascend Mate 2] foltz61:
I was able to just rename the update.app from within L using Root Browser. Did reboot recovery and all was well.

[MENTION=3266877]xordos[/MENTION] that wasn't in response to you :). I was just saying that I fsstbooted TWRP as usual and installed supersu. Then installed TWRP .Booted in to system and used Root Browser to rename the file.
[Huawei Ascend Mate 2] MikeyLee:
Is this a flashable zip rather than Huawei's typical file?
[Huawei Ascend Mate 2] xordos:
It is huawei official b321 upgrade package found in internal storage under /HwOUC. It is meant to flashed with stoock recovery.

But when I am in b309 last night, I cannot see ota b320 or 321 update. Then I put b320 update package in the correct place, but stock recovery say cannot find update.zip. So I ended up restore my b320 backup, then i can see the b321 ota. After downloaded the ota 321 package but before reboot, I made a backup. Thats where that file come from.

What I am trying to say above, I am not sure how to flash the huawei update package offline.

Edit,

OK, now I remembered, in the settings - updater window, the bottom menu has a "local update" function that should do this. It instructs to put package under /dload, not sure if it will work for the package found under /HwOUC.
[Huawei Ascend Mate 2] MikeyLee:
So you eventually were able to update to 321 via OTA then is what you're saying?
[Huawei Ascend Mate 2] xordos:
yes. After I am on b320, the OTA 321 update installed fine.
[Huawei Ascend Mate 2] :
[MENTION=4878287]_that[/MENTION], I realized I rush this example and all the bytes that were extra I cutted out. That is a no go. The extras have to be filled in with 00. That's assuming the new string replacing the old string is smaller. If it's the same length then it will be good from that point. I was barely awake when I made the post lol :-p

But yes, it will work. You can test it out by duplicating your build.prop file and naming it build.prop.test. Make the changes so it looks for that file and renames it to build.prop.test.bak. I definitely can confirm this.

Also wanted to bring this up for the other viewers to since the "after" picture was incorrect. Cheers!
[Huawei Ascend Mate 2] Davinci50:
B320 Update

[MENTION=3266877]xordos[/MENTION] Just an FYI to you and all.

There is a copy of the B320 update on the Index that can be placed on Sd card and applied.

And once again Thanks to ALL parties for Working this Thru !!!
[Huawei Ascend Mate 2] _that:
This is correct. I've patched strings in several binaries in my life, and you must never ever change the length, or all pointers in the code to any following string or data structure will be wrong and it won't work. However for open source like TWRP I strongly prefer rebuilding from source. :)
[Huawei Ascend Mate 2] :
Most certainly :). But if taking a short cut this can be the way to do it ha!
[Huawei Ascend Mate 2] MikeyLee:
Since not a lot of people check the other sections, I thought I would share. http://xdaforums.com/ascend-mate2/o...e-2-mt2l03-t3181518/post62392364#post62392364
[Huawei Ascend Mate 2] Moody66:
Yep. CM for mate 2. And official CM being looked into now. Finally some real Android!
[Huawei Ascend Mate 2] superbass311:
my phone is saying

E: Unable to mount '/HWUserData'
[Huawei Ascend Mate 2] Moody66:
Maybe the newer twrp needs to be used. I know he listed the older one in his post. Perhaps not knowing of the issues? Try the new twrp maybe.
[Huawei Ascend Mate 2] superbass311:
im running 2.8.0.0 will try to update now..

---------- Post added at 04:19 PM ---------- Previous post was at 03:59 PM ----------

how do i put the stock recovery back on so i can update to the new TWRP? pic is my error message
[Huawei Ascend Mate 2] superbass311:
here is the pic

bump
[Huawei Ascend Mate 2] u-ra:
You misspelled recovery. Also, you don't need to flash custom recovery to then flash a different build of TWRP.

Just flash the one I linked in the thread.
[Huawei Ascend Mate 2] superbass311:
updating my twrp fixed the issue. Thanks
[Huawei Ascend Mate 2] Moody66:
Just to clarify. The first attempt you had something other than the twrp posted installed? And after using the one provided it worked fine?

---------- Post added at 05:38 PM ---------- Previous post was at 05:36 PM ----------

BTW we really should be posting all this in the thread where its posted to keep this one clear.
[Huawei Ascend Mate 2] j42lin:
I kinda wish they released 4.4 in the first place. It is a lot more stable than 5.0/5.1:crying:
[Huawei Ascend Mate 2] lifeinpictures:
Just when I was about to make the decision to sell my outdated HAM2 and get an M9, I come across these news. Knowing Huawei's track record, first half of 2015 will likely be last week of June. Now I must debate if I can live with this ancient and frustrating software for another 3 months.
[Huawei Ascend Mate 2] ScoobSTi:
Don't forget we have CM11/12 on the way. It is on hold for now, but it is being/has been worked on. If you don't want Huawei's version of Lollipop you can wait for CM.
[Huawei Ascend Mate 2] p51d007:
MT2-L03, not on the list?

Personally, I don't care if it does get 5.x, but there are those that do.

Screen grab from another site. I don't see the L03 listed.
[Huawei Ascend Mate 2] 4L0M:
I very much doubt they would list the MT2-L03 with the others as it's not for sale in Asia and wouldn't work on any Asian networks anyway. I wouldn't read anything into that.