SlideShare a Scribd company logo
Running Android on the Raspberry Pi
Android Pie meets Raspberry Pi
Chris Simmonds
Android Makers 2019
Running Android on the Raspberry Pi 1 Copyright © 2011-2019, 2net Ltd
License
These slides are available under a Creative Commons Attribution-ShareAlike 4.0 license. You can read the full
text of the license here
http://creativecommons.org/licenses/by-sa/4.0/legalcode
You are free to
• copy, distribute, display, and perform the work
• make derivative works
• make commercial use of the work
Under the following conditions
• Attribution: you must give the original author credit
• Share Alike: if you alter, transform, or build upon this work, you may distribute the resulting work only
under a license identical to this one (i.e. include this page exactly as it is)
• For any reuse or distribution, you must make clear to others the license terms of this work
Running Android on the Raspberry Pi 2 Copyright © 2011-2019, 2net Ltd
About Chris Simmonds
• Consultant and trainer
• Author of Mastering Embedded Linux Programming
• Working with embedded Linux since 1999
• Android since 2009
• Speaker at many conferences and workshops
"Looking after the Inner Penguin" blog at http://2net.co.uk/
@2net_software
https://uk.linkedin.com/in/chrisdsimmonds/
Running Android on the Raspberry Pi 3 Copyright © 2011-2019, 2net Ltd
Why?
• Porting Android to a dev board is a great way to learn about Android
Running Android on the Raspberry Pi 4 Copyright © 2011-2019, 2net Ltd
Why?
• Porting Android to a dev board is a great way to learn about Android
• It’s a good testing ground for new ideas
Running Android on the Raspberry Pi 4 Copyright © 2011-2019, 2net Ltd
Why?
• Porting Android to a dev board is a great way to learn about Android
• It’s a good testing ground for new ideas
• It’s fun! No, really it is!
Running Android on the Raspberry Pi 4 Copyright © 2011-2019, 2net Ltd
What do you need to run Android?
• Hardware from one of the supported architectures
• ARM, x86 or MIPS, in 32 or 64 bit varieties
Running Android on the Raspberry Pi 5 Copyright © 2011-2019, 2net Ltd
What do you need to run Android?
• Hardware from one of the supported architectures
• ARM, x86 or MIPS, in 32 or 64 bit varieties
• Running a recent version of Linux kernel (v4.4 or later)
Running Android on the Raspberry Pi 5 Copyright © 2011-2019, 2net Ltd
What do you need to run Android?
• Hardware from one of the supported architectures
• ARM, x86 or MIPS, in 32 or 64 bit varieties
• Running a recent version of Linux kernel (v4.4 or later)
• With at least 512 MiB RAM
Running Android on the Raspberry Pi 5 Copyright © 2011-2019, 2net Ltd
What do you need to run Android?
• Hardware from one of the supported architectures
• ARM, x86 or MIPS, in 32 or 64 bit varieties
• Running a recent version of Linux kernel (v4.4 or later)
• With at least 512 MiB RAM
• And at least 1 GiB flash storage - e.g. eMMC, SD card
Running Android on the Raspberry Pi 5 Copyright © 2011-2019, 2net Ltd
What do you need to run Android?
• Hardware from one of the supported architectures
• ARM, x86 or MIPS, in 32 or 64 bit varieties
• Running a recent version of Linux kernel (v4.4 or later)
• With at least 512 MiB RAM
• And at least 1 GiB flash storage - e.g. eMMC, SD card
• Plus a touchscreen or external display - e.g. HDMI
Running Android on the Raspberry Pi 5 Copyright © 2011-2019, 2net Ltd
What do you need to run Android?
• Hardware from one of the supported architectures
• ARM, x86 or MIPS, in 32 or 64 bit varieties
• Running a recent version of Linux kernel (v4.4 or later)
• With at least 512 MiB RAM
• And at least 1 GiB flash storage - e.g. eMMC, SD card
• Plus a touchscreen or external display - e.g. HDMI
• And a GPU with OpenGL ES 2.0 libraries (more about this later)
Running Android on the Raspberry Pi 5 Copyright © 2011-2019, 2net Ltd
Android on dev boards
DragonBoard, Hikey, BeagleBone, WandBoard, Raspberry Pi, Digi ConnectCore ...
Running Android on the Raspberry Pi 6 Copyright © 2011-2019, 2net Ltd
Why Raspberry Pi?
• It’s cheap ($35)
Running Android on the Raspberry Pi 7 Copyright © 2011-2019, 2net Ltd
Why Raspberry Pi?
• It’s cheap ($35)
• Easy to get hold of
Running Android on the Raspberry Pi 7 Copyright © 2011-2019, 2net Ltd
Why Raspberry Pi?
• It’s cheap ($35)
• Easy to get hold of
• Hackable
Running Android on the Raspberry Pi 7 Copyright © 2011-2019, 2net Ltd
Why Raspberry Pi?
• It’s cheap ($35)
• Easy to get hold of
• Hackable
• Because it is there
Running Android on the Raspberry Pi 7 Copyright © 2011-2019, 2net Ltd
The Raspberry Pi 3B
• BCM2837, Cortex-A53 (ARMv8) 64-bit
SoC @ 1.2GHz
• 1 GiB SDRAM
• Micro SD card slot
• 4 full size USB 2.0 A host
• 100 Mbit Ethernet
• WiFi 802.11 a/b/g/n/ac
• Bluetooth 4.2/BLE
• HDMI video output
• 40-pin header for HATs
Running Android on the Raspberry Pi 8 Copyright © 2011-2019, 2net Ltd
Hasn’t it been done already?
Sure! Here are some notable projects
• Android RPi: https://github.com/android-rpi
• LineageOS: (unofficial build from KonstaKang)
https://konstakang.com/devices/rpi3/LineageOS15.1
• RTAndroid: https://embedded.rwth-aachen.de/doku.php?id=en:
tools:rtandroid
• based on research by Igor Kalkov, now merged into emteria.os
• emteria.os: https://emteria.com (not open source)
• Android Things:
https://developer.android.com/things/hardware/raspberrypi
(not open source)
Running Android on the Raspberry Pi 9 Copyright © 2011-2019, 2net Ltd
What do you need?
• A copy of the Android Open Source Project (AOSP)
Running Android on the Raspberry Pi 10 Copyright © 2011-2019, 2net Ltd
What do you need?
• A copy of the Android Open Source Project (AOSP)
• A Linux kernel with Android extensions
Running Android on the Raspberry Pi 10 Copyright © 2011-2019, 2net Ltd
What do you need?
• A copy of the Android Open Source Project (AOSP)
• A Linux kernel with Android extensions
• A fair knowledge of the hardware
Running Android on the Raspberry Pi 10 Copyright © 2011-2019, 2net Ltd
What do you need?
• A copy of the Android Open Source Project (AOSP)
• A Linux kernel with Android extensions
• A fair knowledge of the hardware
• All the help you can get from existing projects
Running Android on the Raspberry Pi 10 Copyright © 2011-2019, 2net Ltd
What do you need?
• A copy of the Android Open Source Project (AOSP)
• A Linux kernel with Android extensions
• A fair knowledge of the hardware
• All the help you can get from existing projects
• A fairly fast computer
Running Android on the Raspberry Pi 10 Copyright © 2011-2019, 2net Ltd
What do you need?
• A copy of the Android Open Source Project (AOSP)
• A Linux kernel with Android extensions
• A fair knowledge of the hardware
• All the help you can get from existing projects
• A fairly fast computer
• Time and patience
Running Android on the Raspberry Pi 10 Copyright © 2011-2019, 2net Ltd
Putting Android on Raspberry Pi
• What follows is based on Konsta’s port of LineageOS
Running Android on the Raspberry Pi 11 Copyright © 2011-2019, 2net Ltd
Putting Android on Raspberry Pi
• What follows is based on Konsta’s port of LineageOS
• My version of the code is at
https://github.com/csimmonds/a4rpi-local-manifest
Running Android on the Raspberry Pi 11 Copyright © 2011-2019, 2net Ltd
Putting Android on Raspberry Pi
• What follows is based on Konsta’s port of LineageOS
• My version of the code is at
https://github.com/csimmonds/a4rpi-local-manifest
• Challenges posed by the Raspberry Pi
Running Android on the Raspberry Pi 11 Copyright © 2011-2019, 2net Ltd
Putting Android on Raspberry Pi
• What follows is based on Konsta’s port of LineageOS
• My version of the code is at
https://github.com/csimmonds/a4rpi-local-manifest
• Challenges posed by the Raspberry Pi
• Bootloader
Running Android on the Raspberry Pi 11 Copyright © 2011-2019, 2net Ltd
Putting Android on Raspberry Pi
• What follows is based on Konsta’s port of LineageOS
• My version of the code is at
https://github.com/csimmonds/a4rpi-local-manifest
• Challenges posed by the Raspberry Pi
• Bootloader
• Graphics
Running Android on the Raspberry Pi 11 Copyright © 2011-2019, 2net Ltd
Putting Android on Raspberry Pi
• What follows is based on Konsta’s port of LineageOS
• My version of the code is at
https://github.com/csimmonds/a4rpi-local-manifest
• Challenges posed by the Raspberry Pi
• Bootloader
• Graphics
• Lack of USB OTG port
Running Android on the Raspberry Pi 11 Copyright © 2011-2019, 2net Ltd
Getting AOSP
• AOSP is all of the open source components of the Android O/S
Running Android on the Raspberry Pi 12 Copyright © 2011-2019, 2net Ltd
Getting AOSP
• AOSP is all of the open source components of the Android O/S
• Begin by getting the repo tool
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ∼/bin/repo
$ chmod a+x ∼/bin/repo
Running Android on the Raspberry Pi 12 Copyright © 2011-2019, 2net Ltd
Getting AOSP
• AOSP is all of the open source components of the Android O/S
• Begin by getting the repo tool
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ∼/bin/repo
$ chmod a+x ∼/bin/repo
• Get the manifest of the version you want
$ mkdir ∼/myandroid
$ cd myandroid
$ repo init -u https://android.googlesource.com/platform/manifest -b android-9.0.0_r35
Running Android on the Raspberry Pi 12 Copyright © 2011-2019, 2net Ltd
Getting AOSP
• AOSP is all of the open source components of the Android O/S
• Begin by getting the repo tool
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ∼/bin/repo
$ chmod a+x ∼/bin/repo
• Get the manifest of the version you want
$ mkdir ∼/myandroid
$ cd myandroid
$ repo init -u https://android.googlesource.com/platform/manifest -b android-9.0.0_r35
• Copy all the code (*)
$ repo sync
(*) 70 GiB worth
Running Android on the Raspberry Pi 12 Copyright © 2011-2019, 2net Ltd
Customizing AOSP
• Porting Android to new hardware means creating a new Board
Support Package
Running Android on the Raspberry Pi 13 Copyright © 2011-2019, 2net Ltd
Customizing AOSP
• Porting Android to new hardware means creating a new Board
Support Package
• Consisting of device configuration (next slide), Hardware
Abstraction Layer and other low level packages
Running Android on the Raspberry Pi 13 Copyright © 2011-2019, 2net Ltd
Customizing AOSP
• Porting Android to new hardware means creating a new Board
Support Package
• Consisting of device configuration (next slide), Hardware
Abstraction Layer and other low level packages
• Put these into a local manifest, .repo/local_manifests/default.xml
Running Android on the Raspberry Pi 13 Copyright © 2011-2019, 2net Ltd
Customizing AOSP
• Porting Android to new hardware means creating a new Board
Support Package
• Consisting of device configuration (next slide), Hardware
Abstraction Layer and other low level packages
• Put these into a local manifest, .repo/local_manifests/default.xml
$ git clone https://github.com/csimmonds/a4rpi-local-manifest .repo/local_manifests -b pie
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="a4rpi" fetch="https://github.com/csimmonds" />
<remote name="lineage" fetch="https://github.com/lineage-rpi"/>
<project path="device/rpiorg/rpi3" name="a4rpi-device" revision="pie" remote="a4rpi"/>
[...]
Running Android on the Raspberry Pi 13 Copyright © 2011-2019, 2net Ltd
Device configuration
• Device specific configuration is in device/[organisation]/[product]
• Example: device/rpiorg/rpi3
Running Android on the Raspberry Pi 14 Copyright © 2011-2019, 2net Ltd
Device configuration
• Device specific configuration is in device/[organisation]/[product]
• Example: device/rpiorg/rpi3
• Select the one you want with command lunch
$ source build/envsetup.sh
$ lunch rpi3-eng
Running Android on the Raspberry Pi 14 Copyright © 2011-2019, 2net Ltd
Selecting the base product
• Base product is selected in device configuration by device.mk
$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base.mk)
• Products in AOSP
aosp_base.mk Android tablet
aosp_base_telephony.mk Android phone
atv_base.mk Android TV
car.mk Android Automotive
Running Android on the Raspberry Pi 15 Copyright © 2011-2019, 2net Ltd
Building AOSP
m
Running Android on the Raspberry Pi 16 Copyright © 2011-2019, 2net Ltd
Building AOSP
m
Then go and make a cup of tea: it’s going to take a couple of hours
Running Android on the Raspberry Pi 16 Copyright © 2011-2019, 2net Ltd
When the build is over
• You will find images in out/target/product/[product name]
out/target/product/rpi3/cache.img
out/target/product/rpi3/ramdisk.img
out/target/product/rpi3/system.img
out/target/product/rpi3/userdata.img
out/target/product/rpi3/vendor.img
• Just write these to a micro SD card (Raspberry Pi)
• ... or use fastboot to flash them (everything except Raspberry Pi)
Running Android on the Raspberry Pi 17 Copyright © 2011-2019, 2net Ltd
But wait, what about Linux?
• Android runs on top of Linux
Running Android on the Raspberry Pi 18 Copyright © 2011-2019, 2net Ltd
But wait, what about Linux?
• Android runs on top of Linux
• So, you need a Linux kernel with the Android kernel patches
Running Android on the Raspberry Pi 18 Copyright © 2011-2019, 2net Ltd
But wait, what about Linux?
• Android runs on top of Linux
• So, you need a Linux kernel with the Android kernel patches
• Usually provided by the silicon vendor (Qualcomm, NXP, Rockchip, ...)
Running Android on the Raspberry Pi 18 Copyright © 2011-2019, 2net Ltd
But wait, what about Linux?
• Android runs on top of Linux
• So, you need a Linux kernel with the Android kernel patches
• Usually provided by the silicon vendor (Qualcomm, NXP, Rockchip, ...)
• For Raspberry Pi, use Konsta’s kernel:
$ git clone https://github.com/lineage-rpi/android_kernel_brcm_rpi3 -b lineage-15.1 rpi3
$ cd rpi3
$ make lineageos_rpi3_defconfig
$ make -j $(nproc) zImage
$ make dtbs
Running Android on the Raspberry Pi 18 Copyright © 2011-2019, 2net Ltd
Challenge 1: Booting the Raspberry Pi
• Most Android devices have a bootloader that supports the fastboot
protocol for flashing and booting images
Running Android on the Raspberry Pi 19 Copyright © 2011-2019, 2net Ltd
Challenge 1: Booting the Raspberry Pi
• Most Android devices have a bootloader that supports the fastboot
protocol for flashing and booting images
• Raspberry Pi does not have such a bootloader
Running Android on the Raspberry Pi 19 Copyright © 2011-2019, 2net Ltd
Challenge 1: Booting the Raspberry Pi
• Most Android devices have a bootloader that supports the fastboot
protocol for flashing and booting images
• Raspberry Pi does not have such a bootloader
• So, we have to package the kernel and initial ramdisk and use
Broadcom loader to start Linux
Running Android on the Raspberry Pi 19 Copyright © 2011-2019, 2net Ltd
Challenge 1: Booting the Raspberry Pi
• Most Android devices have a bootloader that supports the fastboot
protocol for flashing and booting images
• Raspberry Pi does not have such a bootloader
• So, we have to package the kernel and initial ramdisk and use
Broadcom loader to start Linux
• ... To update Android, you need to take out the SD card and reflash ...
Running Android on the Raspberry Pi 19 Copyright © 2011-2019, 2net Ltd
Boot files
• The RPi boots from the first partition of the SD card
Bootloader:
bootcode.bin
fixup.dat
fixup_x.dat
start.elf
start_x.elf
config.txt
Linux:
cmdline.txt
bcm2710-rpi-3-b.dtb
overlays/
zImage
Android:
ramdisk.img
Running Android on the Raspberry Pi 20 Copyright © 2011-2019, 2net Ltd
Challenge 2: Graphics
• We need OpenGL ES 2.0 libraries with Android extensions
Running Android on the Raspberry Pi 21 Copyright © 2011-2019, 2net Ltd
Challenge 2: Graphics
• We need OpenGL ES 2.0 libraries with Android extensions
• Three options
Running Android on the Raspberry Pi 21 Copyright © 2011-2019, 2net Ltd
Challenge 2: Graphics
• We need OpenGL ES 2.0 libraries with Android extensions
• Three options
• Get binary OpenGLES libraries from the vendor, if they exist (they don’t
for Broadcom BCM2708/2835)
Running Android on the Raspberry Pi 21 Copyright © 2011-2019, 2net Ltd
Challenge 2: Graphics
• We need OpenGL ES 2.0 libraries with Android extensions
• Three options
• Get binary OpenGLES libraries from the vendor, if they exist (they don’t
for Broadcom BCM2708/2835)
• Use open source drivers, Mesa and DRM, if they exist (they do for
BCM2708/2835)
Running Android on the Raspberry Pi 21 Copyright © 2011-2019, 2net Ltd
Challenge 2: Graphics
• We need OpenGL ES 2.0 libraries with Android extensions
• Three options
• Get binary OpenGLES libraries from the vendor, if they exist (they don’t
for Broadcom BCM2708/2835)
• Use open source drivers, Mesa and DRM, if they exist (they do for
BCM2708/2835)
• Use Soft GPU, Swiftshader
Running Android on the Raspberry Pi 21 Copyright © 2011-2019, 2net Ltd
Graphics: Mesa
mesa
OpenGLES
OpenGLES
3-D Apps
android.opengl.*
HWUI
2-D graphics
libEGL.so
libGLESv1_cm.so
libGLESv2.so
libEGL_mesa.so
libGLESv1_CM_mesa.so
libGLESv2_mesa.so
DRM VC4 kernel driver
Framework
HAL
Kernel
libdrm
Surface Flinger
drm_
hwcomposer
drm_
gralloc
V3D GPU Video controller
Surface
buffers
Running Android on the Raspberry Pi 22 Copyright © 2011-2019, 2net Ltd
Mesa
• Mesa 3D library: https://www.mesa3d.org/
Running Android on the Raspberry Pi 23 Copyright © 2011-2019, 2net Ltd
Mesa
• Mesa 3D library: https://www.mesa3d.org/
• Supports OpenGL ES 1/2/3 and EGL
Running Android on the Raspberry Pi 23 Copyright © 2011-2019, 2net Ltd
Mesa
• Mesa 3D library: https://www.mesa3d.org/
• Supports OpenGL ES 1/2/3 and EGL
• Drivers for mobile GPUs include:
Driver SoC
freedreno Qualcomm MSM
nouveau NVidea Tegra
VC4 Broadcom BCM2708 (Raspberry Pi)
etnaviv NXP i.MX6
lima/panfrost ARM Mali 4xx, Txxx and Gxx
softpipe soft GPU
Running Android on the Raspberry Pi 23 Copyright © 2011-2019, 2net Ltd
DRI/DRM
• DRI (Direct Rendering Infrastructure): user-space wrappers for DRM,
including libdrm
Running Android on the Raspberry Pi 24 Copyright © 2011-2019, 2net Ltd
DRI/DRM
• DRI (Direct Rendering Infrastructure): user-space wrappers for DRM,
including libdrm
• DRM (Direct Rendering Manager): kernel device driver to access GPU
and video controller hardware blocks
Running Android on the Raspberry Pi 24 Copyright © 2011-2019, 2net Ltd
DRI/DRM
• DRI (Direct Rendering Infrastructure): user-space wrappers for DRM,
including libdrm
• DRM (Direct Rendering Manager): kernel device driver to access GPU
and video controller hardware blocks
# ls -l /dev/dri/*
crw-rw-rw- 1 root graphics 226, 0 1970-01-01 00:00 /dev/dri/card0
crw-rw-rw- 1 root graphics 226, 128 1970-01-01 00:00 /dev/dri/renderD128
Running Android on the Raspberry Pi 24 Copyright © 2011-2019, 2net Ltd
Open source graphics go mainstream
• Google is encouraging vendors to move to mesa/DRM
Running Android on the Raspberry Pi 25 Copyright © 2011-2019, 2net Ltd
Open source graphics go mainstream
• Google is encouraging vendors to move to mesa/DRM
• For example
• Pixel 3 has a Qualcomm 845 SoC with Adreno 630 GPU
• Uses Mesa/DRM with freedreno driver
See Alistair Strachan’s presentation at Linux Plumber’s conference, November 2018,
DRM/KMS for Android
https://linuxplumbersconf.org/event/2/contributions/229/attachments/53/60/
10._DRM_KMS_for_Android_v1.pdf
Running Android on the Raspberry Pi 25 Copyright © 2011-2019, 2net Ltd
Graphics: Swiftshader
SwiftShader
OpenGLES
OpenGLES
App 3-D graphics
android.opengl.*
HWUI
2-D graphics
libEGL.so
libGLESv1_cm.so
libGLESv2.so
libEGL_swiftshader.so
libGLESv1_CM_swiftshader.so
libGLESv2_swiftshader.so
Surface Flinger
FBDEV
Framework
HAL
Kernel
Running Android on the Raspberry Pi 26 Copyright © 2011-2019, 2net Ltd
Challenge 3: ADB
• Raspberry Pi only has USB host ports, but ADB needs a USB
peripheral port
Running Android on the Raspberry Pi 27 Copyright © 2011-2019, 2net Ltd
Challenge 3: ADB
• Raspberry Pi only has USB host ports, but ADB needs a USB
peripheral port
• Usually provided by a dual mode USB "On The Go" (OTG) port
Running Android on the Raspberry Pi 27 Copyright © 2011-2019, 2net Ltd
Challenge 3: ADB
• Raspberry Pi only has USB host ports, but ADB needs a USB
peripheral port
• Usually provided by a dual mode USB "On The Go" (OTG) port
• (Actually, the BCM283x has OTG hardware but it is used internally to
bridge the USB host controller, Ethernet, and so on)
Running Android on the Raspberry Pi 27 Copyright © 2011-2019, 2net Ltd
Challenge 3: ADB
• Raspberry Pi only has USB host ports, but ADB needs a USB
peripheral port
• Usually provided by a dual mode USB "On The Go" (OTG) port
• (Actually, the BCM283x has OTG hardware but it is used internally to
bridge the USB host controller, Ethernet, and so on)
• But, we can use ADB over Ethernet instead
$ adb connect Android.local
connected to Android.local:5555
Running Android on the Raspberry Pi 27 Copyright © 2011-2019, 2net Ltd
Challenge 3: ADB
• Raspberry Pi only has USB host ports, but ADB needs a USB
peripheral port
• Usually provided by a dual mode USB "On The Go" (OTG) port
• (Actually, the BCM283x has OTG hardware but it is used internally to
bridge the USB host controller, Ethernet, and so on)
• But, we can use ADB over Ethernet instead
$ adb connect Android.local
connected to Android.local:5555
$ adb shell
rpi3:/ #
Running Android on the Raspberry Pi 27 Copyright © 2011-2019, 2net Ltd
Current status
• Code is on github (URL at the
end)
• Based on Android Pie 9.0 r 30
• Using SwiftShader
• Works:
• HDMI touch screen
• Ethernet
• WiFi (probably)
• Bluetooth (possibly)
• Not working:
• Audio
• Streaming video
• Lots of other things...
• Early stages: still many things to
do
Running Android on the Raspberry Pi 28 Copyright © 2011-2019, 2net Ltd
Apps
• Has standard AOSP apps
• Install Gapps if you want
PlayStore, etc
https://opengapps.org
• Note: this does not come with
a license from Google
Running Android on the Raspberry Pi 29 Copyright © 2011-2019, 2net Ltd
Delving deeper
• If you would like to discover more about building Android platforms,
visit http://www.2net.co.uk/training.html and enquire about
training classes for your company
• 2net training is available world-wide
Running Android on the Raspberry Pi 30 Copyright © 2011-2019, 2net Ltd
Relevant links:
Android 4 RPi
https://github.com/csimmonds/a4rpi-local-manifest
@2net_software http://www.2net.co.uk
Any questions?
Running Android on the Raspberry Pi 31 Copyright © 2011-2019, 2net Ltd

