How to install Android Automotive OS 11 on a Raspberry Pi
Although Android Automotive has been announced in 2017, it was only last year that the first car with Android Automotive came on the market. In case you’re wondering, Android Automotive is not the same as Android Auto. While the latter is a simple interface that needs to connect with your mobile to perform most of the functions, Android Automotive is a complete operating system that is 100% integrated into the vehicle, so it does not need any external device to carry out its tasks. functions.
This deeper implementation of Android in cars allows you to do cool things like open the doors, turn on the air conditioning, or turn on the car heating just by asking the Google Assistant. For that reason, there is so much excitement in the auto industry around Android Automotive. Unfortunately, there are still very few manufacturers that have launched or plan to launch, cars with this version of Android for vehicles.
To remedy this situation, a new company called Snapp Automotive has shown that Android Automotive can be added to any car with a Raspberry Pi. In fact, the company created their own Raspberry Pi with this operating system and they explained how they did it step by step. Of course, they did not present it as a tutorial for anyone, much less, but as a guide for those interested in the subject of development.
Android Automotive OS 11 on a Raspberry Pi is possible with this method
To install Android Automotive OS 11 on a Raspberry Pi using the Snapp Automotive method, you will need a 4GB Raspberry Pi 4 Model B and a Waveshare 10.1 ″ touch screen (or similar). 4 GB of RAM was used because this version of Android for cars is based on Android 11 which requires more than 2 GB of RAM. The touch screen, on the other hand, is necessary to view and control all the actions of the operating system. A USB stick is also required to boot the system.
In total, the investment to create the platform proposed by Snapp Automotive (also considering the cost of cables, USB memory, etc.) was 200 euros.
Build Android 11
To compile Android 11 for use on the Raspberry Pi you need reasonably powerful hardware. The creators of Snapp Automotive used a PC with Debian 10. The first thing they did was run the following command to install the additional packages that are needed:
- 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-table-dev libxml2-utils xsltproc unzip fontconfig libncurses5 procps gcc-aarch64-linux-gnu libssl-dev bc fdisk eject
After these items are installed, the Google repository source code is checked for the version labeled android11-qpr2-release following Google’s instructions. When you reach the repo init phase you have to execute:
- repo init -u https://android.googlesource.com/platform/manifest -b android11-qpr2-release
After running repo init have to add Android RPI changes and Snapp Automotive to build. To achieve the necessary modifications, a local manifest must be added to the compilation, so you have to execute:
- git clone https://github.com/snappautomotive/firmware_rpi-local_manifests.git .repo / local_manifests -b sa-main
To finish, we run repo sync as recommended in the Google instructions. Once the repository sync is complete, there are a number of manual modifications that you will have to make. You can find the instructions on the Android RPi Wiki.
Building the Android Linux kernel
So far, the Android RPi project has already created an Android-compatible build of the kernel that will be in its source tree. To build the kernel you must execute the following commands:
- $ cd kernel / arpi
- $ 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 ../ ..
Creation of the image of Android Automotive
Now, to create a complete image of Android Automotive you just have to use these commands:
- $ source build / envsetup.sh
- $ lunch snapp_car_rpi4-userdebug
- $ make -j6 ramdisk systemimage vendorimage
It is worth clarifying that -j6 is used on a PC with four CPU cores. If you have a machine with more cores, you can increase this number.
Preparing the USB memory
Now you have to put the created image on a bootable USB memory (a pendrive, not an SD card) of at least 16 GB . If you have one with more space, the better because that way you can install more apps. Partitions must be created using fdisk with sizes and types like the following:
- Partition 1: W95 FAT32 (LBA), 128MB, bootable.
- Partition 2: Linux, 2GB.
- Partition 3: Linux, 128 MB.
- Partition 4: Linux, all remaining space.
Your USB stick will probably appear as a device starting with / dev / sd on your PC. From now on we will refer to the partitions as / dev / sdX1 and you will have to replace the X with the appropriate letter that your PC assigns to the device. The next step is to create the filesystem on the two partitions that will have files written to them (sdX1 and sdX4). We will write a disk image to the other two partitions so we don’t need to manually create the file systems for them. To create the file systems run the following:
- $ mkfs.vfat / dev / sdX1
- $ mkfs.ext4 / dev / sdX4
Now you have to mount the first partition and add all the files necessary for the Raspberry Pi to boot . To do this, run the following commands from the source code check:
- $ mount / dev / sdX1 / mnt
- $ mkdir / mnt / overlays
- $ cp device / snappautomotive / rpi / boot / * / mnt
- $ cp kernel / arpi / arch / arm64 / boot / Image.gz / mnt
- $ cp kernel / arpi / arch / arm64 / boot / dts / broadcom / bcm2711-rpi-4-b.dtb / mnt
- $ cp kernel / arpi / arch / arm64 / boot / dts / overlays / vc4-kms-v3d-pi4.dtbo / mnt / overlays /
- $ cp out / target / product / rpi / ramdisk.img / mnt
- $ umount / mnt
- $ sync
Final touches and start-up
The last step is to copy the system and vendor images to the sdX2 and sdX3 partitions on the USB stick. This is done by running the following commands from within the source code check:
- $ dd if = out / target / product / rpi / system.img of = / dev / sdX2 bs = 1M
- $ dd if = out / target / product / rpi / vendor.img of = / dev / sdX3 bs = 1M
- $ sync
- $ eject / dev / sdX
Now, you can remove the USB memory, place it in a USB port of the Raspberry Pi and boot it. The first boot may take a couple of minutes or so while Android optimizes the applications on the USB stick.
And this is how you build an Android Automotive OS 11 build for a touchscreen Raspberry Pi using the Snapp Automotive method. What can be done now? Well, install the Android Automotive applications you want on the Raspberry Pi and use everything that this operating system offers.
Obviously, you will not be able to use functions that are born from deep integration with the car (such as opening the doors with your voice), but at least you will not have to have your mobile connected to use Android in the car. For more information about this Snapp Automotive guide, click on the link.