T-Virus - Infect your Nokia 8 with Project Treble (2019-07-02)

Search This thread

wyimyimwill

New member
Oct 11, 2019
1
0
Hi THMSP:

May I ask if you would port the Android 10 from Nokia 8 Sirroco to Nokia 8, just as what you did on Android 9?
Also, will you release the rom for this build as well ?
 

THMSP

Senior Member
Jul 19, 2018
138
250
Europe
tmsp.io
Hi THMSP:

May I ask if you would port the Android 10 from Nokia 8 Sirroco to Nokia 8, just as what you did on Android 9?
Also, will you release the rom for this build as well ?

For that there would have to be an Android 10 update for Sirocco first. And that probably won't happen for some time. So I am going with a definitive maybe.

In theory, you can use Android 10 with the Android 9 vendor already. But there is a problem with that approach: The binaries that had to be added to the Sirocco vendor were taken from the Nokia 8 firmware, and therefor never setup to work with Treble. They reference libraries that are stored on the system partition directly. And this means that they use APIs that existed in Android 9 but that were removed / changed in Android 10. If they would use the Treble APIs for that, it wouldn't be an issue, but they don't. This is the reason why if you flash an Android 10 GSI the hardware buttons, and the camera won't work.

The only "easy" solution to that would be to update those binaries to the newer APIs. But since Nokia 8 won't get Android 10, those blobs will never see an update to the new APIs either. You might be able to rip the Goodix stuff (hardware buttons) out of another phone that has Treble / A10, but that will most likely not work for the camera at all. And since all of that is proprietary, closed source stuff we can't update it ourselves.

So it will probably be totally impossible to ever run something thats not Pie with T-Virus. At least if you want camera and button support. Unless someone who is more involved into this than I am has an idea how to solve it.

And no, please don't go: "So HMD has to update Nokia 8 to Android 10 so we can fix T-Virus.". That ship has sailed. If you want Android 10 anytime soon, get a different phone. Sorry.
 

comatrices

Member
Jul 10, 2019
6
4
Supposedly the Essential PH-1 uses the same back camera sensors as the Nokia 8. Are its binaries usable?
 

MDV106

Senior Member
Jan 4, 2019
475
169
DotOS rom seems to work quite well for me on this phone. Everything seems to be working quite nicely. I havent tested Bluetooth audio since i rarely ever use it.
 
  • Like
Reactions: rashazad

Azeem Shah

Senior Member
Nov 14, 2015
62
4
Lahore
Code:
#include <std_disclaimer.h>

/*
 * Your warranty is now void.
 *
 * I am not responsible for bricked devices, dead SD cards,
 * thermonuclear war, or you getting fired because the alarm app failed. Please
 * do some research about modifying your android system before flashing this! 
 * YOU are choosing to make these modifications, and if you point the finger at 
 * me for messing up your device, I will laugh at you. Hard. A lot.
 */
(if you expected the Resident Evil references to stop, you just got gnomed)

What is this?
T-Virus (for treble-virus) is a tool that takes a stock Nokia 8 firmware and "infects" it with various parts from the Nokia 8 Sirocco firmware, generating a firmware bundle that is compilant with Project Treble and that can be flashed to a Nokia 8 using NOST.

Firmware Sources
The base of T-Virus is the stock Nokia 8 firmware image (5150 / April Security patch at the time of writing). When being run, the build script takes those files and replaces the partition table with the one from Nokia 8 Sirocco. This required for creating a vendor partition that the stock Nokia 8 does not have. The vendor image is taken from the Sirocco firmware as well. During the build, the vendor image is mounted as rw, and various files are copied over from the stock Nokia 8 system image, or get patched to properly support the minor hardware differences between the two phones. Those actions are defined through very basic scripts inside of the vendor folder in the repository.
The boot image is a modified version of my umbrella kernel, which has support for early mounting vendor. It also includes a TWRP build with full support for Project Treble.

SELinux Hell
Because Android does some very weird stuff with SELinux contexts, you cannot launch a service file when it has an unknown context. We have to fix that by force-setting the SELinux context manually, but due to how SELinux works, this is only possible on a Linux system without SELinux. This means, that you cannot build this on a distribution with SELinux (Fedora in my case). I fixed the problem by building the images in a Ubuntu VM.

