Porting Android to Beagleboard Anish Dhanekula Karl Arndt.

27
Porting Android to Beagleboard Anish Dhanekula Karl Arndt

Transcript of Porting Android to Beagleboard Anish Dhanekula Karl Arndt.

Porting Android to Beagleboard

Anish Dhanekula

Karl Arndt

Porting Android to Beagleboard 2

What is Android?

• Linux-based Operating System for Mobile Devices

• Developed by Android, Inc.– Acquired by Google

• Open-Source, under Apache License– Proprietary extensions developed by vendors

don’t have to be submitted back to open-source commnunity

Porting Android to Beagleboard 3

What is Android?

• Modified Linux Kernel– Éclair (Android v2.0/2.1) based on 2.6.29

• Filesystem– Uses the Bionic C Library instead of glibc– Dalvik Java Virtual Machine

• Is it really Linux?– Sort of… Definitely Linux kernel, but not a

traditional userspace

Porting Android to Beagleboard 4

What is Android?

Porting Android to Beagleboard 5

What’s a Beagleboard?

Porting Android to Beagleboard 6

What’s a Beagleboard?

• OMAP 3530– TI SoC with ARM Cortex A8 and 64x DSP

• SDRAM and Flash on-package with Package-on-Package (PoP)

Porting Android to Beagleboard 7

What’s a Beagleboard?

• Peripherals– SD/MMC Socket for Storage– DVI-D and S-Video– Stereo In and Out– USB– Serial

• Bootloader– U-Boot comes loaded on the PoP Flash

Porting Android to Beagleboard 8

Porting Process

• Get Android Source– Kernel and Filesystem

• Prove it can work• Modify Kernel files as necessary to work with

Beagleboard• Compile• Write to SD Card• Try to Boot• Doesn’t work – pray that your Beagleboard gets stolen

while you grab dinner• Fix Kernel Boot Errors• Repeat

Porting Android to Beagleboard 9

‘Git’ing Android Source

• Kernel – android.git.kernel.org– OMAP tree

• Filesystem – source.android.com– We used a prebuilt filesystem known to work

on Beagleboard in order to focus on the kernel

• Git– Source management tool

Porting Android to Beagleboard 10

Storage Format

• Kernel and Filesystem need to be stored in a particular way on the SD Flash

• Two Partitions– FAT32 Boot Partition

• Holds U-Boot update and compressed Kernel Image (uImage)

– EXT3 Filesystem Partition• Holds the complete root filesystem

Porting Android to Beagleboard 11

Early Boot Process

• OMAP PoP Flash comes with U-Boot, but needs to be replaced on boot– The PoP Flash U-Boot knows to attempt to

boot from the SD Flash first, and when it does it finds the updated U-Boot

• Environment variables must be set to boot properly

– setenv bootcmd ‘mmc init; fatload mmc 0 84000000 uImage; bootm 84000000’– setenv bootargs 'mem=128M androidboot.console=ttyS2 console=tty0

console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw init=/init

Porting Android to Beagleboard 12

Prove it can Work

• Rowboat– Someone has already ported Android to Beagleboard– Confirmed that this distribution works on our board

Porting Android to Beagleboard 13

Compiling the Kernel

• Since the kernel is being compiled on an x86 host for an ARM target, cross-compiling is necessary

• The arm-eabi toolchain is used for this– Included in the Android Filesystem Source

• make ARCH=arm CROSS_COMPILE=/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi uImage –j4

• uImage is the compressed Kernel Image• -j4 tells Make it can use 4 threads (two per CPU

on a dual-core machine

Porting Android to Beagleboard 14

Modifying Kernel Source

• Create the .config file– make defconfig– make ARCH=arm defconfig– make ARCH=arm omap3_beagle_defconfig

• Edit .config to include all necessary settings and modules– make ARCH=arm menuconfig

Porting Android to Beagleboard 15

Modifying Kernel Source• menuconfig

Porting Android to Beagleboard 16

Modifying Kernel Source

• .config– Compilation parameters are chosen

• Particular implementation of an architecture

– Drivers are chosen• Must determine the correct drivers for your

SoC/Board and include them here• Drivers can be included as built-in or modular

Porting Android to Beagleboard 17

Modifying Kernel Source

• .config – selecting the right drivers– Real Time Clock

• Real Time Clock initialization was failing on kernel boot

• Found that the Beagle uses a TWL4030 I2C RTC Controller

• Had to enable I2C, TWL Core, and TWL4030 Drivers

Porting Android to Beagleboard 18

Modifying Kernel Source

• .config – selecting the right drivers– MMC/SD

• Filesystem is stored on SD card• Found correct driver by sorting through Angstrom

Linux running on the Beagleboard

Porting Android to Beagleboard 19

Modifying Kernel Source

• Correct Drivers are chosen, but Kernel won’t boot…

• Need to dig into actual Kernel Source and Boot Process

Porting Android to Beagleboard 20

Modifying Kernel Source

• Kernel Boot Process– Run code from /arch/arm/mach-omap2 to

initialize devices– Run /init/main.c to mount the root filesystem– Once the root filesystem is mounted, run /init

(or whatever is specified to U-Boot) as the first process

Porting Android to Beagleboard 21

Modifying Kernel Source

• RTC is initialized now, but Kernel Boot still hangs– “Waiting for root device /dev/mmcblk0p2…”– This message was found in /init/do_mounts.c

• Called in /init/main.c• While loop continuously polling

– Device_probe_done()– name_to_dev_t()

Porting Android to Beagleboard 22

Modifying Kernel Source

• One of the routines is not completing– Traversed name_to_dev_t() with printk

• Seems to work fine

– Difficult to traverse name_to_dev_t()• Decided to look through initial device initialization

code in /arch/arm/mach-omap2 and SD driver in /drivers/mmc/host/omap_hsmmc.c

Porting Android to Beagleboard 23

Modifying Kernel Source

• /arch/arm/mach-omap2/board-omap3beagle– Several __init statements

• omap3_beagle_init– Calls omap3beagle_flash_init

– This is where the devices are initialized during bootup, but we can’t find anything wrong…

Porting Android to Beagleboard 24

Next Steps

• Hard-coded device names

Porting Android to Beagleboard 25

Things we would do differently

• Spend less time modifying the .config file and more time on the kernel source itself

• Maybe try Network File System (NFS) to store the Filesystem

Porting Android to Beagleboard 26

References

• Linux Kernel in a Nutshell– Greg Kroah-Hartman

• Linux from Scratch– Gerard Beekmans

• code.google.com/p/beagleboard/wiki• code.google.com/p/rowboat/wiki• source.android.com• android.git.kernel.org• www.beagleboard.com

Porting Android to Beagleboard 27

Questions?