Minionguyjpro / android_device_samsung_a2corelte

TWRP device tree for the Samsung Galaxy A2 Core (a2corelte)
0 stars 0 forks source link

TWRP recovery not building properly (Maybe due to incorrect device tree) #1

Closed Minionguyjpro closed 1 month ago

Minionguyjpro commented 1 month ago

@lopestom

lopestom commented 1 month ago

Let me know (with picture or text attached) the errors/logs.

My attempts has:

[ 99% 13249/13254] Install: out/target/product/a2coreltejx/recovery/root/relink_binaries-timestamp
[ 99% 13250/13254] Install: out/target/product/a2coreltejx/recovery/root/system/bin/recovery
[ 99% 13251/13254] ----- Making uncompressed recovery ramdisk ------
[ 99% 13252/13254] ----- Making compressed recovery ramdisk ------
[ 99% 13253/13254] build out/target/product/a2coreltejx/recovery.img
FAILED: out/target/product/a2coreltejx/recovery.img
/bin/bash -c "(out/host/linux-x86/bin/mkbootimg --kernel  out/target/product/a2coreltejx/kernel   --ramdisk out/target/product/a2coreltejx/ramdisk-recovery.img --cmdline \"androidboot.selinux=permissive buildvariant=eng\" --base 0x10000000 --pagesize 2048 --recovery_dtbo  --os_version 11 --os_patch_level 2099-12-31 --ramdisk_offset 0x01000000 --tags_offset 0x00000100 --pagesize 2048 --board \"SRPSB19D014RU\" --second_offset 0x00f00000 --dt device/samsung/a2coreltejx/prebuilt/dt.img --output  out/target/product/a2coreltejx/recovery.img ) && (size=\$(for i in  out/target/product/a2coreltejx/recovery.img; do stat -c \"%s\" \"\$i\" | tr -d '\\n'; echo +; done; echo 0); total=\$(( \$( echo \"\$size\" ) )); printname=\$(echo -n \" out/target/product/a2coreltejx/recovery.img\" | tr \" \" +); maxsize=\$((   39845888-0)); if [ \"\$total\" -gt \"\$maxsize\" ]; then echo \"error: \$printname too large (\$total > \$maxsize)\"; false; elif [ \"\$total\" -gt \$((maxsize - 32768)) ]; then echo \"WARNING: \$printname approaching size limit (\$total now; limit \$maxsize)\"; fi )"
usage: mkbootimg [-h] [--kernel KERNEL] [--ramdisk RAMDISK] [--second SECOND]
                 [--dtb DTB]
                 [--recovery_dtbo RECOVERY_DTBO | --recovery_acpio RECOVERY_ACPIO]
                 [--cmdline CMDLINE] [--vendor_cmdline VENDOR_CMDLINE]
                 [--base BASE] [--kernel_offset KERNEL_OFFSET]
                 [--ramdisk_offset RAMDISK_OFFSET]
                 [--second_offset SECOND_OFFSET] [--dtb_offset DTB_OFFSET]
                 [--os_version OS_VERSION] [--os_patch_level OS_PATCH_LEVEL]
                 [--tags_offset TAGS_OFFSET] [--board BOARD]
                 [--pagesize {2048,4096,8192,16384}] [--id]
                 [--header_version HEADER_VERSION] [-o OUTPUT]
                 [--vendor_boot VENDOR_BOOT] [--vendor_ramdisk VENDOR_RAMDISK]
mkbootimg: error: ambiguous option: --dt could match --dtb, --dtb_offset
ninja: build stopped: subcommand failed.
05:10:52 ninja failed with: exit status 1
Error: Process completed with exit code 1.

We know the normal recovery.img has dtbo file. But with Samis, specially DOWLOAD MODE so maybe need unpacking Image-dt and put in the DT. Some flags need to do that compiling/repacking recovery.img correctlly.

The stock firmware has dtbo.img file?

Minionguyjpro commented 1 month ago

Let me know (with picture or text attached) the errors/logs.

My attempts has:

[ 99% 13249/13254] Install: out/target/product/a2coreltejx/recovery/root/relink_binaries-timestamp
[ 99% 13250/13254] Install: out/target/product/a2coreltejx/recovery/root/system/bin/recovery
[ 99% 13251/13254] ----- Making uncompressed recovery ramdisk ------
[ 99% 13252/13254] ----- Making compressed recovery ramdisk ------
[ 99% 13253/13254] build out/target/product/a2coreltejx/recovery.img
FAILED: out/target/product/a2coreltejx/recovery.img
/bin/bash -c "(out/host/linux-x86/bin/mkbootimg --kernel  out/target/product/a2coreltejx/kernel   --ramdisk out/target/product/a2coreltejx/ramdisk-recovery.img --cmdline \"androidboot.selinux=permissive buildvariant=eng\" --base 0x10000000 --pagesize 2048 --recovery_dtbo  --os_version 11 --os_patch_level 2099-12-31 --ramdisk_offset 0x01000000 --tags_offset 0x00000100 --pagesize 2048 --board \"SRPSB19D014RU\" --second_offset 0x00f00000 --dt device/samsung/a2coreltejx/prebuilt/dt.img --output  out/target/product/a2coreltejx/recovery.img ) && (size=\$(for i in  out/target/product/a2coreltejx/recovery.img; do stat -c \"%s\" \"\$i\" | tr -d '\\n'; echo +; done; echo 0); total=\$(( \$( echo \"\$size\" ) )); printname=\$(echo -n \" out/target/product/a2coreltejx/recovery.img\" | tr \" \" +); maxsize=\$((   39845888-0)); if [ \"\$total\" -gt \"\$maxsize\" ]; then echo \"error: \$printname too large (\$total > \$maxsize)\"; false; elif [ \"\$total\" -gt \$((maxsize - 32768)) ]; then echo \"WARNING: \$printname approaching size limit (\$total now; limit \$maxsize)\"; fi )"
usage: mkbootimg [-h] [--kernel KERNEL] [--ramdisk RAMDISK] [--second SECOND]
                 [--dtb DTB]
                 [--recovery_dtbo RECOVERY_DTBO | --recovery_acpio RECOVERY_ACPIO]
                 [--cmdline CMDLINE] [--vendor_cmdline VENDOR_CMDLINE]
                 [--base BASE] [--kernel_offset KERNEL_OFFSET]
                 [--ramdisk_offset RAMDISK_OFFSET]
                 [--second_offset SECOND_OFFSET] [--dtb_offset DTB_OFFSET]
                 [--os_version OS_VERSION] [--os_patch_level OS_PATCH_LEVEL]
                 [--tags_offset TAGS_OFFSET] [--board BOARD]
                 [--pagesize {2048,4096,8192,16384}] [--id]
                 [--header_version HEADER_VERSION] [-o OUTPUT]
                 [--vendor_boot VENDOR_BOOT] [--vendor_ramdisk VENDOR_RAMDISK]
mkbootimg: error: ambiguous option: --dt could match --dtb, --dtb_offset
ninja: build stopped: subcommand failed.
05:10:52 ninja failed with: exit status 1
Error: Process completed with exit code 1.

We know the normal recovery.img has dtbo file. But with Samis, specially DOWLOAD MODE so maybe need unpacking Image-dt and put in the DT. Some flags need to do that compiling/repacking recovery.img correctlly.

The stock firmware has dtbo.img file?

Seems to be the twrp-11 branch? When I build it from the twrp-9.0 branch it works, and I get an image. Only I get that invalid ramdisk length error..., also trying to port another device built using the twrp-12.1 branch: https://github.com/Minionguyjpro/android_device_incar_Tab11WiFi_NEU (this one's interesting, it has a MediaTek SoC and the recovery on the boot partition. I hope I made this one a little better (used the help of aospdtgen to make a basic structure) but tried optimizing and filling out further and for TWRP as needed)

