How to OEM unlock by default on custom Android built image?

5,172 views
Skip to first unread message

Riccardo Bruè

unread,
Jul 30, 2020, 7:27:15 AM7/30/20
to Android Building
I am facing the following problem on a custom iMX8 board (compiled following the vendor's guide) and using Android 10 (I have root access):

When I connect via ADB (over WiFi) I issue the following command:
# mount -o remount rw /system
>> mount: '/system' not in /proc/mounts 

So, I tried to solve such error by issuing this other command:
$ mount -o remount rw /
>> Another IO error occurs

At the end I tried this other command:
$ adb remount
>> Error
$ adb disable-verity 
>> Device is locked. please unlock the device first

So when I try to unlock it following these steps:
  • Settings => System => Advanced => Developer options => OEM unlocking
  • reboot to bootloader (device stuck)
  • type "fastboot 0" in the U-Boot command line
  • run "sudo `which fastboot` oem unlock" from the Host PC (device not seen from the PC)
  • wait until the unlock process is complete
I receive the annoted errors, the device remains stuck (I already opened a ticket with the board vendor and I am waiting for a reply). 

Furthermore, I don't have any display to use with such board so I don't know what is appening (I can communicate via debug serial but it seems that it remains stuck also from there).

So in order to avoid the whole process, I was thinking to directly build a custom version of the Android OS which is directly OEM unlocked so that I can issue the adb remount without any issue, but I am a beginner and I don't know where to start.

sanshan zhang

unread,
Jul 30, 2020, 3:11:06 PM7/30/20
to Android Building


在 2020年7月30日星期四 UTC+8下午7:27:15,Riccardo Bruè写道:
Hi what's the log "the annoted errors, the device remains stuck "  after you unlock the device?
do you "sudo fastboot reboot" after unlock?

If you want to unlock your device directly, you can apply below patch  in uboot.

-- a/drivers/fastboot/fb_fsl/fastboot_lock_unlock.c
+++ b/drivers/fastboot/fb_fsl/fastboot_lock_unlock.c
@@ -360,6 +360,7 @@ FbLockState fastboot_get_lock_stat(void) {
        unsigned char *bdata;
        int mmc_id;
        FbLockState ret;
+ return FASTBOOT_UNLOCK;
        /* uboot used by uuu will boot from USB, always return UNLOCK state */
        if (is_boot_from_usb())
                return g_lockstat;
@@ -404,6 +405,7 @@ fail:
  * which is managed by PresistDataService
  */

+#define CONFIG_ENABLE_LOCKSTATUS_SUPPORT
 #ifdef CONFIG_ENABLE_LOCKSTATUS_SUPPORT
 //Brillo has no presist data partition

Riccardo Bruè

unread,
Aug 3, 2020, 10:21:04 AM8/3/20
to Android Building
Thank you for your reply. I have changed the content of the files according with your answer. Now I am going to test the results. Is your patch enough for substituting the following commands:
  • type "fastboot 0" in the U-Boot command line
  • run "sudo `which fastboot` oem unlock" from the Host PC
I mean, is your patch the "hard-coded" equivalent version of the previous two commands?
Will I be able to call "adb disable-verity" without any issue then?

Thank you very much.

Riccardo Bruè

unread,
Aug 3, 2020, 10:21:11 AM8/3/20
to Android Building
Ok I managed to execute the command "adb disable-verity" which prompts: "already disabled". But I still have the following error: 

# mount -o remount rw /system
>> mount: '/system' not in /proc/mounts 
So I cannot manually push an APK to the /system/priv-app folder. How can I solve this issue?

On Thursday, July 30, 2020 at 9:11:06 PM UTC+2 pete....@nxp.com wrote:

pete....@nxp.com

unread,
Aug 4, 2020, 10:48:52 AM8/4/20
to Android Building
you need do below action:

adb root
adb remount

Now you can mount system partition as rw permission.

Riccardo Bruè

unread,
Aug 4, 2020, 10:48:55 AM8/4/20
to Android Building
I think I solved the previous problem by opening at the /proc/mounts file and looking for the system_a path. Then I mounted that partition and I managed to push the app in the /system/priv-app folder. Could this be the solution?
Reply all
Reply to author
Forward
0 new messages