Author Topic: Unofficial TWRP build  (Read 2446 times)

Ninji

  • Newbie
  • *
  • Posts: 32
    • View Profile
Unofficial TWRP build
« on: December 14, 2019, 02:18:50 pm »
Hey folks,

I've been experimenting over the past few days with trying to compile TWRP for the Cosmo so I can mess around with updates a bit more easily. Ultimately this may be a bit of a fruitless endeavour if Planet ends up releasing their own, but perhaps this will be useful for some reason or other anyway?

Source code on GitHub: https://github.com/Treeki/unofficial-twrp-cosmo
Initial flashable release: https://github.com/Treeki/unofficial-twrp-cosmo/releases

This is a fairly standard TWRP port with one exception - the Cosmo's userdata partition is encrypted, and getting TWRP to decrypt it is an adventure. I finally got it working after importing a bunch of blobs from Planet's vendor partition so that TWRP can start up the TrustKernel TEE, obtain the correct key and decrypt everything.

I've confirmed that the following features work on my Cosmo:
- Flashing partition images
- Creating backups
- adb while in recovery mode

Android hackery is still a very new thing for me and there's probably ways I could have made this better, but I did what I could with my lack of skills.

Unfortunately the Planet OTA doesn't seem to be flashable from TWRP - it complains about the build fingerprint being different, and even after commenting out that check in the updater script it fails to update the system partition. I think I may have to resort to manually flashing the updated partitions one-by-one.

TheProfessorNQ

  • Newbie
  • *
  • Posts: 15
    • View Profile