How to build?
First you have to download the latest firmware image from https://tmsp.io/fs/xda/nb1/firmware, and the exdupe tool from https://www.quicklz.com/exdupe
Extract the firmware into a folder and then clone the repository, like this:
Code:
 $ mkdir firmware 
 $ ./exdupe -R ~/Downloads/NB1-5150-0-00WW-B03.qlz firmware/ 
 $ git clone https://github.com/resident-nokia/t-virus 
 $ cd t-virus
The build script has two options you have to set: a version and the path to the extracted firmware. This means you have to run it like this:
Code:
 $ ./build.sh --version v0.1 --firmware ../firmware
Leave it running and when it asks you, enter your sudo password. This is required to mount the Android ext4 partitions and edit the files that are only accessable by the (Android) root user, and retain their permissions.
When the script has finished the flashable firmware image will be inside of the out folder. You can optionally package this as a .qlz file again using exdupe.

What works?
  • It boots
  • Data decryption in recovery
  • Flashing GSIs / OpenGApps in recovery
  • WiFi
  • Mobile Data
  • Bluetooth
  • Sound
  • Vibration
  • Calling
  • Hardware buttons
  • Fingerprint
  • Camera
  • GPS
  • NFC
  • SDCard
  • Multi SIM
  • 4k Video

What doesn't work, or isn't tested
  • Haptic feedback for Hardware buttons
  • Bluetooth headphones don't get registered properly
  • Nokia OZO audio support is missing
  • Fingerprint sensor is reported as being on the back of the phone
  • There might be issues with USB transfer under Windows
  • VoLTE (untested)

How to install?
WARNING: This might not be useable as a daily driver. Continue only if you are able to troubleshoot things if neccessary (bootloops, bricking the phone, causing the alarm app to declare nuclear war)

You can download the latest release from the releases page on the repository. It is a .qlz firmware, so you will have to flash it through NOST. You will need a completely unlocked bootloader. When flashing, make sure to select the "Erase Userdata" option, not doing this will most certainly bootloop the phone.
After the installation completed, your phone will reboot into phh's AOSP GSI. If you want to use a different GSI (you most likely will), follow these steps:

  • Download your favorite GSI
  • Unpack every form of compression, so you end up with a .img file
  • Boot into recovery
  • Copy the .img to the internal storage of your phone, or to your SDCard
  • Select "Install" -> "Install .img", select the image file you copied and flash it to your system partition
  • Then install OpenGApps or any other modifications you like.
  • Wipe /data to allow the new system image to boot properly and then reboot
To update to a newer version without having to erase userdata, download the zipped vendor image from the release page, and flash the image inside in TWRP.
If you want to go back to stock, simply download the 5150-revert firmware and flash it with NOST, with the "Erase Userdata" option enabled. It will revert all changes T-Virus made to your phone. Firmwares from https://tmsp.io/fs/xda/nb1 will not work.

Links?

What if I have a bug?
  • Upload a proper bugreport. This means logcat and dmesg. If you don't know how to get them, google it. Also, describe the issue and provide steps to replicate it. Everything else will be ignored.
  • I don't daily drive this phone anymore. I am doing this just because it is an interesting technical challenge. I don't have as much motivation to fix bugs than someone who daily drives it.
I want to say thank you!
I usually don't do this, but since this involved a lot of work on my side, I would be grateful if you would want to say thank you by buying me a coffee (or two): https://paypal.me/thmsp

When I'm trying to install gsi havoc 2.9 twrp show only 2 option flash IMG boot and ramdisk
System option not show
 

dongvatm

Senior Member
Feb 16, 2020
57
11
Ha Noi
Code:
#include <std_disclaimer.h>

/*
 * Your warranty is now void.
 *
 * I am not responsible for bricked devices, dead SD cards,
 * thermonuclear war, or you getting fired because the alarm app failed. Please
 * do some research about modifying your android system before flashing this! 
 * YOU are choosing to make these modifications, and if you point the finger at 
 * me for messing up your device, I will laugh at you. Hard. A lot.
 */
