Harlock1978 / Armor_11_5G

0 stars 0 forks source link

A10_lopestom branch start #4

Open Harlock1978 opened 1 year ago

Harlock1978 commented 1 year ago

I compiled your branch and it boot but there are still the crypto problem:

Could not mount /data and unable to find crypto footer Failed to mount '/data' (invalid argument) Unable to recreate '/data/media' folder. Unable to mount '/data/media/TWRP/.twrps Failed to mount '/data' (invalid argument) Failed to mount '/system_root' (permission denied) Failed to mount '/data' (invalid argument) Failed to decrypt data

Mount usb_otg doesn't work in this branch but it worked in your original so I have to investigate it.

Immediately at the beginning there is another error:

E:Unhandled flag: 'logical' E:Unhandled flag: 'logical' E:Unhandled flag: 'logical'

This error is not present in you recovery I will further investigate.

I added the log of the recovery. recovery.zip

Harlock1978 commented 1 year ago

Usb_otg problem solved.

I find logical twice mentioned once in recovery.fstab and it is also so in you recovery and a second time in twrp.fstab where is regarding the portion image and is not present in you recovery so I think here is the problem.

Removing #Images part in twrp.stab solved the 'logical' flag error

Harlock1978 commented 1 year ago

Reading the mount point created by a friend I noticed

/dev/block/dm-1 /vendor ext4 /dev/block/dm-0 /product ext4

should I use it instead of

/dev/block/mapper/vendor /dev/block/mapper/product

I also find:

/data/media /mnt/runtime/default/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,multiuser,mask=6,derive_gid,default_normal 0 0 /data/media /mnt/runtime/read/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=23,derive_gid,default_normal 0 0 /data/media /mnt/runtime/write/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=7,derive_gid,default_normal 0 0 /data/media /mnt/runtime/full/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=7,derive_gid,default_normal 0 0

/dev/block/dm-3 /data ext4 rw,seclabel,nosuid,nodev,noatime,nodelalloc,nobarrier,noauto_da_alloc,resuid=10010,resgid=1065,errors=panic,data=writeback 0 0

/data/media /storage/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=7,derive_gid,default_normal 0 0

Should I put them in recovery.fstab or better in twrp.fstab?

When I mount system.img in Linux it is indicated as "/" only while product and vendor are indicated as product and vendor, should I change system with only "/" in the fstab?

In mount the first line is

/dev/block/dm-2 / ext4 ro,seclabel,relatime 0 0

that I belileve represent the System partition.

Harlock1978 commented 1 year ago

I added to recovery.fstab

/data/media /mnt/runtime/default/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,multiuser,mask=6,derive_gid,default_normal 0 0 /data/media /mnt/runtime/read/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=23,derive_gid,default_normal 0 0 /data/media /mnt/runtime/write/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=7,derive_gid,default_normal 0 0 /data/media /mnt/runtime/full/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=7,derive_gid,default_normal 0 0 /data/media /storage/emulated sdcardfs rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,multiuser,mask=7,derive_gid,default_normal 0 0

and moddded twrp.fstab

/system ext4 /dev/block/dm-2 flags=backup=1;display="System ext4";wipeingui /vendor ext4 /dev/block/dm-1 flags=backup=1;display="Vendor ext4";wipeingui /product ext4 /dev/block/dm-0 flags=backup=1;display="Product ext4";wipeingui /data ext4 /dev/block/dm-3 flags=fileencryption=aes-256-cts

instead of

/system ext4 /dev/block/mapper/system flags=backup=1;display="System ext4";wipeingui /vendor ext4 /dev/block/mapper/vendor flags=backup=1;display="Vendor ext4";wipeingui /product ext4 /dev/block/mapper/product flags=backup=1;display="Product ext4";wipeingui /data ext4 /dev/block/by-name/userdata flags=fileencryption=aes-256-cts

and I receive this error:

E:primary block device '/dev/block/dm-3' for mount point '/data' is not present! Failed to mount '/data' (invalid argument) Unable to recreate /data/media folder Unable to mount /data/media/TWRP.twrps Failed to mount '/system_root' (permission denied)