I should check, I tried using dumpyara to dump some stuff from it (boot, recovery, system AND vendor images are dumped, I looked through them but I haven't seen a dtbo file yet)

Minionguyjpro commented 1 month ago

Also, I still have to initialize my TWRP AOSP manifest build environment. I did it but I need to do some more testing before I can try compiling TWRP-11.0 myself later. Right now I try the other device since I am curious with the twrp-12.1 branch (the device is running Android 12 on stock).

lopestom commented 1 month ago

Seems to be the twrp-11 branch? When I build it from the twrp-9.0 branch it works, and I get an image. Only I get that invalid ramdisk length error..., also trying to port another device built using the twrp-12.1 branch: https://github.com/Minionguyjpro/android_device_incar_Tab11WiFi_NEU (this one's interesting, it has a MediaTek SoC and the recovery on the boot partition. I hope I made this one a little better (used the help of aospdtgen to make a basic structure) but tried optimizing and filling out further and for TWRP as needed)

I should check, I tried using dumpyara to dump some stuff from it (boot, recovery, system AND vendor images are dumped, I looked through them but I haven't seen a dtbo file yet)

Logs?? Answer about dtbo??

Other device so other Issue tab!!! twrp-9.0 with omni or twrp ?

Also, I still have to initialize my TWRP AOSP manifest build environment. I did it but I need to do some more testing before I can try compiling TWRP-11.0 myself later. Right now I try the other device since I am curious with the twrp-12.1 branch (the device is running Android 12 on stock).

Devices shipperd with A12 and 32MB size of recovery.img or boot.img: https://github.com/lopestom/twrp_device_ulefone_Power_Armor14_Pro/releases/tag/Encrypt_Decrypt

Minionguyjpro commented 1 month ago

Seems to be the twrp-11 branch? When I build it from the twrp-9.0 branch it works, and I get an image. Only I get that invalid ramdisk length error..., also trying to port another device built using the twrp-12.1 branch: https://github.com/Minionguyjpro/android_device_incar_Tab11WiFi_NEU (this one's interesting, it has a MediaTek SoC and the recovery on the boot partition. I hope I made this one a little better (used the help of aospdtgen to make a basic structure) but tried optimizing and filling out further and for TWRP as needed) I should check, I tried using dumpyara to dump some stuff from it (boot, recovery, system AND vendor images are dumped, I looked through them but I haven't seen a dtbo file yet)

Logs?? Answer about dtbo??

Other device so other Issue tab!!! twrp-9.0 with omni or twrp ?

Also, I still have to initialize my TWRP AOSP manifest build environment. I did it but I need to do some more testing before I can try compiling TWRP-11.0 myself later. Right now I try the other device since I am curious with the twrp-12.1 branch (the device is running Android 12 on stock).

Devices shipperd with A12 and 32MB size of recovery.img or boot.img: https://github.com/lopestom/twrp_device_ulefone_Power_Armor14_Pro/releases/tag/Encrypt_Decrypt

Don't know whether I have logs from my IDE, maybe. I haven't seen anything about a dtbo image or partition yet, I wasn't able to find it.

There is a dt.img though.

lopestom commented 1 month ago

There is a dt.img though.

Obviusly! If recovery.img has so ...........

Minionguyjpro commented 1 month ago

There is a dt.img though.

Obviusly! If recovery.img has so ...........

So any idea what to do about the invalid ramdisk length error when I try to boot my built TWRP image?

lopestom commented 1 month ago

There is a dt.img though.

Obviusly! If recovery.img has so ...........

So any idea what to do about the invalid ramdisk length error when I try to boot my built TWRP image?

I need look these text/image/log to know. Upload TWRP img compiled for analyse that.

Minionguyjpro commented 1 month ago

There is a dt.img though.

Obviusly! If recovery.img has so ...........

So any idea what to do about the invalid ramdisk length error when I try to boot my built TWRP image?

I need look these text/image/log to know. Upload TWRP img compiled for analyse that.

There you go (I used the device tree from the twrp-9.0 branch in this repository and I also used that manifest to build TWRP): build.txt I also think that only the OS is 32 bits. I've looked into the kernel sources and it seems like the kernel was configured for this device to be AArch64, but did allow 32 bit mode (which you'd expect on 64 bit). So I also think I can compile TWRP in 64 bit, but I have already tried both in 64 and 32 bit and am experiencing the same issue. You'd think that the issue lays in the BoardConfig.mk containing the incorrect ramdisk offsets, but it SHOULD be correct. How were you able to get the dtb.img from my device by the way? I had cloned your twrp-9.0 branch and saw that it contained a dtb.img, which I wasn't able to find in the boot and recovery image???

Minionguyjpro commented 1 month ago

I may have found the ramdisk issue. The sizes of the recovery partition aren't filled in and also not the board uses full recovery image thing. I will fill in those and see whether that helps.

EDIT: now I found it for real (I looked at the wrong branch so the above doesn't apply). The ramdisk is way bigger with TWRP, I think it is too big. I'll try enabling LZMA in the kernel sources and compile the kernel. After that I'll put the newly built kernel in my device tree and use a tool to compress the ramdisk image in my device tree and see...

lopestom commented 1 month ago

How were you able to get the dtb.img from my device by the way? I had cloned your twrp-9.0 branch and saw that it contained a dtb.img, which I wasn't able to find in the boot and recovery image???

a2corelte_dump

lopestom commented 1 month ago

I had cloned your twrp-9.0 branch and saw that it contained a dtb.img, which I wasn't able to find in the boot and recovery image???

It's?? https://github.com/rabikishanr/device_samsung_a2corelte-twrp/releases

Minionguyjpro commented 1 month ago

I had cloned your twrp-9.0 branch and saw that it contained a dtb.img, which I wasn't able to find in the boot and recovery image???

It's?? https://github.com/rabikishanr/device_samsung_a2corelte-twrp/releases

Hmm, I didn't know he also had a device tree. Anyways I tried booting it (no ramdisk length error so that's good) but it's giving me a black screen...

EDIT: seems like he's also compressing the ramdisk in LZMA, but black screen... I think I'll have to enable LZMA support in the kernel and compile it, then add it to the device tree, build and see...

Minionguyjpro commented 1 month ago

I DID IT! TWRP booted on my old phone by doing that. But touch is NOT working, so I'll have to look into drivers for that...

Okay so:

Minionguyjpro commented 1 month ago

Data seems almost working, but is read only for TWRP?! For the SD card I tried adding vold, but it didn't work, maybe more is needed or something else is needed. Also tried some firmware files and the manifests for vendor, but it's not working...

lopestom commented 1 month ago

I DID IT! TWRP booted on my old phone by doing that. But touch is NOT working, so I'll have to look into drivers for that...

Okay so:

  • Touch is not working, but USB is working. I can move using a USB mouse.
  • Mount for data, the SD card and product is NOT working properly. That needs to be fixed.
  • Mounting the system, cache, EFS and vendor partition, works.

The touch may be directly related to the kernel, but it may have its own driver files located in specific folders. Read this: Touchscreen not working in custom recovery on Mediatek devices - MTK - mtxxxx.md

Since you opened a new Issue about decryption, you will close this Issue as resolved since you managed to compile the img file.

Minionguyjpro commented 1 month ago

I DID IT! TWRP booted on my old phone by doing that. But touch is NOT working, so I'll have to look into drivers for that...

Okay so:

  • Touch is not working, but USB is working. I can move using a USB mouse.
  • Mount for data, the SD card and product is NOT working properly. That needs to be fixed.
  • Mounting the system, cache, EFS and vendor partition, works.

The touch may be directly related to the kernel, but it may have its own driver files located in specific folders. Read this: Touchscreen not working in custom recovery on Mediatek devices - MTK - mtxxxx.md

Since you opened a new Issue about decryption, you will close this Issue as resolved since you managed to compile the img file.

I did, but that's for another DT. Also, the driver seems to be the synaptics_rmi4_i2c, on which I can find nothing in my device's partitions. Maybe the driver was written for 32 bit mode only preventing it from working on 64 bit (TWRP is, OS is not)

lopestom commented 1 month ago

. Also, the driver seems to be the synaptics_rmi4_i2c, on which I can find nothing in my device's partitions.

https://github.com/LineageOS/android_device_lge_bullhead/blob/lineage-16.0/synaptics_rmi4_i2c.idc

Install device info hw and in the 3 point settings so enable all. Look about touch driver and let me know with SS.

If same it's or same by your device so maybe searching any DT to that devices can help!?

Any .ko or .bin file in the boot.img, system.img and vendor.img\vendor\firmware or \vendor\lib\modules\ ??

Any *.rc file have symlink some adress to touch?

Maybe is need compiling kernel and fix touch?? https://github.com/synaptics-touch/synaptics-dsx-i2c/tree/master on xda has other device with same problem but I cant find that now.

Ed: hmmmm that's related to 'keylayout` https://gerrit.twrp.me/plugins/gitiles/android_device_samsung_j5lte/+/77579b05b2012b426def6484e9a754fef78dfa22/device.mk#143

Ed2: Maybe disable other harware driver can help? https://gerrit.twrp.me/plugins/gitiles/android_device_samsung_j5lte/+/77579b05b2012b426def6484e9a754fef78dfa22/BoardConfig.mk#218

Minionguyjpro commented 1 month ago

. Also, the driver seems to be the synaptics_rmi4_i2c, on which I can find nothing in my device's partitions.

https://github.com/LineageOS/android_device_lge_bullhead/blob/lineage-16.0/synaptics_rmi4_i2c.idc

Install device info hw and in the 3 point settings so enable all. Look about touch driver and let me know with SS.

If same it's or same by your device so maybe searching any DT to that devices can help!?

Any .ko or .bin file in the boot.img, system.img and vendor.img\vendor\firmware or \vendor\lib ??

Any *.rc file have symlink some adress to touch?

Maybe is need compiling kernel and fix touch?? https://github.com/synaptics-touch/synaptics-dsx-i2c/tree/master on xda has other device with same problem but I cant find that now.

Ed: hmmmm that's related to 'keylayout` https://gerrit.twrp.me/plugins/gitiles/android_device_samsung_j5lte/+/77579b05b2012b426def6484e9a754fef78dfa22/device.mk#143

Ed2: Maybe disable other harware driver can help? https://gerrit.twrp.me/plugins/gitiles/android_device_samsung_j5lte/+/77579b05b2012b426def6484e9a754fef78dfa22/BoardConfig.mk#218

I'll try it next Saturday, I'm away for now. But I will try it next week and see...

Minionguyjpro commented 1 month ago

. Also, the driver seems to be the synaptics_rmi4_i2c, on which I can find nothing in my device's partitions.

https://github.com/LineageOS/android_device_lge_bullhead/blob/lineage-16.0/synaptics_rmi4_i2c.idc

Install device info hw and in the 3 point settings so enable all. Look about touch driver and let me know with SS.

If same it's or same by your device so maybe searching any DT to that devices can help!?

Any .ko or .bin file in the boot.img, system.img and vendor.img\vendor\firmware or \vendor\lib ??

Any *.rc file have symlink some adress to touch?

Maybe is need compiling kernel and fix touch?? https://github.com/synaptics-touch/synaptics-dsx-i2c/tree/master on xda has other device with same problem but I cant find that now.

Ed: hmmmm that's related to 'keylayout` https://gerrit.twrp.me/plugins/gitiles/android_device_samsung_j5lte/+/77579b05b2012b426def6484e9a754fef78dfa22/device.mk#143

Ed2: Maybe disable other harware driver can help? https://gerrit.twrp.me/plugins/gitiles/android_device_samsung_j5lte/+/77579b05b2012b426def6484e9a754fef78dfa22/BoardConfig.mk#218

I'll try it next Saturday, I'm away for now. But I will try it next week and see...

But to say, I did not find anything about the Synaptics driver in the firmware...

lopestom commented 1 month ago

But to say, I did not find anything about the Synaptics driver in the firmware...

Sometimes the files not have same name of hardware driver. https://gerrit.twrp.me/plugins/gitiles/android_device_samsung_j5lte/+/77579b05b2012b426def6484e9a754fef78dfa22/rootdir/etc/init.target.rc#175

lopestom commented 1 month ago

on xda has other device with same problem but I cant find that now.

https://xdaforums.com/t/mediatek-touchscreen-issues-in-custom-recovery-fixed-edit-touchscreen-drivers.4612867/

Minionguyjpro commented 1 month ago

on xda has other device with same problem but I cant find that now.

https://xdaforums.com/t/mediatek-touchscreen-issues-in-custom-recovery-fixed-edit-touchscreen-drivers.4612867/

I will add the change here and try it out next week.

Minionguyjpro commented 1 month ago

Just looked through the kernel source and I were able to find that secure touch for the Synaptics RMI I2C thing. Maybe adding that part to set the permissions to the init RC file may help. The stock recovery was never made and configured to include touch support, so I'm not too confused of this happening.

Minionguyjpro commented 1 month ago

It was in the dump, in the boot image. There there is an init RC file containing a section to set permissions for the touchscreen. I have added this part to the recovery its init RC file here. It was at on fs and so did I place it here. Do I however need to keep the chown for the user and group system or set it to like user root and shell, just like for everything else was set for the stock recovery (there is a tmp section in the init RC file here, that's what I mean)

Minionguyjpro commented 1 month ago

Also, any idea what I could do about that 0MB data (Not mounting. Formatting it works but it still doesn't work properly after doing so (Of course I rebooted after formatting). Would adding the mke2fs.conf file help this?). The same happens with the external SD card...

EDIT: mke2fs is only for EXT2/3/4 filesystems, but this device uses F2FS for the data partition...

lopestom commented 1 month ago

Also, any idea what I could do about that 0MB data (Not mounting. Formatting it works but it still doesn't work properly after doing so (Of course I rebooted after formatting). Would adding the mke2fs.conf file help this?). The same happens with the external SD card...

We writing about twrp-9.0 branch?

Since your DT has https://github.com/Minionguyjpro/android_device_samsung_a2corelte/blob/ef3c6e2004ef93bd9ac0c009fd87328e409fb374/BoardConfig.mk#L58C1-L58C35

So the more problem (my opinion) is if TWRP not look the internal storage adress like https://github.com/Minionguyjpro/android_device_samsung_a2corelte/blob/ef3c6e2004ef93bd9ac0c009fd87328e409fb374/BoardConfig.mk#L67

Since your device has A8.1 so maybe you need look any flag to decryption/crypto mode like https://github.com/Minionguyjpro/android_device_samsung_a2corelte/blob/ef3c6e2004ef93bd9ac0c009fd87328e409fb374/BoardConfig.mk#L84 Maybe I'm stuched but I not see this https://github.com/TeamWin/android_device_qcom_twrp-common/tree/android-8.1?tab=readme-ov-file#twrp-common-decryption-files in your BoardConfig.mk DT!! Never look import /init.recovery.qcom_decrypt.rc or others TWRP Common Decryption files. Specially in the https://github.com/Minionguyjpro/android_device_samsung_a2corelte/blob/twrp-9.0/omni.dependencies putting the common repo.

What reason you have init.rc?? Source Code of TWRP has that and maybe overwriting your file?! Check! Maybe renaming init.rc to init..samsungexynos7870.rc is better? Maybe trying create with https://github.com/TeamWin/android_device_oneplus_cheeseburger_dumpling/blob/android-8.1/recovery/root/init.recovery.qcom.rc ?! or with https://github.com/TeamWin/android_device_xiaomi_onclite/blob/android-10.0/recovery/root/init.recovery.qcom.rc ??

EDIT: mke2fs is only for EXT2/3/4 filesystems, but this device uses F2FS for the data partition...

In the https://github.com/Minionguyjpro/android_device_samsung_a2corelte/blob/twrp-9.0/BoardConfig.mk#L42-L45 I not see about f2fs fs........ like this:

BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE := fsfs

Maybe putting?

TARGET_CRYPTFS_HW_PATH := vendor/qcom/opensource/commonsys/cryptfs_hw
TARGET_HW_DISK_ENCRYPTION := true

How you want TWRP decrypt \Data if you not prepare DT to have that?! 🙃 🤐 🤔

Minionguyjpro commented 1 month ago

Also, any idea what I could do about that 0MB data (Not mounting. Formatting it works but it still doesn't work properly after doing so (Of course I rebooted after formatting). Would adding the mke2fs.conf file help this?). The same happens with the external SD card...

We writing about twrp-9.0 branch?

Since your DT has https://github.com/Minionguyjpro/android_device_samsung_a2corelte/blob/ef3c6e2004ef93bd9ac0c009fd87328e409fb374/BoardConfig.mk#L58C1-L58C35

So the more problem (my opinion) is if TWRP not look the internal storage adress like https://github.com/Minionguyjpro/android_device_samsung_a2corelte/blob/ef3c6e2004ef93bd9ac0c009fd87328e409fb374/BoardConfig.mk#L67

Since your device has A8.1 so maybe you need look any flag to decryption/crypto mode like https://github.com/Minionguyjpro/android_device_samsung_a2corelte/blob/ef3c6e2004ef93bd9ac0c009fd87328e409fb374/BoardConfig.mk#L84 Maybe I'm stuched but I not see this https://github.com/TeamWin/android_device_qcom_twrp-common/tree/android-8.1?tab=readme-ov-file#twrp-common-decryption-files in your BoardConfig.mk DT!! Never look import /init.recovery.qcom_decrypt.rc or others TWRP Common Decryption files. Specially in the https://github.com/Minionguyjpro/android_device_samsung_a2corelte/blob/twrp-9.0/omni.dependencies putting the common repo.

What reason you have init.rc?? Source Code of TWRP has that and maybe overwriting your file?! Check! Maybe renaming init.rc to init..samsungexynos7870.rc is better? Maybe trying create with https://github.com/TeamWin/android_device_oneplus_cheeseburger_dumpling/blob/android-8.1/recovery/root/init.recovery.qcom.rc ?! or with https://github.com/TeamWin/android_device_xiaomi_onclite/blob/android-10.0/recovery/root/init.recovery.qcom.rc ??

EDIT: mke2fs is only for EXT2/3/4 filesystems, but this device uses F2FS for the data partition...

In the https://github.com/Minionguyjpro/android_device_samsung_a2corelte/blob/twrp-9.0/BoardConfig.mk#L42-L45 I not see about f2fs fs........ like this:

BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE := fsfs

Maybe putting?

TARGET_CRYPTFS_HW_PATH := vendor/qcom/opensource/commonsys/cryptfs_hw
TARGET_HW_DISK_ENCRYPTION := true

How you want TWRP decrypt \Data if you not prepare DT to have that?! 🙃 🤐 🤔

This device has the Exynos SoC, remember? The other device (gtowifi) has the Qualcomm..., but I will do changes like the LUN path, fix that fs type in the BoardConfig.mk and rename the init.rc file.

EDIT: found references to the use of dm crypt which makes use of the crypto API, haven't seen anything about FDE or full HW disk encryption. Mostly I thought that encrypted data would mount and show up but with random directories, but that may be different depending on the encryption algorithm. But you may be right that the encryption is in the way here (I feel like it's relatively easy to get it to work with this device but that's just me).

lopestom commented 1 month ago

This device has the Exynos SoC, remember? The other device (gtowifi) has the Qualcomm..., but I will do changes like the LUN path, fix that fs type in the BoardConfig.mk and rename the init.rc file.

Maybe you not undertood me. All is reference/example to you know and compare because has: https://github.com/Minionguyjpro/android_device_samsung_a2corelte/blob/twrp-9.0/recovery/root/init.recovery.samsungexynos7870.rc#L96-L104

But every time the TWRP(recovery) need permissions like: https://github.com/TeamWin/android_device_xiaomi_onclite/blob/android-10.0/recovery/root/init.recovery.qcom.rc#L50-L53

Therefore I not see any files in your DT (\system or and \vendor) to encryption/decryption attempts!

EDIT: found references to the use of dm crypt which makes use of the crypto API, haven't seen anything about FDE or full HW disk encryption. Mostly I thought that encrypted data would mount and show up but with random directories, but that may be different depending on the encryption algorithm. But you may be right that the encryption is in the way here (I feel like it's relatively easy to get it to work with this device but that's just me).

Some Issues or "problems" with encryption/decryption mode in TWRP was solved in the next TWRPversion. With A8.1 you need know waht your device have encryption/decryption mode so test with branch twrp-9.0, twrp-10 or twrp-11 to know if that's good. FDE is a type about crypt and FBE is other from Android 10. Searched any Exynos SoC Custom Recovery repo to know if encryption/decryption mode is fully working??

Minionguyjpro commented 1 month ago

I will relook into this all of this once it's Saturday. Today was a pretty heavy day due to car problems and I prefer to spend my last real day of vacation (away, not in total. I have three more weeks to come...) doing probably some other stuff. But I'll continue when I am back on my laptop with a good overview of everything.

Minionguyjpro commented 1 month ago

Okay great, the tree is causing a bootloop now showing a black screen and then reboots the device when entering the recovery...

Minionguyjpro commented 1 month ago

Okay great, the tree is causing a bootloop now showing a black screen and then reboots the device when entering the recovery...

Fixed, not sure what did it.

Minionguyjpro commented 1 month ago

Touchscreen still not working, it even doesn't show up in /sys/class, so I guess I DO need a driver.

Minionguyjpro commented 1 month ago

There is a .ihex file in the kernel about the touch in the recovery, see https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/main/firmware/tsp_synaptics/td4101_a2corelte_recovery.fw.ihex.

Minionguyjpro commented 1 month ago

Also, renaming it from init.rc to init.samsungexynos7870.rc makes it problematic actually. It causes the black screen issue, I just checked. I may know something to fix it but I'll have to check.

Minionguyjpro commented 1 month ago

Would it be worth trying to replace the recovery's FW's contents to have the exact same contents as the original one (the .ihex file without the recovery part in it) and compile?

EDIT: I don't see anymore why the kernel would need changes, it already includes all the needed drivers and even the firmware. So what could it be hmm. Blocking the accelerometer also doesn't help it, and the secure TS part in the init RC file doesn't work since there is no /sys/class/sec and then something for secure touch or something. It still feels like it doesn't detect the touchscreen (missing drivers or firmware, or it doesn't load correctly?)

lopestom commented 1 month ago

It still feels like it doesn't detect the touchscreen (missing drivers or firmware, or it doesn't load correctly

How I wrote before the kernel can have permissions or not have boot in the scripts drivers. But you can read this: Touchscreen not working in custom recovery on Mediatek devices - MTK - mtxxxx.md for more attempts. That's not only to Mediatek devices.

I wrote to you specially https://gist.github.com/lopestom/685cdd9c71476e9daf95ca612066e23f#updating-some-information-for-android-13 to know about touchscreen driver

Install device info hw

lopestom commented 1 month ago

There is a .ihex file in the kernel about the touch in the recovery, see https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/main/firmware/tsp_synaptics/td4101_a2corelte_recovery.fw.ihex.

Obvliuslly with kernel source code is better so in the config you can see: https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/arch/arm64/configs/exynos7870-a2corelte_defconfig#L1798-L1799

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/drivers/input/touchscreen/synaptics_td4x00/Kconfig#L11

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/tree/bfdf04ea29b3653abc9ab04d958338fed82ca61b/drivers/input/touchscreen

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/drivers/input/touchscreen/mtouch.c#L2

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/drivers/input/touchscreen/of_touchscreen.c#L2

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/arch/arm64/configs/exynos7870-a2corelte_defconfig#L1728-L1729

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/drivers/input/touchscreen/sec_ts/sec_ts_only_vendor.c#L1

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/drivers/input/touchscreen/sec_ts/sec_ts_fw.c#L604

May be other reason is Samis not put touch in the recovery mode or has blocked or need more in the script to permissions or maybe if not have \Data decripted so not have touchscreen. Only you can find something.

Minionguyjpro commented 1 month ago

There is a .ihex file in the kernel about the touch in the recovery, see https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/main/firmware/tsp_synaptics/td4101_a2corelte_recovery.fw.ihex.

Obvliuslly with kernel source code is better so in the config you can see: https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/arch/arm64/configs/exynos7870-a2corelte_defconfig#L1798-L1799

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/drivers/input/touchscreen/synaptics_td4x00/Kconfig#L11

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/tree/bfdf04ea29b3653abc9ab04d958338fed82ca61b/drivers/input/touchscreen

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/drivers/input/touchscreen/mtouch.c#L2

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/drivers/input/touchscreen/of_touchscreen.c#L2

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/arch/arm64/configs/exynos7870-a2corelte_defconfig#L1728-L1729

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/drivers/input/touchscreen/sec_ts/sec_ts_only_vendor.c#L1

https://github.com/Minionguyjpro/android_kernel_samsung_exynos7870/blob/bfdf04ea29b3653abc9ab04d958338fed82ca61b/drivers/input/touchscreen/sec_ts/sec_ts_fw.c#L604

May be other reason is Samis not put touch in the recovery mode or has blocked or need more in the script to permissions or maybe if not have \Data decripted so not have touchscreen. Only you can find something.

I just feel like the touchscreen isn't being detected in the recovery at all, since I cannot find anything in /sys back about the synaptics touchscreen.

Also interesting, the data partition mount is working when changing the filesystem to EXT4 (I know, this removes encryption of course). Even if I change it back to F2FS then, it shows up as 0MB, but when I change it back to EXT4 again then it shows again up with the correct size and is able to mount.

Minionguyjpro commented 1 month ago

I see CONFIG_F2FS_FS_SECURITY=y in the kernel, would disabling this maybe allow permissions to the F2FS system?

Minionguyjpro commented 1 month ago

Ah wait now it's F2FS and does seem to work... Probably the encryption is in the way maybe.

EDIT: and not anymore..., something while using F2FS doesn't like it. Or, I think it IS the encryption. It was working with F2FS until I rebooted into the system.

Minionguyjpro commented 1 month ago

The kernel also contains some dts files for the device tree structure. I can however find nothing back in it about the synaptics thing...

EDIT: kernel source doesn't contain anything about the synaptics rmi4 firmware or touchscreen (dts files in arch/arm64/boot/dts), but a .dtb extracted from the stock boot.img, then converted to a readable format from .dts DOES contain the synaptics stuff. Not sure how I can get this added to the kernel's device tree stuff?

This could explain why touch isn't working in the recovery, since I rebuilt the kernel from the kernel source since I had to enable LZMA compression support for the ramdisk, but if the dts files and device tree stuff contains nothing about the synaptics stuff then yeah...

I feel like it will be needed to patch the dts files in the kernel source in order to get touch to work.

EDIT 2: Nevermind, this is why the device tree DT file is included. It includes those details about the synaptics driver, but it still doesn't work..., I managed to compile the kernel to get a .fw file of the touch, can I utilise this somehow?

EDIT 3: Okay great now the TWRP is booting it into download mode everytime (older version still works so it isn't a security thing causing it)! I still however don't think I have to add any firmware, it is already built into the kernel. I may go over and copy the touch code of the boot to the recovery one and see.

EDIT 4: Fixed. Touchscreen still not working, but checked and the drivers and firmware are available in the recovery image. Not sure what to do next...

Minionguyjpro commented 1 month ago

Turns out this device DOES have a DTBO partition, I dumped it to a dtbo.img (it's around 2MB), is it still relevant to use this somehow?

Minionguyjpro commented 1 month ago

Interesting, seems like the driver BLOCKS since it's in recovery mode, dmesg in TWRP shows:

[    7.818112]  [1:      swapper/0:    1] Successfully registered hid_synaptics_driver
[    9.253594]  [1:      swapper/0:    1] synaptics_rmi4_i2c 7-004b: synaptics_rmi4_probe : Do not load driver due to : device entered recovery mode 2

EDIT: found the error in the code of the driver in the kernel source. Removed the if part and hope it may work now!

EDIT 2: GET THE CAKE! TOUCH IS NOW WORKING ON TWRP ON THIS PHONE!

Minionguyjpro commented 1 month ago

Okay I'm getting further into troubleshooting the issues. The MMC2 (SD card, MMC0 is the phone's flash chip) does seem to get detected looking at dmesg, but nothing else. I don't see a way to mount the block device (there's nothing in /dev/block) nor can't I get using vold to work (if needed). Found out that the Data partition is probably not mounting with crypto because of this: [ 12.121174] [1: recovery: 2373] F2FS-fs (mmcblk0p26): Cannot load crc32 driver..

I've looked up things about this driver or library, it seems included with the kernel.

Minionguyjpro commented 1 month ago

Giving more information about this, the device seems to use Crypto with AES, DES or Twofish as cipher, and either CRC32C, CRC32 (probably this one), MD5, SHA-1, SHA-256 or SHA-512 as digest.

Minionguyjpro commented 1 month ago

I tried TW_CRYPTO_USE_SBIN_VOLD := true to no avail...

lopestom commented 1 month ago

I tried TW_CRYPTO_USE_SBIN_VOLD := true to no avail...

I tried TW_CRYPTO_USE_SBIN_VOLD := true to no avail...

Okay I'm getting further into troubleshooting the issues. The MMC2 (SD card, MMC0 is the phone's flash chip) does seem to get detected looking at dmesg, but nothing else. I don't see a way to mount the block device (there's nothing in /dev/block) nor can't I get using vold to work (if needed). Found out that the Data partition is probably not mounting with crypto because of this: [ 12.121174] [1: recovery: 2373] F2FS-fs (mmcblk0p26): Cannot load crc32 driver..

I've looked up things about this driver or library, it seems included with the kernel.

No much time now. But yesterday I can look something about decryption in your device Exynos.

But with that so open new Issue Decrypt and so copy yours 3 msg for we writing better about. I wrote before about some binary files responsable about decryption. All can look in the (I never had device with A8.1) system\vendor\etc\init or vendor\etc\init or/and system\etc\init. I need see names and proprieters into rc files from folders like qseecom and others.

After that so clse this Issue TWRP recovery not building properly as solved.