More Related Content

What's hot (20)

PDF
Quick and Easy Device Drivers for Embedded Linux Using UIO
Chris Simmonds
 
PDF
Kernel Recipes 2015: Kernel packet capture technologies
Anne Nicolas
 
PDF
Part 02 Linux Kernel Module Programming
Tushar B Kute
 
PPTX
Android - ADB
Yossi Gruner
 
PPTX
Overview of Android binder IPC implementation
Chethan Pchethan
 
PDF
Android presentation
Siva Ramakrishna kv
 
PDF
Building aosp
gvercoutere
 
PDF
Android IPC Mechanism
National Cheng Kung University
 
PDF
An Introduction to the Android Framework -- a core architecture view from app...
William Liang
 
PDF
Architecture Of The Linux Kernel
guest547d74
 
PDF
Android HAL Introduction: libhardware and its legacy
Jollen Chen
 
PDF
Linux Internals - Part I
Emertxe Information Technologies Pvt Ltd
 
PPT
Android JNI
Siva Ramakrishna kv
 
PDF
Android device driver structure introduction
William Liang
 
PDF
Kernel Module Programming
Saurabh Bangad
 
PDF
Understanding the Android System Server
Opersys inc.
 
PPTX
Linux Kernel Programming
Nalin Sharma
 
