resident-nokia / android_device_nokia_NB1-TWRP

TWRP tree for Nokia 8 Stock
5 stars 2 forks source link

Nokia 8 Sirocco Test #1

Open Audioboxer opened 5 years ago

Audioboxer commented 5 years ago

Hi, Audioboxer from XDA.

Looking to test a Sirocco build if possible. Phone is unlocked.

Cheers

StollD commented 5 years ago

Download this file, and flash it to your active boot partition (fastboot flash boot): twrp-3.3.0-0-A1N.img

Please only do that if you know how to recover yourself from a bootlooping device (i.e. force shutdown and reflashing stock boot).

When the phone boots into Android with that image, reboot into recovery using adb reboot recovery.

Then please check if:

Audioboxer commented 5 years ago

Thanks, will be able to test within the hour.

Audioboxer commented 5 years ago

Flashed via fastboot flash boot twrp-3.3.0-0-A1N.img. Then rebooted. Got stuck on the unlocked bootloader message (Nokia warning about your bootloader being unlocked). Done a hard reboot and it passed that screen but is now stuck on the AndroidOne logo.

I'm on the April sec patch and I fully unrooted before doing the above. If it helps the April boot.img is here https://forum.xda-developers.com/showpost.php?p=79436079&postcount=55 (direct link https://mega.nz/#!XQ9ggIgC!YrYePjjTPHqmweQEgyQbjuRSd5HCG5Mrh5aN3N03laA).

May sec patch is now out, but I haven't upgraded to it yet.

edit: Fastboot flashing my April_stock_boot.img from above allows phone to boot again.

StollD commented 5 years ago

Thanks for trying and also for sending me that stock boot image! I made another build, this time using the kernel from that stock image instead of my own modified one. Maybe it works now: twrp-3.3.0-0-A1N-stock-kernel.img

Would be awesome if you could try that as well.

Audioboxer commented 5 years ago

No problem, unfortunately, it's still not booting and is getting stuck on the android one screen.

Also, unfortunately, I'm not a dev, so all I can think of is to point out the things that make the Sirocco different from the 8 that you'll already know lol (project treble/etc). The other obvious one being I think there is a difference between the Chinese model and the international model. Just to confirm, I bought this phone in Europe. It's a UK model.

It was unlocked by Hikari https://hikaricalyx.com/product/nokia-8-sirocco-bootloader-unlock/

StollD commented 5 years ago

When it comes to the Android One screen, does it crash (and reboot), or does it just stay there? Have you tried just waiting for something to happen? Is the device detected by adb? (So we might get logcats)

There is another thing we could try: booting directly into recovery from fastboot. After flashing the TWRP image you can enter fastboot oem HALT and fastboot oem shutdown. Then remove the USB cable, and press volume up while reconnecting the phone to the PC. (I am guessing and hoping the steps on sirocco are the same as on Nokia 8 though)

Audioboxer commented 5 years ago

Yeah I left it on the bootscreen for 5 minutes with the latest download above. It just hangs.

It doesn't seem like adb picks it up either.

My only way out is to get it to boot into download mode and then reflash the stock boot image. I've re-uploaded it just in case something is up with the mega link, but I doubt it

https://uploadfiles.io/hq0hmdct

OEM shutdown results in an error

fastboot oem shutdown FAILED (Write to device failed (Unknown error)) Finished. Total time: 5.010s

StollD commented 5 years ago

Then I have no idea how to solve that issue, sorry. But it seems weird to me that the system doesn't want to boot, given that it should be using the stock kernel (and not touch the recovery ramdisk that is included).

Audioboxer commented 5 years ago

Thanks for trying. I'll ask on the Nokia telegram if anyone else has any ideas. sjrmac might be able to help out.

Audioboxer commented 5 years ago

Some good news mate, with the help of Narender Singh, we managed to get your last file above booting. It also boots into TWRP, but freezes on the main screen.

Narender changed the OS level "I'm sending you a repacked twrp image from him. I only changed the os level to 2019-04 and the OS 9.0.0."

https://mega.nz/#!7NEg2CgJ!EcoxWD2fxL04H4-vPBkcNTdvGZ5dUzE4m20rnzUqai8