(if you expected the Resident Evil references to stop, you just got gnomed)

What is this?
T-Virus (for treble-virus) is a tool that takes a stock Nokia 8 firmware and "infects" it with various parts from the Nokia 8 Sirocco firmware, generating a firmware bundle that is compilant with Project Treble and that can be flashed to a Nokia 8 using NOST.

Firmware Sources
The base of T-Virus is the stock Nokia 8 firmware image (5150 / April Security patch at the time of writing). When being run, the build script takes those files and replaces the partition table with the one from Nokia 8 Sirocco. This required for creating a vendor partition that the stock Nokia 8 does not have. The vendor image is taken from the Sirocco firmware as well. During the build, the vendor image is mounted as rw, and various files are copied over from the stock Nokia 8 system image, or get patched to properly support the minor hardware differences between the two phones. Those actions are defined through very basic scripts inside of the vendor folder in the repository.
The boot image is a modified version of my umbrella kernel, which has support for early mounting vendor. It also includes a TWRP build with full support for Project Treble.

SELinux Hell
Because Android does some very weird stuff with SELinux contexts, you cannot launch a service file when it has an unknown context. We have to fix that by force-setting the SELinux context manually, but due to how SELinux works, this is only possible on a Linux system without SELinux. This means, that you cannot build this on a distribution with SELinux (Fedora in my case). I fixed the problem by building the images in a Ubuntu VM.

How to build?
First you have to download the latest firmware image from https://tmsp.io/fs/xda/nb1/firmware, and the exdupe tool from https://www.quicklz.com/exdupe
Extract the firmware into a folder and then clone the repository, like this:
Code:
 $ mkdir firmware 
 $ ./exdupe -R ~/Downloads/NB1-5150-0-00WW-B03.qlz firmware/ 
 $ git clone https://github.com/resident-nokia/t-virus 
 $ cd t-virus
The build script has two options you have to set: a version and the path to the extracted firmware. This means you have to run it like this:
Code:
 $ ./build.sh --version v0.1 --firmware ../firmware
Leave it running and when it asks you, enter your sudo password. This is required to mount the Android ext4 partitions and edit the files that are only accessable by the (Android) root user, and retain their permissions.
When the script has finished the flashable firmware image will be inside of the out folder. You can optionally package this as a .qlz file again using exdupe.

What works?
  • It boots
  • Data decryption in recovery
  • Flashing GSIs / OpenGApps in recovery
  • WiFi
  • Mobile Data
  • Bluetooth
  • Sound
  • Vibration
  • Calling
  • Hardware buttons
  • Fingerprint
  • Camera
  • GPS
  • NFC
  • SDCard
  • Multi SIM
  • 4k Video

What doesn't work, or isn't tested
  • Haptic feedback for Hardware buttons
  • Bluetooth headphones don't get registered properly
  • Nokia OZO audio support is missing
  • Fingerprint sensor is reported as being on the back of the phone
  • There might be issues with USB transfer under Windows
  • VoLTE (untested)

How to install?
WARNING: This might not be useable as a daily driver. Continue only if you are able to troubleshoot things if neccessary (bootloops, bricking the phone, causing the alarm app to declare nuclear war)

You can download the latest release from the releases page on the repository. It is a .qlz firmware, so you will have to flash it through NOST. You will need a completely unlocked bootloader. When flashing, make sure to select the "Erase Userdata" option, not doing this will most certainly bootloop the phone.
After the installation completed, your phone will reboot into phh's AOSP GSI. If you want to use a different GSI (you most likely will), follow these steps:

  • Download your favorite GSI
  • Unpack every form of compression, so you end up with a .img file
  • Boot into recovery
  • Copy the .img to the internal storage of your phone, or to your SDCard
  • Select "Install" -> "Install .img", select the image file you copied and flash it to your system partition
  • Then install OpenGApps or any other modifications you like.
  • Wipe /data to allow the new system image to boot properly and then reboot