PDF
Project meeting: Android Graphics Architecture Overview
Yu-Hsin Hung
 
PDF
Uboot startup sequence
Houcheng Lin
 
Quick and Easy Device Drivers for Embedded Linux Using UIO
Chris Simmonds
 
Kernel Recipes 2015: Kernel packet capture technologies
Anne Nicolas
 
Part 02 Linux Kernel Module Programming
Tushar B Kute
 
Android - ADB
Yossi Gruner
 
Overview of Android binder IPC implementation
Chethan Pchethan
 
Android presentation
Siva Ramakrishna kv
 
Building aosp
gvercoutere
 
Android IPC Mechanism
National Cheng Kung University
 
An Introduction to the Android Framework -- a core architecture view from app...
William Liang
 
Architecture Of The Linux Kernel
guest547d74
 
Android HAL Introduction: libhardware and its legacy
Jollen Chen
 
Android JNI
Siva Ramakrishna kv
 
Android device driver structure introduction
William Liang
 
Kernel Module Programming
Saurabh Bangad
 
Understanding the Android System Server
Opersys inc.
 
Linux Kernel Programming
Nalin Sharma
 
Project meeting: Android Graphics Architecture Overview
Yu-Hsin Hung
 
Uboot startup sequence
Houcheng Lin
 

