33
Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul N. Khan Department of Electrical & Computer Engineering EE8205 Embedded Computer Systems

Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

PortingAndroidtoDE1SoCBy:MuhammadObaidullah

SupervisedBy:Dr.GulN.Khan

DepartmentofElectrical&ComputerEngineeringEE8205EmbeddedComputerSystems

Page 2: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

OverviewIntroduction

Inspiration

LiteratureReview

Implementation

Results

Conclusion

Page 3: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

INTRODUCTION 1

Page 4: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

WhatisAndroid?

[1]

[1]

Page 5: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

INSPIRATION 2

Page 6: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

• CodeisavailableonlineandmanagedbyGoogleAndroidOpenSourceProject(AOSP).

• BasedonLinux.• Designedforembeddeddevices.• Suitedtolowpowerdevices• AndroidisEverywhere

Page 7: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

LITERATUREREVIEW 3

Page 8: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

DifferenceBetweenLinuxandAndroid

Linux(EmbeddedSystem)

PowerUpDevice

Bootloader(U-Boot)

InternalROM

Preloader(BL1)

Kernel

INIT

EmbeddedLinux(RootFileSystem)

Linux

PowerUpDevice

Bootloader(GRUB,LILO,etc)

SystemStartup(BIOS)

Bootloader(MBR)

Kernel

INIT

Linux(RootFileSystem)

Android(EmbeddedSystem)

PowerUpDevice

Bootloader(U-Boot)

InternalROM

Preloader(BL1)

Kernel

INIT

Zygote

Dalvik VM

Android(RootFileSystem)

Page 9: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

RawBinaryFiles(.rbf)ALTERACycloneV

L1CAHCE L1CAHCE

L2CAHCE

HPS FPGA

VIDEOAcc.

FloatingPointAcc.

AUDIOAcc.

Memory(FATPartition)

.rbf

FPAccelerator

.rbf

VideoAccelerator

.rbf

AudioAccelerator

• WritehardwarecodeinVHDL/Verilog/SystemVerilog

• CompileandverifythedesignusingQuartus togetSRAMObjectFile(.sof)

• Convert.sof fileto.rbf• Copythegenerated.rbf filetoSDcard’sFAT

partition• Decideonhowtoloadtheconfigurationbit

stream(Choosefromfollowing)

o Pre-loaderscripto U-Bootsourcecodeo U-Bootscripto Linuxinito Linuxapplication(runtime)

Page 10: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

LinuxDeviceFiles

Theapplicationfindsthedevicefilebasedondevicefilename

Devicefilefindsthedevicedriverbasedonthemajornumber

Devicedriverfindsdevicebasedontheminornumber

Java/C/C++…

Application

AFile

DeviceFile

Executable

DeviceDriver

Hardware

Device

/

dev bin etc mnt…

ttyS0

ttyS1

ttyS2

ttyUSB0

socfpga

enable

hps_to_fpga

fpga_to_hps

Page 11: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

AlteraSoC LinuxHardware/SoftwareHandoff

[7]

HardwareProject

BoardInformation

BoardInformation

HandoffFolder

Quartus II

DeviceTreeGenerator:sopc2dts

BootloaderGenerator:bsp-editor

BootloaderDTSource

BootloaderDTBlob

DTC

LinuxDTBlob

MakeFile

u-bootSourceCode

Make u-bootBinary

mkpimage u-bootimage

Regenerateonlywhenuseroptions(bootsourceetc.)change

Regeneratewhenhardwareprojectisrecompiled

Legend:

ProvidedbyAltera

OpenSource

InputFile

IntermediateFile

OutputFile

Page 12: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

AndroidBootSequenceCPU

Bootloader- InitializeRAM- PutbasicHWinquiescentstate- LoadkernelandRAMdisk- Jumptokernel

Kernel- InitializeenvironmenttorunCcode- Initializekernelsubsystems- Initializealldrivers- MountrootFileSystem- Start“init”process

Init- Setupenv.variables- Createmountpoints- MountFileSystem(FS)- SetupFSpermissions- SetOOMadj.- Startnativedaemons

NativeDaemons- servicemanager- vold- netd- debuggerd- rild- app_process-XZygote- mediaserver

- bootanimation- bluetoothhd- dbus-deamon- installd- keystore- adbd

AndroidRuntime(ART)- StartaDalvik VM- CallZygote’smain()

Zygote- RegisterZygotesocket- PreloadallJavaclasses- Preloadresources- StartSystemServer- Opensocket- Listenforconnections

SystemServerForeachservice:- Init service- RegisteritwithServiceManager

ActivityManager- Init itself- Sendintent.CATEGORY_HOME

Launcher- Init itself- RegisteronClick()handlers

startActivity()

App

fork()

Click()

Android Linux

Page 13: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

IMPLEMENTATION 4

