Create your own Android Automotive OS for your car on Raspberry Pi
Android Automotive is an operating system and platform running directly on the in-vehicle hardware. It is a full-stack, open source, highly customizable platform powering the infotainment experience. Android Automotive supports apps built for Android as well as those built for Android Auto. In this article we gonna need a 8GB or 4GB Raspberry model B.
Setting up a build machine and download the code source
Before building any system first we need a linux machine Ubuntu18 or Ubuntu16 with at least 250GB of free disk space and 16?GB of available RAM is required.
First we need to install some additional packages needed
$ sudo apt-get install -y git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig libncurses5 procps libssl-dev bc fdisk ejec
$ sudo apt-get install -y gcc-aarch64-linux-gnut
also we need to install repo and prepare your environment of build. To prepare this please look at my previous article Trying The Android Open Source Project For The First Time .
Once you have prepare this ! you can start by getting the version of Repo for our case we gonna work with Android 11
$ mkdir android_auto_rpi4 && cd android_auto_rpi4
$ repo init -u https://android.googlesource.com/platform/manifest -b android11-qpr2-release
After running the repo init we add Android Rpi and RpiAutomotive changes to the build. So to get the modifications we need to add a local manifest to the build which we do by running
$ git clone https://github.com/ayariboudour/automotive_rpi_manifests.git .repo/local_manifests -b main
$ repo sync -c -j4
Once the repo sync has completed there are a set of manual modifications you need to do to make it build, take a look at this link.
Build the AAOS
Before starting the build we need to build the kernel
领英推荐
$ ARCH=arm64 scripts/kconfig/merge_config.sh arch/arm64/configs/bcm2711_defconfig kernel/configs/android-base.config kernel/configs/android-recommended.config
$ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make Image.gz
$ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- DTC_FLAGS=”-@” make broadcom/bcm2711-rpi-4-b.dtb
$ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- DTC_FLAGS=”-@” make overlays/vc4-kms-v3d-pi4.dtbo
$ cd ../..
Then we build the AAOS
$ source build/envsetup.sh
$ lunch rpi_car_rpi4-userdebug
$ make -j4 ramdisk systemimage vendorimage
Testing and flashing
The partitions should be created using fdisk with sizes and types as follows
Partitions of the card should be set-up like followings.
p1 128MB for boot : Do fdisk, set W95 FAT32(LBA) & Bootable type, mkfs.vfat
p2 2048MB for /system : Do fdisk, new primary partition
p3 128MB for /vendor : Do fdisk, new primary partition
p4 remainings for /data : Do fdisk, mkfs.ext4
Set volume label of /data partition as userdata
: use -L option for mkfs.ext4, and -n option for mkfs.vfat
Then write the system & vendor partition
$ cd out/target/product/rpi
$ sudo dd if=system.img of=/dev/<p2> bs=1M
$ sudo dd if=vendor.img of=/dev/<p3> bs=1M
Copy kernel & ramdisk to boot partition
device/snappautomotive/rpi/boot/* to p1:/
kernel/arpi/arch/arm64/boot/Image.gz to p1:/
kernel/arpi/arch/arm64/boot/dts/broadcom/bcm2711-rpi-4-b.dtb to p1:/
kernel/arpi/arch/arm64/boot/dts/overlays/vc4-kms-v3d-pi4.dtbo to p1:/overlays/
out/target/product/rpi/ramdisk.img to p1:/
Now hopefully you get to run the Android Automotive OS 11 on a Raspberry Pi, If you have any questions please contact me.