Similar to Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi (20)

PDF
Android rpi-csimmonds-fosdem-2019
Chris Simmonds
 
PPTX
tm.gdg.ro: Android on Raspberry Pi
Alexandru IOVANOVICI
 
PDF
Embedded Android: Android beyond the smartphone
Chris Simmonds
 
ODP
Android/Chrome os on RaspberryPi
Arun Kumar
 
PDF
Raspberry Pi Hacks
Imad Rhali
 
PDF
Single Board Computers & Raspberry Pi Basics
Eueung Mulyana
 
PDF
Running Chrome/Android OS on Raspberry Pi
Louis Shue
 
PDF
Porting Android ABS 2011
Opersys inc.
 
PDF
Porting Android
Opersys inc.
 
PDF
Porting Android
Opersys inc.
 
PDF
Is Android the New Embedded Linux? at AnDevCon V
Opersys inc.
 
PDF
Raspberry pi Board Hardware & Software Setup
RANAALIMAJEEDRAJPUT
 
PDF
Raspberry pi history, tips and use case
Masafumi Ohta
 
PDF
Is Android the New Embedded Linux? at AnDevCon VI
Opersys inc.
 
PDF
Raspberry pi history, tips and use case (coscup19)
Masafumi Ohta
 
PDF
What Makes the Raspberry Pi 5 So Special?
Leon Anavi
 
PDF
Raspberry pi: Conceptos básicos de la arquitectura de la computadora raspberr...
SANTIAGO PABLO ALBERTO
 
PDF
Android Hacks, Variants, Tricks and Resources ESC SV 2012
Opersys inc.
 
PPTX
Starting Raspberry Pi
LloydMoore
 