Page 14: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

Step1:StudyingCycloneVHPSMemoryMap

SlavesviaHPAXIBridge

SlavesviaLWAXIBridge

SDMMCModule

QSPIFlashControllerModule

GPIOModule

USBOTGController

DMAModule

BootROMModule

On-ChipRAMModule0xFFFD0000- 0xFFFFFFFF

0xFFFD0000- 0xFFFDFFFF

0xFFFE0000- 0xFFE01FFF

0xFFB00000- 0xFFB7FFFF

0x FF708000 - 0x FF70A07F

0x FF705000 - 0x FF7050FF

0x FF704000 - 0x FF7043FF

0x FF200000 - 0xFF3FFFFF

0xC0000000- 0xFBFFFFFF

[5]

Memory

0xFF704000

DATAADDRESS

01001011

0xFF7043FF 01001011

0xFF704001 11010010……

0xFFFFFFFF 10011001

0x00000000 10011001

SDMMCModule

Page 15: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

Step2:FindingResources

[6]

S.No. Component RepositoryName GitHubURL

1. AngstromScripts angstrom-socfpga https://github.com/altera-opensource/angstrom-socfpga

2. BootLoader u-Boot-socfpga https://github.com/altera-opensource/u-boot-socfpga

3. DeviceTreeGenerator sopc2dts https://github.com/altera-opensource/sopc2dts

4. LinuxKernel linux-socfpga https://github.com/altera-opensource/linux-socfpga

5. ReferenceDesigns linux-refdesigns https://github.com/altera-opensource/linux-refdesigns

6. Yocoto Layer meta-altera https://github.com/altera-opensource/meta-altera

Page 16: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

Step3:InternalROMConfiguration Android(DE1-SoC)

PowerUpDevice

Bootloader(U-Boot)

InternalROM

Preloader(BL1)

Kernel

INIT

Zygote

Dalvik VM

Android(RootFileSystem)

MSEL[4:0] Configuration Scheme Description

10010 AS FPGAconfiguredfromEPCQ(default)

01010 FPPx32 FPGAconfiguredfromHPSsoftware:Linux

00000 FPPx16

FPGAconfiguredfromHPSsoftware:U-Boot,withimagestoredontheSDcard,likeLXDEDesktoporconsoleLinuxwithframebufferedition

Page 17: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

Step4:GeneratingPreloader Android(DE1-SoC)

PowerUpDevice

Bootloader(U-Boot)

InternalROM

Preloader(BL1)

Kernel

INIT

Zygote

Dalvik VM

Android(RootFileSystem)

Preloader(Unknown)

U-Boot(W95FAT32)

LinuxFileSystem(Linux)

1MB

256MB

~MB

dd

.bin

Preloader-mkpimage.bin

Page 18: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

Step5:GeneratingU-Boot Android(DE1-SoC)

PowerUpDevice

Bootloader(U-Boot)

InternalROM

Preloader(BL1)

Kernel

INIT

Zygote

Dalvik VM

Android(RootFileSystem)

Preloader(Unknown)

U-Boot(W95FAT32)

LinuxFileSystem(Linux)

1MB

256MB

~MB

copy .img

uboot.img

$git clonehttps://github.com/altera-opensource/u-boot-socfpga.git$makemrproper$makesocfpga_cyclone5_config$make

Page 19: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

echo-- ProgrammingFPGA–fatload mmc0:1$fpgadata soc_config.rbf;fpga load0$fpgadata $filesize;runbridge_enable_handoff;

echo-- SettingEnv Variables–setenv fdtimage soc_system.dtb;setenv mmcroot /dev/ram;setenv mmcload 'mmcrescan;${mmcloadcmd}mmc0:${mmcloadpart}${loadaddr}${bootimage};${mmcloadcmd}mmc0:${mmcloadpart}${fdtaddr}${fdtimage};setenv mmcboot 'setenv bootargsconsole=ttyS0,115200root=${mmcroot}rwrootwait;bootz ${loadaddr}- ${fdtaddr}';

runmmcload;runmmcboot;

Step6:GeneratingU-BootScript Android(DE1-SoC)

PowerUpDevice

Bootloader(U-Boot)

InternalROM

Preloader(BL1)

Kernel

INIT

Zygote

Dalvik VM

Android(RootFileSystem)

Preloader(Unknown)

U-Boot(W95FAT32)

LinuxFileSystem(Linux)

1MB

256MB

~MB

copy

.scr

uboot.scr

Page 20: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

$git clonehttps://github.com/altera-opensource/linux-socfpga.git$makeARCH=armsocfpga_custom_defconfig$make ARCH=arm menuconfig

Step7:ConfiguringLinux Android(DE1-SoC)

PowerUpDevice

Bootloader(U-Boot)

InternalROM

Preloader(BL1)

Kernel