I'm assuming this is somewhat similar to how you used to have to supply a Nokia 8 TWRP every single month with the new sec patch in the past?

As for freezing on the TWRP screen, Narender suggests that is to do with encryption and I'm just in the process of wiping userdata and I'm going to attempt to boot directly into recovery with no userdata.

Audioboxer commented 5 years ago

More good news, TWRP booting fine with no userdata in place.

If userdata gets initiated then TWRP gets stuck on the initial splash screen. Narender suggests that is something to do with userdata decryption.

First proper boot of TWRP on a Sirocco though :D

Audioboxer commented 5 years ago

So I swiped right to allow TWRP to modify system, rebooted the phone, went through the initial setup process and enabled a lockscreen pin, then rebooted to recovery.

TWRP froze on splash screen again. So it definitely seems like encryption related.

realjack-1 commented 5 years ago

congratulations!

"If userdata gets initiated...." what does it mean?

singhnsk commented 5 years ago

That was just a wild guess on changing the OS level and version. But it somehow worked 🤞😂 I've seen this similar problem with stuck on splash screen even on devices which have official TWRP. Like Nokia 6.1 and 6.1 Plus. For some users (including the TWRP developers), it is working fine and decrypting. For other users, just hangs on the splash screen. Only a real dev can find out why, I wish I was one 😂

Audioboxer commented 5 years ago

congratulations!

"If userdata gets initiated...." what does it mean?

If you allow the phone to boot in any way.

To get the file I posted above to go past the TWRP flashscreen you have to boot into download mode, fastboot erase userdata, then reboot directly into TWRP. Do this on a Sirocco by having it plugged into the PC, hold the volume up key, then send the fastboot reboot command.

I'm not a dev but I think TWRP encryption/decryption issues can be fixed relatively easy once you know what is going wrong.

I'm going to pull the May security patch boot image shortly as well, the above is for April.

StollD commented 5 years ago

Awesome news! I never quite understood what that os level stuff meant so I never touched it.

Regarding your error: I got exactly the same error on NB1 when I compiled TWRP in an Android 9 tree (with both Android 9 and Android 8 blobs). It only worked when I used Android 8 blobs together with an Android 8 build environment.

Now what could have happened is that those binary blobs saw that the OS level is set to Android 9 and changed their behaviour so that decryption fails just as if you would boot a TWRP that was built in an Android 9 tree.

The solution might be to find an Android 8 os version level that allows the image to boot on sirocco. But that is just guessing, I don't know how those blobs work internally.

P.S: out of curiosity, did you modified the image with the stock kernel, or the image with umbrella @singhnsk? It doesn't matter regarding the main issue, but I am interested if umbrella actually works fine on sirocco.

singhnsk commented 5 years ago

@StollD How about if we leave the OS version to 8.1.0 and only change the OS level to the current security patch? That's April.

Edit: I made no other changes. I really don't have much idea. Just leading. I'll read into what Umbrella is and maybe try to incorporate 😳

Audioboxer commented 5 years ago

Awesome news! I never quite understood what that os level stuff meant so I never touched it.

Regarding your error: I got exactly the same error on NB1 when I compiled TWRP in an Android 9 tree (with both Android 9 and Android 8 blobs). It only worked when I used Android 8 blobs together with an Android 8 build environment.

Now what could have happened is that those binary blobs saw that the OS level is set to Android 9 and changed their behaviour so that decryption fails just as if you would boot a TWRP that was built in an Android 9 tree.

The solution might be to find an Android 8 os version level that allows the image to boot on sirocco. But that is just guessing, I don't know how those blobs work internally.

P.S: out of curiosity, did you modified the image with the stock kernel, or the image with umbrella @singhnsk? It doesn't matter regarding the main issue, but I am interested if umbrella actually works fine on sirocco.

He modified the one with stock boot. I could try the umbrella one if yourself or @singhnsk can modify it.

Right now our main issue is the TWRP freeze after userdata is initiated. Even with no userdata initiated and TWRP booted there are more issues. Some screenshots. Internal storage is reading as 0mb and backup cannot work

https://i.imgur.com/9ZzzpFE.jpg https://i.imgur.com/hUFbyIH.jpg https://i.imgur.com/T6DBr2L.jpg