There is not anymore the error of unable to find crypto footer but decrypt doesn't work and is still not possible to mount /System and /vendor

Harlock1978 commented 1 year ago

Restoring only twrtp.fstab brings again the error

Could not mount /data and unable to find crypto footer

so probably was only showing a different error

lopestom commented 1 year ago

I'm without PC yet. Not helping much only with smartphone.

Well, you have advance so continue learning and tests with your device.

Crypto: if you made FORMAT DATA (yes) - Reboot Recovery and \Data not show or have crypto error too so the problem is about How script&files can work. How I wrote before, the encrypt & decrypt part is not easy. Has 2 others ways but that is not the official encrypt (not password so not encryption): 1- search in the xda about disable encryption; 2- you can have new vendor.img modifying the fstab file(s): Unpack vendor.img and you have \vendor\etc\fstab.mt6873 or and fstab.emmc; open fstab file and change fileencryption to encryptable. Pack these \vendor Flash new_vendor.img in the fastbootd: fastboot flash vendor new_vendor.img Format userdata in the fastboot fastboot -w or fastboot erase userdata or in the stock recovery

Harlock1978 commented 1 year ago

That would be an option, but because of the crash of my handy I would like to retrieve the file saved on userdata. I'm not the first that had a bootloop after updating a Magisk module, I'm wondering if it's the same.

In official recovery is possible to mount system, I'm trying to understand how, so maybe it can help also with vendor, product and data.

In official recovery some link are indicated as /dev/block/platform/bootdevice/by-name/ while this versione never appear in system or vendor

Harlock1978 commented 1 year ago

ADeadTrousers id very difficult becasue he wrote script to create the files and I don't understand his script

Harlock1978 commented 1 year ago

I think that this link What is a data/media device? can help to understand how to mount data

lopestom commented 1 year ago

I think that this link What is a data/media device? can help to understand how to mount data

Unfortunately no. That's only inform about \Data (internal storage for userdata).

I compiled your branch and it boot but there are still the crypto problem..... There is not anymore the error of unable to find crypto footer but decrypt doesn't work and is still not possible to mount /System and /vendor

Can you FORMAT DATA - Reboot System - any password in the settings?! Reboot to TWRP: same message? Need more development in the script/more files from stock ROM so more tests.

How I wrote a time ago: it's not easy specially with userdata file encrypted with stock recovery.

For TWRP mount better the partitions use this: [SCRIPT][Android 10+] Universal MakeSystemRW Mount SystemRW / SuperRW featuring MakeRW (read/write)

Harlock1978 commented 1 year ago

When I start to mount system and vendor the error message is always permission denied and I think is related to Privileged Permission Allowlisting. I have now two hypothesis either I create an alternative privapp-permissions-DEVICE_NAME.xml that I symlink to the original one or I extract the three partition of the super partition, I made them rw I add the line in the privapp-permissions-DEVICE_NAME.xml then i repack the images and I flash the new version on my phone.

One problem is that I don't know the package name of TWRP

lopestom commented 1 year ago

When I start to mount system and vendor the error message is always permission denied and I think is related to Privileged Permission Allowlisting. I have now two hypothesis either I create an alternative privapp-permissions-DEVICE_NAME.xml that I symlink to the original one or I extract the three partition of the super partition, I made them rw I add the line in the privapp-permissions-DEVICE_NAME.xml then i repack the images and I flash the new version on my phone.

One problem is that I don't know the package name of TWRP

Tried mount -o remount, rw / ??

adb shell
su

or in the TWRP terminal mount -o remount, rw /

Always I can do

blockdev --setrw /dev/block/dm-0
blockdev --setrw /dev/block/dm-1
blockdev --setrw /dev/block/dm-2
blockdev --setrw /dev/block/dm-3
blockdev --setrw /dev/block/dm-4

and mount.....

I believe you are complicating with this part of privapp-permissions-DEVICE_NAME.xml If you are doing something with the device directly started and using some ROOT file manager, then use a working one and mount rw.