INIT

Zygote

Dalvik VM

Android(RootFileSystem)

SpecifythefilesystemandRAMdisktoload

Page 21: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

$make ARCH=arm LOCALVERSION= zImage

Step8:CompilingLinux Android(DE1-SoC)

PowerUpDevice

Bootloader(U-Boot)

InternalROM

Preloader(BL1)

Kernel

INIT

Zygote

Dalvik VM

Android(RootFileSystem)

Preloader(Unknown)

U-Boot(W95FAT32)

LinuxFileSystem(Linux)

1MB

256MB

~MB

copyzImage

Page 22: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

$make ARCH=arm CONFIG_DTB_SOURCE=arch/arm/boot/dts/baseTree.dts <your-dev-board>.dtb

Step8:GeneratingDeviceTreeBlob Android(DE1-SoC)

PowerUpDevice

Bootloader(U-Boot)

InternalROM

Preloader(BL1)

Kernel

INIT

Zygote

Dalvik VM

Android(RootFileSystem)

Preloader(Unknown)

U-Boot(W95FAT32)

LinuxFileSystem(Linux)

1MB

256MB

~MB

copy

.dtb

soc_system.dtb

.dtsi

baseTree.dtsi

.dtsi

overlay1.dtsi

.dtsi

overlayN.dtsi

Page 23: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

Step9:AndroidBindingsDeveloping your device drivers is similar todeveloping a typical Linux device driver. Androiduses a version of the Linux kernel with a fewspecial additions such as wake locks (a memorymanagement system that is more aggressive inpreserving memory), the Binder IPC driver, andother features important for a mobile embeddedplatform. These additions are primarily forsystem functionality and do not affect driverdevelopment.

You can use any version of the kernel as long as itsupports the required features (such as thebinder driver).

Page 24: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

Step10:AndroidApplication

/

dev

socfpga

enable

hps_to_fpga

fpga_to_hps

write

write

read

Page 25: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

RESULTS 5

Page 26: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

RawBinaryFiles(.rbf)inAndroidApplicationPackage(.apk)

ALTERACycloneV

L1CAHCE L1CAHCE

L2CAHCE

HPS FPGA

App2Acc.

App1Acc.

App3Acc.

Memory• Load.rbf fileonactivitycreate

eventontothefpga foracceleration

• Remove.rbf fileonactivitycloseevent

• AndroidInit()shouldconfigurethefpga withbaseconfigurationfileandseveralPRRs(PartialReconfigurationRegions).

MP4PlayerApp(.apk)

.rbf

GameApp(.apk)

.rbf

Page 27: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

Demo

Page 28: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

CONCLUSION 6

Page 29: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

App-basedHardwareAcceleration

Page 30: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

BooksUsed

Page 31: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

“People who are really serious about software should make their own

hardware.

~ Alan Kay (Computer Scientist)

Page 32: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

References1. Google Inc.,"Android Open Source Project,"Google,23August 2016.[Online].Available:https://source.android.com.[Accessed 9

November 2016].2. M.Daum,"Android for DE1-SoCBoard,"RocketBoards.org,6October 2016.[Online].Available:

https://rocketboards.org/foswiki/view/Projects/AndroidForDE1SoCBoard.[Accessed 9November 2016].3. "Graphics Accelerator for Android,"FUJISOFTINCORPORATED,15November 2013.[Online].Available:https://www.fsi-

embedded.jp/e/_emb/gaforandroid_e/.[Accessed 9November 2016].4. Intel,"Implementation of an Android™Operating Systemon an Altera SoC,"Intel,8January 2014.[Online].Available:

https://youtu.be/zHqS_yWiMNI.[Accessed 9November 2016].5. Altera,"CycloneV HPSMemoryMap,"Altera,16 November2016.[Online].Available:

https://www.altera.com/hps/en_us/cyclone-v/hps.html#topic/sfo1418687413697.html.[Accessed 16 November 2016].6. YvesVandervennet,"MovetoGitHub,"RocketBoards.org,7 August2015.[Online].Available:

https://rocketboards.org/foswiki/view/Documentation/MoveToGitHub.[Accessed 21 November 2016].7. Altera,"Workshop#1– AlteraSoC SoftwareDevelopmentOverview,"RocketBoards.org,23 April2016.[Online].Available:

https://rocketboards.org/foswiki/pub/Documentation/WS1IntroToAlteraSoCDevices/WS_1_Intro_To_SoC_SW_Workshop.pdf.[Accessed 23 November 2016].

Page 33: Porting Android to DE1 SoC - Muhammad Obaidullahobaidtech.com/files/Courses/EM_Final_Presentation.pdf · Porting Android to DE1 SoC By: Muhammad Obaidullah Supervised By: Dr. Gul

THANKS!Any questions?

You can find me atENG 402 / [email protected]