Appendix A (Legacy User-Space) of the 2013 Karim Yaghmour book Embedded Android describes how to merge a root filesystem based on glibc that contains BusyBox into the AOSP build. But it describes how to make this work in 2.3/Gingerbread.
I'm trying to do the same for the Android 8.1 sources provided with the Orange Pi 4 LTS.
Following the instructions in the book, I copied my cross-compiled build of a root filesystem based on glibc that contains BusyBox to a new directory in my AOSP:
$ ls -lh ~/builds/RK3399-Android8.1/rootfs-glibc
total 20K
-rw-rw-r-- 1 joe joe 584 Mar 18 12:14 Android.mk
drwxrwxr-x 2 joe joe 4.0K Mar 8 12:25 bin
drwxrwxr-x 2 joe joe 4.0K Mar 8 11:29 lib
lrwxrwxrwx 1 joe joe 11 Mar 8 12:25 linuxrc -> bin/busybox
drwxrwxr-x 2 joe joe 4.0K Mar 8 12:25 sbin
drwxrwxr-x 5 joe joe 4.0K Mar 8 11:30 usr
And I created an Android.mk
file matching the one in the book. But it didn't work, so I experimented and adapted it to this:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := rootfs-glibc
# LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
LOCAL_MODULE_CLASS := EXECUTABLES
# This part is a hack, we're doing "addprefix" because if we don't,
# this dependency will be stripped out by the build system
GLIBC_ROOTFS := $(addprefix $(TARGET_ROOT_OUT)/, rootfs-glibc)
$(GLIBC_ROOTFS):
xxxmkdir -p $(TARGET_ROOT_OUT)
cp -af $(TOPDIR)rootfs-glibc/* $(TARGET_ROOT_OUT)
rm $(TARGET_ROOT_OUT)/Android.mk
# The last command just gets rid of this very .mk since it's copied as is
include $(BUILD_PREBUILT)
I know the makefile is getting parsed since I was getting error messages before I added LOCAL_MODULE_CLASS
. But the rules in my $(GLIBC_ROOTFS)
target aren't getting run--confirmed by my deliberate change of mkdir
to xxxmkdir
.
I did some more research and learned about the existence of the Soong Build System, which was "introduced in Android 7.0 (Nougat) to replace Make." But I've searched for example Android.bp
files to do something approximating what I'm trying to do with no success.
It appears I need to use a module type of android_filesystem, but I haven't found an example or clear enough documentation to create my own.
Should I fix my Android.mk
file? How? Or should I use an Android.bp
file?
I reached out to Karim Yaghmour who was kind to answer. He referred me to the exercises in his Embedded Android Training courseware. Go to www.opersys.com/training/embedded-android-training and scroll down. Click on COURSEWARE. (Note the license.) There is a link of the right to the exercises. On page 14 are instructions for downloading an Android.mk file that worked for me (after following the accompanying instructions).