To update to a newer version without having to erase userdata, download the zipped vendor image from the release page, and flash the image inside in TWRP.
If you want to go back to stock, simply download the 5150-revert firmware and flash it with NOST, with the "Erase Userdata" option enabled. It will revert all changes T-Virus made to your phone. Firmwares from https://tmsp.io/fs/xda/nb1 will not work.

Links?

What if I have a bug?
  • Upload a proper bugreport. This means logcat and dmesg. If you don't know how to get them, google it. Also, describe the issue and provide steps to replicate it. Everything else will be ignored.
  • I don't daily drive this phone anymore. I am doing this just because it is an interesting technical challenge. I don't have as much motivation to fix bugs than someone who daily drives it.
I want to say thank you!
I usually don't do this, but since this involved a lot of work on my side, I would be grateful if you would want to say thank you by buying me a coffee (or two): https://paypal.me/thmsp

Thank u so much. it worked. i have installed Android 10 GSI on my Nokia but it have a bluetooth connect problem. Dont connect audio with bluetooth. How to fix it?:confused::confused::confused:
 

Tommik6534

New member
Mar 14, 2020
1
0
Hey guys!

Thank you so much fot this amazing NOKIA 8 treble project, guys! :cool::cowboy:

I tried these ROMs on my NOKIA 8..
Havoc OS 2.9
Lineage OS 16.x, 17.x..

I can confirm, that Lineage OS 16.x and HAVOC OS 2.9 working like a charm with OpenGApps (except fingerprint reader, haptic feedback )
I didnt test BT audio..

Lineage OS 17.x working perfectly too, but i m not able to work HW buttons - has anyone an idea ?
I tried to check all "buttons settings", changing system profiles..and no change..

BTW: For successful flash OpenGApps, you may have to resize your system partition in TWRP..because of space requirements.. (note for beginners :D )

Thanks a lot! ;)
 
D

Deleted member 8413550

Guest
Hey guys!

Thank you so much fot this amazing NOKIA 8 treble project, guys! :cool::cowboy:

I tried these ROMs on my NOKIA 8..
Havoc OS 2.9
Lineage OS 16.x, 17.x..

I can confirm, that Lineage OS 16.x and HAVOC OS 2.9 working like a charm with OpenGApps (except fingerprint reader, haptic feedback )
I didnt test BT audio..

Lineage OS 17.x working perfectly too, but i m not able to work HW buttons - has anyone an idea ?
I tried to check all "buttons settings", changing system profiles..and no change..

BTW: For successful flash OpenGApps, you may have to resize your system partition in TWRP..because of space requirements.. (note for beginners :D )

Thanks a lot! ;)
nice. Will test los17 tomorrow. im fine with onscreen nav buttons
 

Majd7667

Senior Member
May 29, 2013
159
29
Well done!

Hi,

First of all thanks for making project treble compatible with the Nokia 8!

I have flashed the infected firmware on my Nokia 8 TA-1012 that I have built previously. Here are some things I noticed:
  • On boot, I get this message: "There is an internal problem in your device. Please contact your manufacturer". However, it doesn't seem to affect the device performance.
  • The camera app crashes with the message: "Camera keeps stopping". I have attached logs for this (logcat, logcat radio and dmesg).
  • Bluetooth audio doesn't work correctly.

Then, I installed Lineage 17 (Android 10), I noticed that the hardware navigation buttons don't even work!

Finally, I installed Pixel Experience P and here is what I noticed:
  • It seems like the wifi signal is way lower than on the stock ROM, I get around half the speed I get on stock. I didn't check this on the other ROMs!
  • Bluetooth audio doesn't work correctly.

Note that I reverted back to stock and I haven't done any factory reset after installing any GSI.

Logs are captured after camera crash issue and not for the other issues (it might however include the slow wifi problem).
Please let me know if you need logs for a specific bugs and on a specific GSI!
 

Attachments

  • logs.zip
    214.2 KB · Views: 16
  • Like
Reactions: Olevikas

shubhmc

Member
May 21, 2016
21
12
Android 10 Beta for Nokia 8 Sirocco has leaked