Harlock1978 commented 1 year ago

When I boot TWRp I decide to chose keep read only and so I didn't have the error message Failed to mount '/system_root' (permission denied) and Failed to mount '/vendor' (permission denied), then I tried on twrp terminal what you suggested with system_root instead of system_ext, but in grep I don't have "/" while the other 3 show esact the same messages.

Harlock1978 commented 1 year ago

Surfing than product, vendor and system_root I found that system_root is empty

Harlock1978 commented 1 year ago

Looking on githun I found the source of the kernel of Ulefone Power Armor 13 that have a lot fo code about MT6873 soc, so I was wondering if it can help us to decrypt and mount /data

Unfortunately c++ programming is still out of my knowldege

lopestom commented 1 year ago

Surfing than product, vendor and system_root I found that system_root is empty

Maybe because the device in the ro mode? Not mounted \system or \system_root? Look that in your fstab changed.

When I boot TWRp I decide to chose keep read only and so I didn't have the error message Failed to mount '/system_root' (permission denied) and Failed to mount '/vendor' (permission denied), then I tried on twrp terminal what you suggested with system_root instead of system_ext, but in grep I don't have "/" while the other 3 show esact the same messages.

With stock recovery installed you can know about mounts.

Looking on githun I found the source of the kernel of Ulefone Power Armor 13 that have a lot fo code about MT6873 soc, so I was wondering if it can help us to decrypt and mount /data

Unfortunately c++ programming is still out of my knowldege

It's need much knowedge and the real Source Code for your device! Many devices with source code (which comes partially or fully) can't always get encryption/decryption working. So it's your choice whether you want to try it or not. I gave up a long time ago because Mediatek doesn't give the complete source code. I won't be able to help you with that.

Look =>> Ulefone Power Armor 13 - that have a lot fo code about MT6873 soc =>> Android 11;MediaTek Helio G95 (MT6785V/CD)
https://www.devicespecifications.com/en/model/0a6056be

Harlock1978 commented 1 year ago

With stock recovery installed you can know about mounts.

How can I do that?

I cannot run adb shell while in recovery, I now I can mount system, because is an option

lopestom commented 1 year ago
cat /proc/mounts
Harlock1978 commented 1 year ago

The command gave me only all my drive, but not the on the cell phone.

lopestom commented 1 year ago

cat /proc/mounts

start device...... you can install termux if you want maybe need su or adb shell

Harlock1978 commented 1 year ago

adb shell doesn't work, it say device unauthorized

lopestom commented 1 year ago

adb shell doesn't work, it say device unauthorized

In the Developer Options the USB Debugging enable? Authorized PC with Revoke USB debugging authorizations? Well, bootloader unlocked; any Su or Magisk installed? Maybe the platform-tools need update?

Harlock1978 commented 1 year ago

My problem is that my phone doesn't boot. I can go in bootloader or in recovery, but when I chose normal boot it stays stuck to Ulefone logo. Everything happened after updating two script of Magisk, and according to XDA I'm not the only one. I wanted to do a factory reset but it turned out that my backup was deleted. I removed the microsd from the old Mobile phone and when I put it again in the PC the directory was empty, it seems to be a security measure. That's why I try to decrypt the userdata to get back as much I can from my phone. I downloaded all the image with mtkclient and at least boot and super are corrected and I can mount them in Linux, I cannot mount userdata, probably because is encrypted. I wanted to follow this instructions: Mate 9 - how to retrieve encrypted files from a broken system (userdata partition) but I was not able to compile the first code.

My computer used to be authorized, but after two or three times it was again popping up the authorisation request on the phone,

Harlock1978 commented 1 year ago

Following this post I found that 4 files are in system directory, but not in the recovery so I added tham to the system folder, maybe teed need them to decrypt.

Another thing that I'm thinking is if instead of the kernel from the recovery we need the kernel from the boot image, while it should handle encrypted userdata.

Third point I asked a friend to perform cat /proc/mounts on his Ulefone Armor 11 5 G and I noticed that:

/dev/block/dm-3 /data ext4 rw,seclabel,nosuid,nodev,noatime,nodelalloc,nobarrier,noauto_da_alloc,resuid=10010,resgid=1065,errors=panic,data=writeback 0 0

maybe in twrp.stab is better if I write:

/data ext4 /dev/block/mapper/userdata flags=fileencryption=aes-256-cts

instead of

/data ext4 /dev/block/by-name/userdata flags=fileencryption=aes-256-cts

System, vendor and product are showed like this:

/dev/block/dm-2 / ext4 ro,seclabel,relatime 0 0 /dev/block/dm-1 /vendor ext4 ro,seclabel,relatime 0 0 /dev/block/dm-0 /product ext4 ro,seclabel,relatime 0 0

lopestom commented 1 year ago

Following this post I found that 4 files are in system directory, but not in the recovery so I added tham to the system folder, maybe teed need them to decrypt.

Another thing that I'm thinking is if instead of the kernel from the recovery we need the kernel from the boot image, while it should handle encrypted userdata.

All attempts is valid. Your time, your decision.....

Third point I asked a friend to perform cat /proc/mounts on his Ulefone Armor 11 5 G and I noticed that:

/dev/block/dm-3 /data ext4 rw,seclabel,nosuid,nodev,noatime,nodelalloc,nobarrier,noauto_da_alloc,resuid=10010,resgid=1065,errors=panic,data=writeback 0 0

maybe in twrp.stab is better if I write:

/data ext4 /dev/block/mapper/userdata flags=fileencryption=aes-256-cts

instead of

/data ext4 /dev/block/by-name/userdata flags=fileencryption=aes-256-cts

System, vendor and product are showed like this:

/dev/block/dm-2 / ext4 ro,seclabel,relatime 0 0 /dev/block/dm-1 /vendor ext4 ro,seclabel,relatime 0 0 /dev/block/dm-0 /product ext4 ro,seclabel,relatime 0 0

Thats already made by TWRP. It's search partitions as logical and not logical for mount/unmount...... Obviusly the System need enter in the userdata and so it's need the "atail" in the logical partition..... You not need ask me to do anything.... Made your self and learn because you go have more experience with "errors" and/or sucess solving that. So with that you have more knowledege too.

https://gerrit.twrp.me/c/android_bootable_recovery/+/3113/6/twrp.cpp // Symlink mapper to bootdevice, etc, if we have dynamic partitions

https://source.android.com/docs/core/ota/dynamic_partitions/implement#partition-alignment

https://source.android.com/docs/core/ota/virtual_ab#device-mapper

https://source.android.com/docs/core/ota/user-data-checkpoint#setup

https://source.android.com/docs/security/features/encryption/file-based

lopestom commented 1 year ago

I have to you a new img file test with 3.7.0_11 version. TWRP3.7.0_11

Harlock1978 commented 1 year ago

I will give it a try, the 11 means that is based on Android 11?

I flashed it and here are the error messages:

Could not mount /data and unable to find crypto footer Failed to mount '/data' (Invalid argument) Unable to recreate /data/media folder. E:Cannot decrypt adopted storage because /data will not mount

Updating partition details... Failed to mount '/data/ (Invalid argument) Failed to mount '/persist' (Device or resource busy) Failed to mount '/nvcfg' (Device or resource busy) Failed to mount '/nvdata' (Device or resource busy) Failed to mount '/protect_f' (Device or resource busy) Failed to mount '/protect_s' (Device or resource busy) ...done Unable to mount storage Full SELinux support is present. Unable to mount /data/media/TWRP/.twrps

lopestom commented 1 year ago

Need Trying FORMAT DATA and testing enc_dec mode.

Harlock1978 commented 1 year ago

I would like not to format data, but I'm still trying to recover what was saved on my phone.

Harlock1978 commented 1 year ago

A friend of mine tested the your latest recovery and format worked on his phone, we didn't try enc_dec while I'm still trying to implement following the instruction of ADeadTrousers, but I have a problem about drop priv failed while running teed service