PDF
Raspberry pi Beginners Session
Anant Shrivastava
 
Android rpi-csimmonds-fosdem-2019
Chris Simmonds
 
tm.gdg.ro: Android on Raspberry Pi
Alexandru IOVANOVICI
 
Embedded Android: Android beyond the smartphone
Chris Simmonds
 
Android/Chrome os on RaspberryPi
Arun Kumar
 
Raspberry Pi Hacks
Imad Rhali
 
Single Board Computers & Raspberry Pi Basics
Eueung Mulyana
 
Running Chrome/Android OS on Raspberry Pi
Louis Shue
 
Porting Android ABS 2011
Opersys inc.
 
Porting Android
Opersys inc.
 
Porting Android
Opersys inc.
 
Is Android the New Embedded Linux? at AnDevCon V
Opersys inc.
 
Raspberry pi Board Hardware & Software Setup
RANAALIMAJEEDRAJPUT
 
Raspberry pi history, tips and use case
Masafumi Ohta
 
Is Android the New Embedded Linux? at AnDevCon VI
Opersys inc.
 
Raspberry pi history, tips and use case (coscup19)
Masafumi Ohta
 
What Makes the Raspberry Pi 5 So Special?
Leon Anavi
 
Raspberry pi: Conceptos básicos de la arquitectura de la computadora raspberr...
SANTIAGO PABLO ALBERTO
 
Android Hacks, Variants, Tricks and Resources ESC SV 2012
Opersys inc.
 
Starting Raspberry Pi
LloydMoore
 
Raspberry pi Beginners Session
Anant Shrivastava
 
Ad

More from Chris Simmonds (18)

PDF
Debugging embedded devices using GDB
Chris Simmonds
 
PDF
Debian or Yocto Project? Which is the best for your Embedded Linux project?
Chris Simmonds
 
PDF
Embedded Linux Quick Start Guide v1.5
Chris Simmonds
 
PDF
Reducing the boot time of Linux devices
Chris Simmonds
 
PDF
Reducing boot time in embedded Linux
Chris Simmonds
 
PDF
Linux power management: are you doing it right?
Chris Simmonds
 
PDF
Software update for IoT Embedded World 2017
Chris Simmonds
 
PDF
Software update for IoT: the current state of play
Chris Simmonds
 
PDF
Read-only rootfs: theory and practice
Chris Simmonds
 
PDF
Android beyond the smartphone
Chris Simmonds
 
PDF
10 ways hardware engineers can make software integration easier
Chris Simmonds
 
PDF
Userspace drivers-2016
Chris Simmonds
 
PDF
The end of embedded Linux (as we know it)
Chris Simmonds
 
PDF
Linux field-update-2015
Chris Simmonds
 
PDF
Tuning Android for low RAM
Chris Simmonds
 
PDF
The Android graphics path, in depth
Chris Simmonds
 
PDF
Booting Android: bootloaders, fastboot and boot images
Chris Simmonds
 
PDF
A timeline for embedded Linux
Chris Simmonds
 
Debugging embedded devices using GDB
Chris Simmonds
 
Debian or Yocto Project? Which is the best for your Embedded Linux project?
Chris Simmonds
 
Embedded Linux Quick Start Guide v1.5
Chris Simmonds
 
Reducing the boot time of Linux devices
Chris Simmonds
 
Reducing boot time in embedded Linux
Chris Simmonds
 
Linux power management: are you doing it right?
Chris Simmonds
 
Software update for IoT Embedded World 2017
Chris Simmonds
 
Software update for IoT: the current state of play
Chris Simmonds
 
Read-only rootfs: theory and practice
Chris Simmonds
 
Android beyond the smartphone
Chris Simmonds
 
10 ways hardware engineers can make software integration easier
Chris Simmonds
 
Userspace drivers-2016
Chris Simmonds
 
The end of embedded Linux (as we know it)
Chris Simmonds
 
Linux field-update-2015
Chris Simmonds
 
Tuning Android for low RAM
Chris Simmonds
 
The Android graphics path, in depth
Chris Simmonds
 
Booting Android: bootloaders, fastboot and boot images
Chris Simmonds
 
A timeline for embedded Linux
Chris Simmonds
 
Ad

Recently uploaded (20)

PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 

Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi

  • 1. Running Android on the Raspberry Pi Android Pie meets Raspberry Pi Chris Simmonds Android Makers 2019 Running Android on the Raspberry Pi 1 Copyright © 2011-2019, 2net Ltd
  • 2. License These slides are available under a Creative Commons Attribution-ShareAlike 4.0 license. You can read the full text of the license here http://creativecommons.org/licenses/by-sa/4.0/legalcode You are free to • copy, distribute, display, and perform the work • make derivative works • make commercial use of the work Under the following conditions • Attribution: you must give the original author credit • Share Alike: if you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one (i.e. include this page exactly as it is) • For any reuse or distribution, you must make clear to others the license terms of this work Running Android on the Raspberry Pi 2 Copyright © 2011-2019, 2net Ltd
  • 3. About Chris Simmonds • Consultant and trainer • Author of Mastering Embedded Linux Programming • Working with embedded Linux since 1999 • Android since 2009 • Speaker at many conferences and workshops "Looking after the Inner Penguin" blog at http://2net.co.uk/ @2net_software https://uk.linkedin.com/in/chrisdsimmonds/ Running Android on the Raspberry Pi 3 Copyright © 2011-2019, 2net Ltd
  • 4. Why? • Porting Android to a dev board is a great way to learn about Android Running Android on the Raspberry Pi 4 Copyright © 2011-2019, 2net Ltd
  • 5. Why? • Porting Android to a dev board is a great way to learn about Android • It’s a good testing ground for new ideas Running Android on the Raspberry Pi 4 Copyright © 2011-2019, 2net Ltd
  • 6. Why? • Porting Android to a dev board is a great way to learn about Android • It’s a good testing ground for new ideas • It’s fun! No, really it is! Running Android on the Raspberry Pi 4 Copyright © 2011-2019, 2net Ltd
  • 7. What do you need to run Android? • Hardware from one of the supported architectures • ARM, x86 or MIPS, in 32 or 64 bit varieties Running Android on the Raspberry Pi 5 Copyright © 2011-2019, 2net Ltd
  • 8. What do you need to run Android? • Hardware from one of the supported architectures • ARM, x86 or MIPS, in 32 or 64 bit varieties • Running a recent version of Linux kernel (v4.4 or later) Running Android on the Raspberry Pi 5 Copyright © 2011-2019, 2net Ltd
  • 9. What do you need to run Android? • Hardware from one of the supported architectures • ARM, x86 or MIPS, in 32 or 64 bit varieties • Running a recent version of Linux kernel (v4.4 or later) • With at least 512 MiB RAM Running Android on the Raspberry Pi 5 Copyright © 2011-2019, 2net Ltd
  • 10. What do you need to run Android? • Hardware from one of the supported architectures • ARM, x86 or MIPS, in 32 or 64 bit varieties • Running a recent version of Linux kernel (v4.4 or later) • With at least 512 MiB RAM • And at least 1 GiB flash storage - e.g. eMMC, SD card Running Android on the Raspberry Pi 5 Copyright © 2011-2019, 2net Ltd
  • 11. What do you need to run Android? • Hardware from one of the supported architectures • ARM, x86 or MIPS, in 32 or 64 bit varieties • Running a recent version of Linux kernel (v4.4 or later) • With at least 512 MiB RAM • And at least 1 GiB flash storage - e.g. eMMC, SD card • Plus a touchscreen or external display - e.g. HDMI Running Android on the Raspberry Pi 5 Copyright © 2011-2019, 2net Ltd
  • 12. What do you need to run Android? • Hardware from one of the supported architectures • ARM, x86 or MIPS, in 32 or 64 bit varieties • Running a recent version of Linux kernel (v4.4 or later) • With at least 512 MiB RAM • And at least 1 GiB flash storage - e.g. eMMC, SD card • Plus a touchscreen or external display - e.g. HDMI • And a GPU with OpenGL ES 2.0 libraries (more about this later) Running Android on the Raspberry Pi 5 Copyright © 2011-2019, 2net Ltd
  • 13. Android on dev boards DragonBoard, Hikey, BeagleBone, WandBoard, Raspberry Pi, Digi ConnectCore ... Running Android on the Raspberry Pi 6 Copyright © 2011-2019, 2net Ltd
  • 14. Why Raspberry Pi? • It’s cheap ($35) Running Android on the Raspberry Pi 7 Copyright © 2011-2019, 2net Ltd
  • 15. Why Raspberry Pi? • It’s cheap ($35) • Easy to get hold of Running Android on the Raspberry Pi 7 Copyright © 2011-2019, 2net Ltd
  • 16. Why Raspberry Pi? • It’s cheap ($35) • Easy to get hold of • Hackable Running Android on the Raspberry Pi 7 Copyright © 2011-2019, 2net Ltd
  • 17. Why Raspberry Pi? • It’s cheap ($35) • Easy to get hold of • Hackable • Because it is there Running Android on the Raspberry Pi 7 Copyright © 2011-2019, 2net Ltd
  • 18. The Raspberry Pi 3B • BCM2837, Cortex-A53 (ARMv8) 64-bit SoC @ 1.2GHz • 1 GiB SDRAM • Micro SD card slot • 4 full size USB 2.0 A host • 100 Mbit Ethernet • WiFi 802.11 a/b/g/n/ac • Bluetooth 4.2/BLE • HDMI video output • 40-pin header for HATs Running Android on the Raspberry Pi 8 Copyright © 2011-2019, 2net Ltd
  • 19. Hasn’t it been done already? Sure! Here are some notable projects • Android RPi: https://github.com/android-rpi • LineageOS: (unofficial build from KonstaKang) https://konstakang.com/devices/rpi3/LineageOS15.1 • RTAndroid: https://embedded.rwth-aachen.de/doku.php?id=en: tools:rtandroid • based on research by Igor Kalkov, now merged into emteria.os • emteria.os: https://emteria.com (not open source) • Android Things: https://developer.android.com/things/hardware/raspberrypi (not open source) Running Android on the Raspberry Pi 9 Copyright © 2011-2019, 2net Ltd
  • 20. What do you need? • A copy of the Android Open Source Project (AOSP) Running Android on the Raspberry Pi 10 Copyright © 2011-2019, 2net Ltd
  • 21. What do you need? • A copy of the Android Open Source Project (AOSP) • A Linux kernel with Android extensions Running Android on the Raspberry Pi 10 Copyright © 2011-2019, 2net Ltd
  • 22. What do you need? • A copy of the Android Open Source Project (AOSP) • A Linux kernel with Android extensions • A fair knowledge of the hardware Running Android on the Raspberry Pi 10 Copyright © 2011-2019, 2net Ltd
  • 23. What do you need? • A copy of the Android Open Source Project (AOSP) • A Linux kernel with Android extensions • A fair knowledge of the hardware • All the help you can get from existing projects Running Android on the Raspberry Pi 10 Copyright © 2011-2019, 2net Ltd
  • 24. What do you need? • A copy of the Android Open Source Project (AOSP) • A Linux kernel with Android extensions • A fair knowledge of the hardware • All the help you can get from existing projects • A fairly fast computer Running Android on the Raspberry Pi 10 Copyright © 2011-2019, 2net Ltd
  • 25. What do you need? • A copy of the Android Open Source Project (AOSP) • A Linux kernel with Android extensions • A fair knowledge of the hardware • All the help you can get from existing projects • A fairly fast computer • Time and patience Running Android on the Raspberry Pi 10 Copyright © 2011-2019, 2net Ltd
  • 26. Putting Android on Raspberry Pi • What follows is based on Konsta’s port of LineageOS Running Android on the Raspberry Pi 11 Copyright © 2011-2019, 2net Ltd
  • 27. Putting Android on Raspberry Pi • What follows is based on Konsta’s port of LineageOS • My version of the code is at https://github.com/csimmonds/a4rpi-local-manifest Running Android on the Raspberry Pi 11 Copyright © 2011-2019, 2net Ltd
  • 28. Putting Android on Raspberry Pi • What follows is based on Konsta’s port of LineageOS • My version of the code is at https://github.com/csimmonds/a4rpi-local-manifest • Challenges posed by the Raspberry Pi Running Android on the Raspberry Pi 11 Copyright © 2011-2019, 2net Ltd
  • 29. Putting Android on Raspberry Pi • What follows is based on Konsta’s port of LineageOS • My version of the code is at https://github.com/csimmonds/a4rpi-local-manifest • Challenges posed by the Raspberry Pi • Bootloader Running Android on the Raspberry Pi 11 Copyright © 2011-2019, 2net Ltd
  • 30. Putting Android on Raspberry Pi • What follows is based on Konsta’s port of LineageOS • My version of the code is at https://github.com/csimmonds/a4rpi-local-manifest • Challenges posed by the Raspberry Pi • Bootloader • Graphics Running Android on the Raspberry Pi 11 Copyright © 2011-2019, 2net Ltd
  • 31. Putting Android on Raspberry Pi • What follows is based on Konsta’s port of LineageOS • My version of the code is at https://github.com/csimmonds/a4rpi-local-manifest • Challenges posed by the Raspberry Pi • Bootloader • Graphics • Lack of USB OTG port Running Android on the Raspberry Pi 11 Copyright © 2011-2019, 2net Ltd
  • 32. Getting AOSP • AOSP is all of the open source components of the Android O/S Running Android on the Raspberry Pi 12 Copyright © 2011-2019, 2net Ltd
  • 33. Getting AOSP • AOSP is all of the open source components of the Android O/S • Begin by getting the repo tool $ curl https://storage.googleapis.com/git-repo-downloads/repo > ∼/bin/repo $ chmod a+x ∼/bin/repo Running Android on the Raspberry Pi 12 Copyright © 2011-2019, 2net Ltd
  • 34. Getting AOSP • AOSP is all of the open source components of the Android O/S • Begin by getting the repo tool $ curl https://storage.googleapis.com/git-repo-downloads/repo > ∼/bin/repo $ chmod a+x ∼/bin/repo • Get the manifest of the version you want $ mkdir ∼/myandroid $ cd myandroid $ repo init -u https://android.googlesource.com/platform/manifest -b android-9.0.0_r35 Running Android on the Raspberry Pi 12 Copyright © 2011-2019, 2net Ltd
  • 35. Getting AOSP • AOSP is all of the open source components of the Android O/S • Begin by getting the repo tool $ curl https://storage.googleapis.com/git-repo-downloads/repo > ∼/bin/repo $ chmod a+x ∼/bin/repo • Get the manifest of the version you want $ mkdir ∼/myandroid $ cd myandroid $ repo init -u https://android.googlesource.com/platform/manifest -b android-9.0.0_r35 • Copy all the code (*) $ repo sync (*) 70 GiB worth Running Android on the Raspberry Pi 12 Copyright © 2011-2019, 2net Ltd
  • 36. Customizing AOSP • Porting Android to new hardware means creating a new Board Support Package Running Android on the Raspberry Pi 13 Copyright © 2011-2019, 2net Ltd
  • 37. Customizing AOSP • Porting Android to new hardware means creating a new Board Support Package • Consisting of device configuration (next slide), Hardware Abstraction Layer and other low level packages Running Android on the Raspberry Pi 13 Copyright © 2011-2019, 2net Ltd
  • 38. Customizing AOSP • Porting Android to new hardware means creating a new Board Support Package • Consisting of device configuration (next slide), Hardware Abstraction Layer and other low level packages • Put these into a local manifest, .repo/local_manifests/default.xml Running Android on the Raspberry Pi 13 Copyright © 2011-2019, 2net Ltd
  • 39. Customizing AOSP • Porting Android to new hardware means creating a new Board Support Package • Consisting of device configuration (next slide), Hardware Abstraction Layer and other low level packages • Put these into a local manifest, .repo/local_manifests/default.xml $ git clone https://github.com/csimmonds/a4rpi-local-manifest .repo/local_manifests -b pie <?xml version="1.0" encoding="UTF-8"?> <manifest> <remote name="a4rpi" fetch="https://github.com/csimmonds" /> <remote name="lineage" fetch="https://github.com/lineage-rpi"/> <project path="device/rpiorg/rpi3" name="a4rpi-device" revision="pie" remote="a4rpi"/> [...] Running Android on the Raspberry Pi 13 Copyright © 2011-2019, 2net Ltd
  • 40. Device configuration • Device specific configuration is in device/[organisation]/[product] • Example: device/rpiorg/rpi3 Running Android on the Raspberry Pi 14 Copyright © 2011-2019, 2net Ltd
  • 41. Device configuration • Device specific configuration is in device/[organisation]/[product] • Example: device/rpiorg/rpi3 • Select the one you want with command lunch $ source build/envsetup.sh $ lunch rpi3-eng Running Android on the Raspberry Pi 14 Copyright © 2011-2019, 2net Ltd
  • 42. Selecting the base product • Base product is selected in device configuration by device.mk $(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base.mk) • Products in AOSP aosp_base.mk Android tablet aosp_base_telephony.mk Android phone atv_base.mk Android TV car.mk Android Automotive Running Android on the Raspberry Pi 15 Copyright © 2011-2019, 2net Ltd
  • 43. Building AOSP m Running Android on the Raspberry Pi 16 Copyright © 2011-2019, 2net Ltd
  • 44. Building AOSP m Then go and make a cup of tea: it’s going to take a couple of hours Running Android on the Raspberry Pi 16 Copyright © 2011-2019, 2net Ltd
  • 45. When the build is over • You will find images in out/target/product/[product name] out/target/product/rpi3/cache.img out/target/product/rpi3/ramdisk.img out/target/product/rpi3/system.img out/target/product/rpi3/userdata.img out/target/product/rpi3/vendor.img • Just write these to a micro SD card (Raspberry Pi) • ... or use fastboot to flash them (everything except Raspberry Pi) Running Android on the Raspberry Pi 17 Copyright © 2011-2019, 2net Ltd
  • 46. But wait, what about Linux? • Android runs on top of Linux Running Android on the Raspberry Pi 18 Copyright © 2011-2019, 2net Ltd
  • 47. But wait, what about Linux? • Android runs on top of Linux • So, you need a Linux kernel with the Android kernel patches Running Android on the Raspberry Pi 18 Copyright © 2011-2019, 2net Ltd
  • 48. But wait, what about Linux? • Android runs on top of Linux • So, you need a Linux kernel with the Android kernel patches • Usually provided by the silicon vendor (Qualcomm, NXP, Rockchip, ...) Running Android on the Raspberry Pi 18 Copyright © 2011-2019, 2net Ltd
  • 49. But wait, what about Linux? • Android runs on top of Linux • So, you need a Linux kernel with the Android kernel patches • Usually provided by the silicon vendor (Qualcomm, NXP, Rockchip, ...) • For Raspberry Pi, use Konsta’s kernel: $ git clone https://github.com/lineage-rpi/android_kernel_brcm_rpi3 -b lineage-15.1 rpi3 $ cd rpi3 $ make lineageos_rpi3_defconfig $ make -j $(nproc) zImage $ make dtbs Running Android on the Raspberry Pi 18 Copyright © 2011-2019, 2net Ltd
  • 50. Challenge 1: Booting the Raspberry Pi • Most Android devices have a bootloader that supports the fastboot protocol for flashing and booting images Running Android on the Raspberry Pi 19 Copyright © 2011-2019, 2net Ltd
  • 51. Challenge 1: Booting the Raspberry Pi • Most Android devices have a bootloader that supports the fastboot protocol for flashing and booting images • Raspberry Pi does not have such a bootloader Running Android on the Raspberry Pi 19 Copyright © 2011-2019, 2net Ltd
  • 52. Challenge 1: Booting the Raspberry Pi • Most Android devices have a bootloader that supports the fastboot protocol for flashing and booting images • Raspberry Pi does not have such a bootloader • So, we have to package the kernel and initial ramdisk and use Broadcom loader to start Linux Running Android on the Raspberry Pi 19 Copyright © 2011-2019, 2net Ltd
  • 53. Challenge 1: Booting the Raspberry Pi • Most Android devices have a bootloader that supports the fastboot protocol for flashing and booting images • Raspberry Pi does not have such a bootloader • So, we have to package the kernel and initial ramdisk and use Broadcom loader to start Linux • ... To update Android, you need to take out the SD card and reflash ... Running Android on the Raspberry Pi 19 Copyright © 2011-2019, 2net Ltd
  • 54. Boot files • The RPi boots from the first partition of the SD card Bootloader: bootcode.bin fixup.dat fixup_x.dat start.elf start_x.elf config.txt Linux: cmdline.txt bcm2710-rpi-3-b.dtb overlays/ zImage Android: ramdisk.img Running Android on the Raspberry Pi 20 Copyright © 2011-2019, 2net Ltd
  • 55. Challenge 2: Graphics • We need OpenGL ES 2.0 libraries with Android extensions Running Android on the Raspberry Pi 21 Copyright © 2011-2019, 2net Ltd
  • 56. Challenge 2: Graphics • We need OpenGL ES 2.0 libraries with Android extensions • Three options Running Android on the Raspberry Pi 21 Copyright © 2011-2019, 2net Ltd
  • 57. Challenge 2: Graphics • We need OpenGL ES 2.0 libraries with Android extensions • Three options • Get binary OpenGLES libraries from the vendor, if they exist (they don’t for Broadcom BCM2708/2835) Running Android on the Raspberry Pi 21 Copyright © 2011-2019, 2net Ltd
  • 58. Challenge 2: Graphics • We need OpenGL ES 2.0 libraries with Android extensions • Three options • Get binary OpenGLES libraries from the vendor, if they exist (they don’t for Broadcom BCM2708/2835) • Use open source drivers, Mesa and DRM, if they exist (they do for BCM2708/2835) Running Android on the Raspberry Pi 21 Copyright © 2011-2019, 2net Ltd
  • 59. Challenge 2: Graphics • We need OpenGL ES 2.0 libraries with Android extensions • Three options • Get binary OpenGLES libraries from the vendor, if they exist (they don’t for Broadcom BCM2708/2835) • Use open source drivers, Mesa and DRM, if they exist (they do for BCM2708/2835) • Use Soft GPU, Swiftshader Running Android on the Raspberry Pi 21 Copyright © 2011-2019, 2net Ltd
  • 60. Graphics: Mesa mesa OpenGLES OpenGLES 3-D Apps android.opengl.* HWUI 2-D graphics libEGL.so libGLESv1_cm.so libGLESv2.so libEGL_mesa.so libGLESv1_CM_mesa.so libGLESv2_mesa.so DRM VC4 kernel driver Framework HAL Kernel libdrm Surface Flinger drm_ hwcomposer drm_ gralloc V3D GPU Video controller Surface buffers Running Android on the Raspberry Pi 22 Copyright © 2011-2019, 2net Ltd
  • 61. Mesa • Mesa 3D library: https://www.mesa3d.org/ Running Android on the Raspberry Pi 23 Copyright © 2011-2019, 2net Ltd
  • 62. Mesa • Mesa 3D library: https://www.mesa3d.org/ • Supports OpenGL ES 1/2/3 and EGL Running Android on the Raspberry Pi 23 Copyright © 2011-2019, 2net Ltd
  • 63. Mesa • Mesa 3D library: https://www.mesa3d.org/ • Supports OpenGL ES 1/2/3 and EGL • Drivers for mobile GPUs include: Driver SoC freedreno Qualcomm MSM nouveau NVidea Tegra VC4 Broadcom BCM2708 (Raspberry Pi) etnaviv NXP i.MX6 lima/panfrost ARM Mali 4xx, Txxx and Gxx softpipe soft GPU Running Android on the Raspberry Pi 23 Copyright © 2011-2019, 2net Ltd
  • 64. DRI/DRM • DRI (Direct Rendering Infrastructure): user-space wrappers for DRM, including libdrm Running Android on the Raspberry Pi 24 Copyright © 2011-2019, 2net Ltd
  • 65. DRI/DRM • DRI (Direct Rendering Infrastructure): user-space wrappers for DRM, including libdrm • DRM (Direct Rendering Manager): kernel device driver to access GPU and video controller hardware blocks Running Android on the Raspberry Pi 24 Copyright © 2011-2019, 2net Ltd
  • 66. DRI/DRM • DRI (Direct Rendering Infrastructure): user-space wrappers for DRM, including libdrm • DRM (Direct Rendering Manager): kernel device driver to access GPU and video controller hardware blocks # ls -l /dev/dri/* crw-rw-rw- 1 root graphics 226, 0 1970-01-01 00:00 /dev/dri/card0 crw-rw-rw- 1 root graphics 226, 128 1970-01-01 00:00 /dev/dri/renderD128 Running Android on the Raspberry Pi 24 Copyright © 2011-2019, 2net Ltd
  • 67. Open source graphics go mainstream • Google is encouraging vendors to move to mesa/DRM Running Android on the Raspberry Pi 25 Copyright © 2011-2019, 2net Ltd
  • 68. Open source graphics go mainstream • Google is encouraging vendors to move to mesa/DRM • For example • Pixel 3 has a Qualcomm 845 SoC with Adreno 630 GPU • Uses Mesa/DRM with freedreno driver See Alistair Strachan’s presentation at Linux Plumber’s conference, November 2018, DRM/KMS for Android https://linuxplumbersconf.org/event/2/contributions/229/attachments/53/60/ 10._DRM_KMS_for_Android_v1.pdf Running Android on the Raspberry Pi 25 Copyright © 2011-2019, 2net Ltd
  • 69. Graphics: Swiftshader SwiftShader OpenGLES OpenGLES App 3-D graphics android.opengl.* HWUI 2-D graphics libEGL.so libGLESv1_cm.so libGLESv2.so libEGL_swiftshader.so libGLESv1_CM_swiftshader.so libGLESv2_swiftshader.so Surface Flinger FBDEV Framework HAL Kernel Running Android on the Raspberry Pi 26 Copyright © 2011-2019, 2net Ltd
  • 70. Challenge 3: ADB • Raspberry Pi only has USB host ports, but ADB needs a USB peripheral port Running Android on the Raspberry Pi 27 Copyright © 2011-2019, 2net Ltd
  • 71. Challenge 3: ADB • Raspberry Pi only has USB host ports, but ADB needs a USB peripheral port • Usually provided by a dual mode USB "On The Go" (OTG) port Running Android on the Raspberry Pi 27 Copyright © 2011-2019, 2net Ltd
  • 72. Challenge 3: ADB • Raspberry Pi only has USB host ports, but ADB needs a USB peripheral port • Usually provided by a dual mode USB "On The Go" (OTG) port • (Actually, the BCM283x has OTG hardware but it is used internally to bridge the USB host controller, Ethernet, and so on) Running Android on the Raspberry Pi 27 Copyright © 2011-2019, 2net Ltd
  • 73. Challenge 3: ADB • Raspberry Pi only has USB host ports, but ADB needs a USB peripheral port • Usually provided by a dual mode USB "On The Go" (OTG) port • (Actually, the BCM283x has OTG hardware but it is used internally to bridge the USB host controller, Ethernet, and so on) • But, we can use ADB over Ethernet instead $ adb connect Android.local connected to Android.local:5555 Running Android on the Raspberry Pi 27 Copyright © 2011-2019, 2net Ltd
  • 74. Challenge 3: ADB • Raspberry Pi only has USB host ports, but ADB needs a USB peripheral port • Usually provided by a dual mode USB "On The Go" (OTG) port • (Actually, the BCM283x has OTG hardware but it is used internally to bridge the USB host controller, Ethernet, and so on) • But, we can use ADB over Ethernet instead $ adb connect Android.local connected to Android.local:5555 $ adb shell rpi3:/ # Running Android on the Raspberry Pi 27 Copyright © 2011-2019, 2net Ltd
  • 75. Current status • Code is on github (URL at the end) • Based on Android Pie 9.0 r 30 • Using SwiftShader • Works: • HDMI touch screen • Ethernet • WiFi (probably) • Bluetooth (possibly) • Not working: • Audio • Streaming video • Lots of other things... • Early stages: still many things to do Running Android on the Raspberry Pi 28 Copyright © 2011-2019, 2net Ltd
  • 76. Apps • Has standard AOSP apps • Install Gapps if you want PlayStore, etc https://opengapps.org • Note: this does not come with a license from Google Running Android on the Raspberry Pi 29 Copyright © 2011-2019, 2net Ltd
  • 77. Delving deeper • If you would like to discover more about building Android platforms, visit http://www.2net.co.uk/training.html and enquire about training classes for your company • 2net training is available world-wide Running Android on the Raspberry Pi 30 Copyright © 2011-2019, 2net Ltd
  • 78. Relevant links: Android 4 RPi https://github.com/csimmonds/a4rpi-local-manifest @2net_software http://www.2net.co.uk Any questions? Running Android on the Raspberry Pi 31 Copyright © 2011-2019, 2net Ltd