raspberry-vanilla / android_local_manifest

106 stars 48 forks source link

"adb remount" cannot be used on AOSP14 for RPI4. #47

Closed znlsl closed 7 months ago

znlsl commented 7 months ago

Hi Konsta

I synced to the latest source code and then locally compiled the complete AOSP14 version for RPI4. After the system started, I found that adb remount failed. Is there any other operation required to unlock the BootLoader?

$ adb root $ adb remount Device must be bootloader unlocked

Thank you!

KonstaT commented 7 months ago

Well, there's no bootloader to unlock to begin with.

There was additional check for the bootloader status added in Android 14. You can get around this by adding ro.boot.verifiedbootstate=orange to kernel cmdine (https://github.com/raspberry-vanilla/android_device_brcm_rpi4/blob/android-14.0/BoardConfig.mk#L48).

Or you can just disable the check under system/core instead:

--- a/fs_mgr/fs_mgr_remount.cpp
+++ b/fs_mgr/fs_mgr_remount.cpp
@@ -630,10 +630,12 @@ int main(int argc, char* argv[]) {
         return EXIT_FAILURE;
     }

+    /*
     if (android::base::GetProperty("ro.boot.verifiedbootstate", "") != "orange") {
         LOG(ERROR) << "Device must be bootloader unlocked";
         return EXIT_FAILURE;
     }
+    */

     // Start a threadpool to service waitForService() callbacks as
     // fs_mgr_overlayfs_* might call waitForService() to get the image service.

This gets you further but there's another issue with the boot partition and/or AVB. Can't recall if the error actually caused the remount to fail but this at least gets rid off the nasty warning there still was running adb remount:

--- a/fs_mgr/fs_mgr_remount.cpp
+++ b/fs_mgr/fs_mgr_remount.cpp
@@ -485,7 +485,8 @@ bool do_remount(Fstab& fstab, const std::vector<std::string>& partition_args,
     }

     // Disable verity.
-    auto verity_result = SetVerityState(false /* enable_verity */);
+    //auto verity_result = SetVerityState(false /* enable_verity */);
+    SetVerityStateResult verity_result = {.success = true, .want_reboot = false};

     // Treat error as fatal and suggest reboot only if verity is enabled.
     // TODO(b/260041315): We check the device mapper for any "<partition>-verity" device present
znlsl commented 7 months ago

I followed the above steps, and the remount worked perfectly! Thank you so much!!!

mrarjun commented 6 months ago

Same issue observed in RPI-5 with 14_r20 code base. Tried to update in device/brcm/rpi5/BoardConfig.mk file with below line. But still not able to remount BOARD_KERNEL_CMDLINE += ro.boot.verifiedbootstate=orange How can i fix Device must be bootloader unlocked issue using ro.boot.verifiedbootstate=orange solution?

Not tried to update system/core file.

KonstaT commented 5 months ago

@mrarjun Have you checked that it actually made it to /boot/cmdline.txt?

Adding something to BOARD_KERNEL_CMDLINE with += would only work after it's being defined (https://github.com/raspberry-vanilla/android_device_brcm_rpi5/blob/android-14.0/BoardConfig.mk#L48). It gets otherwise overriden with the := definition.

mrarjun commented 5 months ago

In out/target/product/rpi5/rpiboot/cmdline.txt file displaying as below

console=ttyAMA0,115200 no_console_suspend root=/dev/ram0 rootwait androidboot.hardware=rpi5 ro.boot.verifiedbootstate=orange androidboot.selinux=permissive

Is there any other change expected?

KonstaT commented 5 months ago

In out/target/product/rpi5/rpiboot/cmdline.txt file displaying as below

Yeah, but that's still not /boot/cmdline.txt on the image that you've flashed to the storage device. You can just edit the text file manually to test as well.

Everything you need to know is already explained in https://github.com/raspberry-vanilla/android_local_manifest/issues/47#issuecomment-1829888921.