Unofficial TWRP build
« Reply #1 on: December 14, 2019, 06:33:49 pm »
Ninji - Great work! I flashed your TWRP (I couldn't possibly make my current situation any worse, so why not?). Finally able to escape my eternal boot loop! Still cant boot android up, but it's a hell of a start! Certainly strange - the fingerprint issue. There is no build.prop under /system, though there is one under /sytem/system that has the OTA's expected fingerprint. I think I'm still stuck waiting for Planet to release full ROMs, but now I have confidence my device will be able to work again!!

Ninji

  • Newbie
  • *
  • Posts: 32
    • View Profile
Unofficial TWRP build
« Reply #2 on: December 14, 2019, 07:30:28 pm »
Quote from: TheProfessorNQ
Ninji - Great work! I flashed your TWRP (I couldn't possibly make my current situation any worse, so why not?). Finally able to escape my eternal boot loop! Still cant boot android up, but it's a hell of a start! Certainly strange - the fingerprint issue. There is no build.prop under /system, though there is one under /sytem/system that has the OTA's expected fingerprint. I think I'm still stuck waiting for Planet to release full ROMs, but now I have confidence my device will be able to work again!!
Yes, that's normal because of the way the Cosmo's ROM is laid out. It's a system-as-root configuration, so under Android, the system partition is mounted at /, but in recovery it's mounted at /system (as the recovery OS requires its own rootfs). Hence, what maps to /system in Android ends up being /system/system inside TWRP.

Regarding your issues: I've seen in the rooting thread that you've tried reflashing preloader and boot with no success. Have you tried flashing lk as well? You can get a known-good lk image from Planet themselves out of the OTA zip. From my understanding, lk is the component that fits into the boot sequence between the preloader and boot, so it may be worth a shot.

I'm also curious, does my TWRP build successfully decrypt /data for you? This was a massive pain to get working, but if it works, then this suggests that your userdata, metadata (stores the encryption keys for userdata) and tee (TrustZone OS) partitions are all in a good state.

I'm uploading the images I used for the update and I'll post a link in the rooting thread once I get that sorted out.

TheProfessorNQ

  • Newbie
  • *
  • Posts: 15
    • View Profile
Unofficial TWRP build
« Reply #3 on: December 14, 2019, 08:24:03 pm »
Quote from: Ninji
Yes, that's normal because of the way the Cosmo's ROM is laid out. It's a system-as-root configuration, so under Android, the system partition is mounted at /, but in recovery it's mounted at /system (as the recovery OS requires its own rootfs). Hence, what maps to /system in Android ends up being /system/system inside TWRP.

Regarding your issues: I've seen in the rooting thread that you've tried reflashing preloader and boot with no success. Have you tried flashing lk as well? You can get a known-good lk image from Planet themselves out of the OTA zip. From my understanding, lk is the component that fits into the boot sequence between the preloader and boot, so it may be worth a shot.

I'm also curious, does my TWRP build successfully decrypt /data for you? This was a massive pain to get working, but if it works, then this suggests that your userdata, metadata (stores the encryption keys for userdata) and tee (TrustZone OS) partitions are all in a good state.

I'm uploading the images I used for the update and I'll post a link in the rooting thread once I get that sorted out.


Thank you so much! Yeah, I've tried the lk as well. All img files from he OTA zip, actually. It certainly seems that /data is being decrypted successfully. I haven't tried pulling any of the files with ADB, but I would think if file and folder names are looking right, that the decryption is working.

Just finished downloading your images. Gonna give it a whirl!


Thanks!!
-Prof

AP756

  • Newbie
  • *
  • Posts: 30
    • View Profile
Unofficial TWRP build
« Reply #4 on: December 17, 2019, 06:34:21 am »
Ninji, wanted to inform you about successfully using your TWRP. Thank you for doing this great work which greatly improved usability of my Cosmo. For all others: My Cosmo is allready rooted, I downloaded all boot images from here and I installed "Official TWRP App" from Playstore. Now I can change my recovery and the boot images on the fly without the need of a computer to flash. This is absolutely great. Exception: If you flashed back your Cosmo to unrooted boot.img you have to use SP flash tools on your PC to get the root back (I am not aware of any other way, as far as I know flash programs on any Android device need root)

Bye for now  Fred
« Last Edit: December 17, 2019, 08:23:40 am by AP756 »

TauPan

  • Newbie
  • *
  • Posts: 36
    • View Profile
    • http://
Unofficial TWRP build
« Reply #5 on: December 19, 2019, 04:00:13 pm »
Quote from: AP756
Ninji, wanted to inform you about successfully using your TWRP. Thank you for doing this great work which greatly improved usability of my Cosmo. For all others: My Cosmo is allready rooted, I downloaded all boot images from here and I installed "Official TWRP App" from Playstore. Now I can change my recovery and the boot images on the fly without the need of a computer to flash. This is absolutely great. Exception: If you flashed back your Cosmo to unrooted boot.img you have to use SP flash tools on your PC to get the root back (I am not aware of any other way, as far as I know flash programs on any Android device need root)

Bye for now  Fred

You can simply boot into TWRP, choose INSTALL, tap on "flash image" on the right and choose the rooted boot image and then the "boot" partition (not boot2 or boot3 or any other partition). Should work without SP flash tool.

WARNING: This way you can brick your device just as easily as with SP flash tool, so be careful!

Noppe

  • Newbie
  • *
  • Posts: 22
    • View Profile
Unofficial TWRP build
« Reply #6 on: January 30, 2020, 01:29:28 pm »
Brand new member with a brand new Cosmo.  

I am a bit confused here, because my efforts to get TWRP to boot on the Cosmo are unsuccessful.

I first attempted a "fastboot boot twrp.img" (because I generally avoid overwriting stock recovery unless I need to) and fastboot thinks everything went fine, but the Cosmo goes black screen, vibrates, pauses about three seconds, vibrates again, and then boots Android.

Okay, so I decided to use fastboot to flash the image and used "fastboot flash recovery twrp.img", and once again fastboot thinks everything worked fine, but now when I boot into recovery, I'm getting stock recovery.

So, last thing I knew to try, I flashed the recovery partition using SP Flash Tool, which again appears to have gone fine, and yet I am still getting stock recovery on the Cosmo.

Any hints what might be happening here?

Ninji

  • Newbie
  • *
  • Posts: 32
    • View Profile
Unofficial TWRP build
« Reply #7 on: January 30, 2020, 03:48:57 pm »
Quote from: Noppe
Brand new member with a brand new Cosmo.  

I am a bit confused here, because my efforts to get TWRP to boot on the Cosmo are unsuccessful.

I first attempted a "fastboot boot twrp.img" (because I generally avoid overwriting stock recovery unless I need to) and fastboot thinks everything went fine, but the Cosmo goes black screen, vibrates, pauses about three seconds, vibrates again, and then boots Android.

Okay, so I decided to use fastboot to flash the image and used "fastboot flash recovery twrp.img", and once again fastboot thinks everything worked fine, but now when I boot into recovery, I'm getting stock recovery.

So, last thing I knew to try, I flashed the recovery partition using SP Flash Tool, which again appears to have gone fine, and yet I am still getting stock recovery on the Cosmo.

Any hints what might be happening here?
It's a bit tricky to get bootstrapped for a couple of reasons:
- in my experience, half the time the Cosmo ignores buttons and just decides to boot into normal Android anyway
- when booting into normal Android, the recovery partition automatically gets replaced by stock recovery*

So, you must flash it and then boot straight into recovery without starting up normal Android.

*: The caveat is that if the boot partition has been modified in any way (e.g. replaced with a rooted version), this replacement will not occur. So, if you flash a rooted boot.img (which you can do using fastboot or Flashtool) then it will not replace your recovery at all.

Noppe

  • Newbie
  • *
  • Posts: 22
    • View Profile
Unofficial TWRP build
« Reply #8 on: January 30, 2020, 04:33:39 pm »
Quote from: Ninji
- when booting into normal Android, the recovery partition automatically gets replaced by stock recovery*

So, you must flash it and then boot straight into recovery without starting up normal Android.

Aha, thank you!  That is what is happening here.  I've been booting into Android and then using adb to get back to recovery, because of exactly what you mention, about it being tough to get the device to react to the buttons.  So I've been nuking my TWRP every time.  

Quote
*: The caveat is that if the boot partition has been modified in any way (e.g. replaced with a rooted version), this replacement will not occur. So, if you flash a rooted boot.img (which you can do using fastboot or Flashtool) then it will not replace your recovery at all.

After giving up on TWRP, I've gone ahead and manually upgraded to V19 with the Magisk'ed boot.img, so I have solved my own problem there without realising it.  Hadn't yet gone back to test TWRP again, but I imagine it will work okay now.

Thanks much for the tip.  On the Android platform, I've been exclusively a OnePlus user for a number of years now, and a Lineage user on that hardware for the last couple, so I'm sure there are a few gotchas here and there on the Planet setup.  I will eventually run into all of them.  

cam1965

  • Sr. Member
  • ****
  • Posts: 264
    • View Profile
    • http://
Unofficial TWRP build
« Reply #9 on: February 14, 2020, 11:43:45 am »
Quote from: Ninji
Hey folks,

I've been experimenting over the past few days with trying to compile TWRP for the Cosmo so I can mess around with updates a bit more easily. Ultimately this may be a bit of a fruitless endeavour if Planet ends up releasing their own, but perhaps this will be useful for some reason or other anyway?

Source code on GitHub: https://github.com/Treeki/unofficial-twrp-cosmo
Initial flashable release: https://github.com/Treeki/unofficial-twrp-cosmo/releases

This is a fairly standard TWRP port with one exception - the Cosmo's userdata partition is encrypted, and getting TWRP to decrypt it is an adventure. I finally got it working after importing a bunch of blobs from Planet's vendor partition so that TWRP can start up the TrustKernel TEE, obtain the correct key and decrypt everything.

I've confirmed that the following features work on my Cosmo:
- Flashing partition images
- Creating backups
- adb while in recovery mode

Android hackery is still a very new thing for me and there's probably ways I could have made this better, but I did what I could with my lack of skills.

Unfortunately the Planet OTA doesn't seem to be flashable from TWRP - it complains about the build fingerprint being different, and even after commenting out that check in the updater script it fails to update the system partition. I think I may have to resort to manually flashing the updated partitions one-by-one.

Hi. I've installed twrp using the image provided by planet here ( http://support.planetcom.co.uk/download/co...taller-beta.zip ) in EMPTY_RECOVERY_BOOT_2 partition ( http://support.planetcom.co.uk/index.php/C...id_installation ).
But nothing happens when I boot to twrp.
I've also installed Debian in EMPTY_RECOVERY_BOOT_3 partition and debian boots fine.

What is the problem with twrp ?
I've also installed again twrp and the problem persists. I think the problem is because of Cosmo's userdata partition is encrypted. Mine is encrypted. Because mifritscher ( an user from this forum )  said in this post ( https://www.oesf.org/forum/index.php?showtopic=36119 ) that for him it is working... Despite having problems unlocking the user partition (he  didn't activated the encryption...). He used the the same file from  http://support.planetcom.co.uk/download/co...taller-beta.zip . He said  that it shows the TWRP logo for 1-2 minutes before giving up on decrypt the user partition.
Can I use your twrp image overwriting the planet image  after decompressing this zip file above ?
Thank you

cam1965

  • Sr. Member
  • ****
  • Posts: 264
    • View Profile
    • http://
Unofficial TWRP build
« Reply #10 on: February 14, 2020, 12:00:40 pm »
Quote from: cam1965
Quote from: Ninji
Hey folks,

I've been experimenting over the past few days with trying to compile TWRP for the Cosmo so I can mess around with updates a bit more easily. Ultimately this may be a bit of a fruitless endeavour if Planet ends up releasing their own, but perhaps this will be useful for some reason or other anyway?

Source code on GitHub: https://github.com/Treeki/unofficial-twrp-cosmo
Initial flashable release: https://github.com/Treeki/unofficial-twrp-cosmo/releases

This is a fairly standard TWRP port with one exception - the Cosmo's userdata partition is encrypted, and getting TWRP to decrypt it is an adventure. I finally got it working after importing a bunch of blobs from Planet's vendor partition so that TWRP can start up the TrustKernel TEE, obtain the correct key and decrypt everything.

I've confirmed that the following features work on my Cosmo:
- Flashing partition images
- Creating backups
- adb while in recovery mode

Android hackery is still a very new thing for me and there's probably ways I could have made this better, but I did what I could with my lack of skills.

Unfortunately the Planet OTA doesn't seem to be flashable from TWRP - it complains about the build fingerprint being different, and even after commenting out that check in the updater script it fails to update the system partition. I think I may have to resort to manually flashing the updated partitions one-by-one.

Hi. I've installed twrp using the image provided by planet here ( http://support.planetcom.co.uk/download/co...taller-beta.zip ) in EMPTY_RECOVERY_BOOT_2 partition ( http://support.planetcom.co.uk/index.php/C...id_installation ).
But nothing happens when I boot to twrp.
I've also installed Debian in EMPTY_RECOVERY_BOOT_3 partition and debian boots fine.

What is the problem with twrp ?
I've also installed again twrp and the problem persists. I think the problem is because of Cosmo's userdata partition is encrypted. Mine is encrypted. Because mifritscher ( an user from this forum )  said in this post ( https://www.oesf.org/forum/index.php?showtopic=36119 ) that for him it is working... Despite having problems unlocking the user partition (he  didn't activated the encryption...). He used the the same file from  http://support.planetcom.co.uk/download/co...taller-beta.zip . He said  that it shows the TWRP logo for 1-2 minutes before giving up on decrypt the user partition.
Can I use your twrp image overwriting the planet image  after decompressing this zip file above ?
Thank you

updated : installed as mentioned above and it worked ! ( Please see https://www.oesf.org/forum/index.php?showtopic=36119 )
Thank you again !
« Last Edit: February 14, 2020, 12:57:23 pm by cam1965 »

Varti

  • Administrator
  • Hero Member
  • *****
  • Posts: 1098
    • View Profile
Unofficial TWRP build
« Reply #11 on: June 17, 2020, 02:54:06 am »
[Note: this is a message from the user "spa", who has sent it to us mods while he was waiting for his account to be validated. I'm posting his question here for him. Varti]

I use Cosmo v21.
The backup and restore of userdata only was successful with this TWRP many times.
After backup and restore of boot, system and userdata with TWRP, I couldn't boot.
When you select normal android from the boot selection screen, you will be returned to the boot selection screen after the Planet screen is displayed.
When I select rooted android from the boot selection screen, the screen remains unchanged with the planet spinning.
Is there any way to recover it?

Spa
Planet Gemini PDA WiFi/LTE with Mediatek x27
SL-C1000 running Arch Linux ARM May2017, K30225 Wi-Fi CF Card, 64GB SDXC card
and many other Zauruses!

spa

  • Newbie
  • *
  • Posts: 10
    • View Profile
Unofficial TWRP build
« Reply #12 on: June 22, 2020, 08:14:45 am »
Quote from: Ninji
Hey folks,

I've been experimenting over the past few days with trying to compile TWRP for the Cosmo so I can mess around with updates a bit more easily. Ultimately this may be a bit of a fruitless endeavour if Planet ends up releasing their own, but perhaps this will be useful for some reason or other anyway?

Source code on GitHub: https://github.com/Treeki/unofficial-twrp-cosmo
Initial flashable release: https://github.com/Treeki/unofficial-twrp-cosmo/releases

This is a fairly standard TWRP port with one exception - the Cosmo's userdata partition is encrypted, and getting TWRP to decrypt it is an adventure. I finally got it working after importing a bunch of blobs from Planet's vendor partition so that TWRP can start up the TrustKernel TEE, obtain the correct key and decrypt everything.

I've confirmed that the following features work on my Cosmo:
- Flashing partition images
- Creating backups
- adb while in recovery mode

Android hackery is still a very new thing for me and there's probably ways I could have made this better, but I did what I could with my lack of skills.

Unfortunately the Planet OTA doesn't seem to be flashable from TWRP - it complains about the build fingerprint being different, and even after commenting out that check in the updater script it fails to update the system partition. I think I may have to resort to manually flashing the updated partitions one-by-one.

TWRP is no longer available on V22. It asks for a password. Will I be able to use it as before?

AP756

  • Newbie
  • *
  • Posts: 30
    • View Profile
Unofficial TWRP build
« Reply #13 on: June 22, 2020, 02:13:34 pm »
Quote from: spa
TWRP is no longer available on V22. It asks for a password. Will I be able to use it as before?

TWRP still works. It asks for a password to decrypt data (AFAIK is only possible using ADB). Just use <back> and you'll see TWRP - no data partition of course

cam1965

  • Sr. Member
  • ****
  • Posts: 264
    • View Profile
    • http://
Unofficial TWRP build
« Reply #14 on: June 22, 2020, 03:31:30 pm »
Quote from: AP756
Quote from: spa
TWRP is no longer available on V22. It asks for a password. Will I be able to use it as before?

TWRP still works. It asks for a password to decrypt data (AFAIK is only possible using ADB). Just use <back> and you'll see TWRP - no data partition of course

This is a task  for the ninja NINJI.
Please Ninji help us.
Thank you so much !