I don't understand how ROM's work but after a unlocked bootloader, can we flash a modded Sirocco Android 10 since a lot of hardware is similar?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 25
    Code:
    #include <std_disclaimer.h>
    
    /*
     * Your warranty is now void.
     *
     * I am not responsible for bricked devices, dead SD cards,
     * thermonuclear war, or you getting fired because the alarm app failed. Please
     * do some research about modifying your android system before flashing this! 
     * YOU are choosing to make these modifications, and if you point the finger at 
     * me for messing up your device, I will laugh at you. Hard. A lot.
     */
    (if you expected the Resident Evil references to stop, you just got gnomed)

    What is this?
    T-Virus (for treble-virus) is a tool that takes a stock Nokia 8 firmware and "infects" it with various parts from the Nokia 8 Sirocco firmware, generating a firmware bundle that is compilant with Project Treble and that can be flashed to a Nokia 8 using NOST.

    Firmware Sources
    The base of T-Virus is the stock Nokia 8 firmware image (5150 / April Security patch at the time of writing). When being run, the build script takes those files and replaces the partition table with the one from Nokia 8 Sirocco. This required for creating a vendor partition that the stock Nokia 8 does not have. The vendor image is taken from the Sirocco firmware as well. During the build, the vendor image is mounted as rw, and various files are copied over from the stock Nokia 8 system image, or get patched to properly support the minor hardware differences between the two phones. Those actions are defined through very basic scripts inside of the vendor folder in the repository.
    The boot image is a modified version of my umbrella kernel, which has support for early mounting vendor. It also includes a TWRP build with full support for Project Treble.

    SELinux Hell
    Because Android does some very weird stuff with SELinux contexts, you cannot launch a service file when it has an unknown context. We have to fix that by force-setting the SELinux context manually, but due to how SELinux works, this is only possible on a Linux system without SELinux. This means, that you cannot build this on a distribution with SELinux (Fedora in my case). I fixed the problem by building the images in a Ubuntu VM.

    How to build?
    First you have to download the latest firmware image from https://tmsp.io/fs/xda/nb1/firmware, and the exdupe tool from https://www.quicklz.com/exdupe
    Extract the firmware into a folder and then clone the repository, like this:
    Code:
     $ mkdir firmware 
     $ ./exdupe -R ~/Downloads/NB1-5150-0-00WW-B03.qlz firmware/ 
     $ git clone https://github.com/resident-nokia/t-virus 
     $ cd t-virus
    The build script has two options you have to set: a version and the path to the extracted firmware. This means you have to run it like this:
    Code:
     $ ./build.sh --version v0.1 --firmware ../firmware
    Leave it running and when it asks you, enter your sudo password. This is required to mount the Android ext4 partitions and edit the files that are only accessable by the (Android) root user, and retain their permissions.
    When the script has finished the flashable firmware image will be inside of the out folder. You can optionally package this as a .qlz file again using exdupe.

    What works?
    • It boots
    • Data decryption in recovery
    • Flashing GSIs / OpenGApps in recovery
    • WiFi
    • Mobile Data
    • Bluetooth
    • Sound
    • Vibration
    • Calling
    • Hardware buttons
    • Fingerprint
    • Camera
    • GPS
    • NFC
    • SDCard
    • Multi SIM
    • 4k Video

    What doesn't work, or isn't tested
    • Haptic feedback for Hardware buttons
    • Bluetooth headphones don't get registered properly
    • Nokia OZO audio support is missing
    • Fingerprint sensor is reported as being on the back of the phone
    • There might be issues with USB transfer under Windows
    • VoLTE (untested)

    How to install?
    WARNING: This might not be useable as a daily driver. Continue only if you are able to troubleshoot things if neccessary (bootloops, bricking the phone, causing the alarm app to declare nuclear war)

    You can download the latest release from the releases page on the repository. It is a .qlz firmware, so you will have to flash it through NOST. You will need a completely unlocked bootloader. When flashing, make sure to select the "Erase Userdata" option, not doing this will most certainly bootloop the phone.
    After the installation completed, your phone will reboot into phh's AOSP GSI. If you want to use a different GSI (you most likely will), follow these steps:

    • Download your favorite GSI
    • Unpack every form of compression, so you end up with a .img file
    • Boot into recovery
    • Copy the .img to the internal storage of your phone, or to your SDCard
    • Select "Install" -> "Install .img", select the image file you copied and flash it to your system partition
    • Then install OpenGApps or any other modifications you like.
    • Wipe /data to allow the new system image to boot properly and then reboot
    To update to a newer version without having to erase userdata, download the zipped vendor image from the release page, and flash the image inside in TWRP.
    If you want to go back to stock, simply download the 5150-revert firmware and flash it with NOST, with the "Erase Userdata" option enabled. It will revert all changes T-Virus made to your phone. Firmwares from https://tmsp.io/fs/xda/nb1 will not work.

    Links?

    What if I have a bug?
    • Upload a proper bugreport. This means logcat and dmesg. If you don't know how to get them, google it. Also, describe the issue and provide steps to replicate it. Everything else will be ignored.
    • I don't daily drive this phone anymore. I am doing this just because it is an interesting technical challenge. I don't have as much motivation to fix bugs than someone who daily drives it.
    I want to say thank you!
    I usually don't do this, but since this involved a lot of work on my side, I would be grateful if you would want to say thank you by buying me a coffee (or two): https://paypal.me/thmsp
    3
    What about ozo audio config?

    yeah, I'd like that, too, also fully working camera, i.e. with dual-camera.
    Just lack the knowledge on how to determine which libs and configs are needed for that.

    The credits for the compass fix actually should go to @kosmatyj :good:
    3
    Hi THMSP:

    May I ask if you would port the Android 10 from Nokia 8 Sirroco to Nokia 8, just as what you did on Android 9?
    Also, will you release the rom for this build as well ?

    For that there would have to be an Android 10 update for Sirocco first. And that probably won't happen for some time. So I am going with a definitive maybe.

    In theory, you can use Android 10 with the Android 9 vendor already. But there is a problem with that approach: The binaries that had to be added to the Sirocco vendor were taken from the Nokia 8 firmware, and therefor never setup to work with Treble. They reference libraries that are stored on the system partition directly. And this means that they use APIs that existed in Android 9 but that were removed / changed in Android 10. If they would use the Treble APIs for that, it wouldn't be an issue, but they don't. This is the reason why if you flash an Android 10 GSI the hardware buttons, and the camera won't work.

    The only "easy" solution to that would be to update those binaries to the newer APIs. But since Nokia 8 won't get Android 10, those blobs will never see an update to the new APIs either. You might be able to rip the Goodix stuff (hardware buttons) out of another phone that has Treble / A10, but that will most likely not work for the camera at all. And since all of that is proprietary, closed source stuff we can't update it ourselves.

    So it will probably be totally impossible to ever run something thats not Pie with T-Virus. At least if you want camera and button support. Unless someone who is more involved into this than I am has an idea how to solve it.

    And no, please don't go: "So HMD has to update Nokia 8 to Android 10 so we can fix T-Virus.". That ship has sailed. If you want Android 10 anytime soon, get a different phone. Sorry.
    2
    Ok. After the flashing we have a phone "infected" by the Project Treble. But what it gives to end-user? What is profit of this?
    The ability to install GSIs (Generic System Images). Basically everything from here: https://forum.xda-developers.com/project-treble/trebleenabled-device-development
    2
    Yes I solved partically the compass error. But seems it is partically because it sloooowly rotates clockwise. Trying to find another solution. So it was preambula. Now what I did: I got sensor_def_qcomdev.conf file from Android 8.1 for Nokia 8 and copied it to /system/vendor/etc/sensors (root access required) and set rights -rw-r-r just like it was on original. After that compass seemed to be fixed. Bu as I said befor - it is only first look. Than it ran away. But you may be mor lucky with it! Try and you`ll see if it helped.

    Yes buttons are flickering twice and then they go out. I dont pay attention to it.

    Since the compass was fixed with June update (?), I compared the .conf file from current T-Virus vendor and the 515D stock and there were two lines that were different: in `platform nb1` section, Mag Y and Mag Z are negative values in 515D, so I changed them (see attached image).
    I also copied over two .so files to both lib and lib64 in /vendor, just in case (they had different hashes).
    After reboot and calibration it seems like it shows the correct direction.