I'm guessing that is probably related to encryption issues as well?? Or is the above because the phone hasn't been able to boot and initiate userdata?

StollD commented 5 years ago

@StollD How about if we leave the OS version to 8.1.0 and only change the OS level to the current security patch? That's April.

Thats probably worth trying out.

Edit: I made no other changes. I really don't have much idea. Just leading. I'll read into what Umbrella is and maybe try to incorporate flushed

Don't worry. Lets get it to work with stock first, then we can look into umbrella (that will be needed for generic images that work with every security patch without breaking wifi)

Audioboxer commented 5 years ago

@StollD How about if we leave the OS version to 8.1.0 and only change the OS level to the current security patch? That's April.

Thats probably worth trying out.

Edit: I made no other changes. I really don't have much idea. Just leading. I'll read into what Umbrella is and maybe try to incorporate flushed

Don't worry. Lets get it to work with stock first, then we can look into umbrella (that will be needed for generic images that work with every security patch without breaking wifi)

Yeah, we're going to try leaving the OS version at 8.1.0 when Narender has time to modify the boot image for me later today. Sadly I don't know how.

In the meantime here is the May stock boot https://mega.nz/#!uZFzXYqZ!g4yyZGJcPek41TIg0CNgYfN7QLg0PPrUPpkTPgmjtNI

But I'm booting into April for now until more TWRP testing is done, then hopefully if we work things out we won't need monthly boot images.

Audioboxer commented 5 years ago

@StollD We have tried 8.1.0 but with the April date. It gets stuck on the Android One screen like your two original files do.

So in order to boot it's needing OS as 9.0.0 unless you can figure something out.

We're going to try 9.0.0 but written with another month and see if it boots.

Is all of this maybe because HMD released kernel sources for the Sirocco once it was on Android 9.0, but the Nokia 8 had sources released when it was on 8.0? https://www.nokia.com/phones/en_int/opensource/

Audioboxer commented 5 years ago

@singhnsk Set the OS level to 2025-12 as it was originally, but changed to 9.0. It won't boot.

So far the only image to fastboot boot or fastboot flash boot OK has been the one with 9.0 and OS level 2019-04.

