Search code examples
rootandroid-sourceandroid-10.0

How to root your own AOSP build?


We have root access to our AOSP build, when we use:

lunch smarc_mx8mq-eng

How can we get a root shell after using:

lunch smarc_mx8mq-user

This can be any form of temporary hack to the AOSP source, but the build must remain a user build.

I've read about / being mounted with nosetuid, but that doesn't seem to be the case for us:

smarc_mx8mq:/ # mount 
/dev/block/mmcblk1p5 on / type ext4 (ro,seclabel,relatime,block_validity,delalloc,barrier,user_xattr,acl,inode_readahead_blks=8)

(I will check this again once I have built a user build.)

What's the best way of rooting our own AOSP build?


Solution

  • The solution was to flash the boot-debug.img into the boot partition.

    $ sudo fastboot flash boot boot-debug.img
    target reported max download size of 419430400 bytes
    sending 'boot_a' (43252 KB)...
    OKAY [  2.270s]
    writing 'boot_a'...
    OKAY [  2.163s]
    finished. total time: 4.433s
    ...
    $ adb shell
    smarc_mx8mq:/ $ exit
    $ adb root
    restarting adbd as root
    $ adb shell
    smarc_mx8mq:/ #