But it cannot decrypt userdata :(

StollD commented 5 years ago

hmm, ok.

@singhnsk how did you change the os level and security patch exactly? what values were there, and which values did you set? I can only find the security patch in the twrp build files, nothing about the OS version. Maybe we have to add something like this to the TWRP build files? https://github.com/dg28gadhavi/android_device_nokia_NB1/blob/android-8.1/omni_NB1.mk#L111-L112

singhnsk commented 5 years ago

@StollD I only changed the OS level in the split_img files. I didn't touch the ramdisk. So, essentially, it only corresponds to booting the OS and will have nothing to do with the TWRP. In fact, if @Audioboxer tries to flash your original boot image. And then tries to boot to TWRP via key combination, it should still work 🙂 Only booting the OS would get affected by the SP.

Audioboxer commented 5 years ago

@StollD Here is my build.prop if it might help

build.zip

Audioboxer commented 5 years ago

@StollD Any thoughts on trying to add something like this?

PRODUCT_BUILD_PROP_OVERRIDES += \ PRODUCT_NAME=NB1 \ BUILD_PRODUCT=NB1 \ TARGET_DEVICE=NB1 \ BUILD_FINGERPRINT=Nokia/NB1_00WW_FIH/NB1:8.1.0/OPR1.170623.026/00WW_4_88B:user/release-keys \ PRIVATE_BUILD_DESC="NB1_00WW_FIH-user 8.1.0 OPR1.170623.026 00WW_4_88B release-keys"

But swapping in

ro.build.description=Avenger_00WW-user 9 PPR1.180610.011 00WW_4_12B release-keys ro.build.fingerprint=Nokia/Avenger_00WW/A1N_sprout:9/PPR1.180610.011/00WW_4_12B:user/release-keys

StollD commented 5 years ago

Sorry for not replying for so long, I was a bit busy and not being able to debug this properly is sadly not helping the case xD

I can make a built with the changed properties, sure. But I am not sure if it would help much. I spent the last week or so porting Siroccos vendor image to NB1, and what suprised me was that TWRP worked fine on a system that was initialized (and encrypted) by Siroccos vendor and some random GSI from XDA. So this means that the software in TWRP definitly could decrypt a Sirocco system.

However, I think that AVB (Android Verified Boot) messes with us a bit here. TWRP has to bump the security patch version to something insane, so the blobs don't trigger rollback protection when decrypting the userdata. However, by bumping the version that high the rollback protection in the bootloader gets triggered (which is either lousy implemented and only checks if the version is equal and not newer, or thinks the system itself got downgraded).

I am not sure if all of that is correct, but I have an idea: I want to build a TWRP image that uses security patch version 2019-04 and Android 9 as the os version, but that overrides those values with the insane ones as soon as TWRP boots and initializes decryption.

If you have the time, it would be great if you could try something: Could you try booting with the image that was set to 2019-04 on a May or June (idk. which security patch sirocco is on) system? Just to see if just a mismatching security patch causes the boot to get stuck at the Android One screen. If it boots with a mismatching security patch, we can just change the value in the TWRP build settings and be done with it, if not we would have to update the image for every new security patch. And that would be less than ideal.

Audioboxer commented 5 years ago

Hey, no problem.

I'm on June security patch just now. This is a June boot image, although this is patched with magisk https://mega.nz/#!CdlxwYTK!StKoZa2ecq1oZC5TxRsIF6sK1xathkhgmK_DzxwYpy8

I don't think I'm 100% sure what you want me to try lol. It's been a few weeks. From what I remember we couldn't get the system to boot unless the security patch dates matched. What @singhnsk discovered is using keypresses to boot to recovery before system tries to boot should work on your images, irrespective of the OS version.

But we couldn't get TWRP decrypting.

StollD commented 5 years ago

I don't think I'm 100% sure what you want me to try lol. It's been a few weeks. From what I remember we couldn't get the system to boot unless the security patch dates matched. What @singhnsk discovered is using keypresses to boot to recovery before system tries to boot should work on your images.

This is what I need to know. We know the system won't boot if the security patch of the boot image is higher than the one of the system. But I am wondering what happens if the security patch of the boot image is lower than the one of the system. I.e. what would happen if you flashed the image that was patched to report it's security patch as 2019-04 to your June system?

Because then we can hardcode the security patch version to 2019-04 for the Sirocco TWRP and be done with it. If it has to match, we would have to update the image every month to report a matching security patch.

Sveeeeeen commented 5 years ago

Any ETA for a stable release?

realjack-1 commented 4 years ago

hello, is there any news? thanks

raphaelthegreat commented 4 years ago

@realjack-1 Hello, I am the developer of Lineage OS for the Nokia 8. I want to ask you, do you have an unlocked Nokia 8 Sirocco? I am in need of some keymaster firmware files (/vendor/firmware_mnt/keymaster64.mdt) to make TWRP work. Is it possible to extract these and upload them here? Thanks

singhnsk commented 4 years ago

Hi @GPUCode can this be extracted from the firmware instead? I can do it if its possible :))

raphaelthegreat commented 4 years ago

I have tried doing that, but no luck. The keymaster firmware is an .mbn file which needs to be split into and .mdt and .b00, .b01, etc I wrote splitter python script to do that, but the resulting firmware images did not load correcly. If you have a Sirocco phone, would you mind extracting them?

realjack-1 commented 4 years ago

@realjack-1 Hello, I am the developer of Lineage OS for the Nokia 8. I want to ask you, do you have an unlocked Nokia 8 Sirocco? I am in need of some keymaster firmware files (/vendor/firmware_mnt/keymaster64.mdt) to make TWRP work. Is it possible to extract these and upload them here? Thanks

yes, i have an unlocked nokia8 sirocco. there is no keymaster64.mdt file in /vendor/firmware_mnt/ , but there is a folder called "image" where many files (.b00 , b.01... , .mdt, jsn, .sig, .msc, )are contained

raphaelthegreat commented 4 years ago

Yes seach in the image folder. I am sorry it is supposed to be in /vendor/firmware_mnt/image/keymaster64.mdt

realjack-1 commented 4 years ago

(i forgot: android 10 - sp september 2020)

there is no keymaster64.mdt but there are keym_h.sig and keym_p.sig