porting android to de1 soc - muhammad...
TRANSCRIPT
PortingAndroidtoDE1SoCBy:MuhammadObaidullah
SupervisedBy:Dr.GulN.Khan
DepartmentofElectrical&ComputerEngineeringEE8205EmbeddedComputerSystems
OverviewIntroduction
Inspiration
LiteratureReview
Implementation
Results
Conclusion
INTRODUCTION 1
WhatisAndroid?
[1]
[1]
INSPIRATION 2
• CodeisavailableonlineandmanagedbyGoogleAndroidOpenSourceProject(AOSP).
• BasedonLinux.• Designedforembeddeddevices.• Suitedtolowpowerdevices• AndroidisEverywhere
LITERATUREREVIEW 3
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)
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)
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
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
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
IMPLEMENTATION 4
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
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
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
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
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
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
$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
$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
$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
…
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).
Step10:AndroidApplication
/
dev
socfpga
enable
hps_to_fpga
fpga_to_hps
write
write
read
RESULTS 5
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
Demo
CONCLUSION 6
App-basedHardwareAcceleration
BooksUsed
“People who are really serious about software should make their own
hardware.
~ Alan Kay (Computer Scientist)
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].
THANKS!Any questions?
You can find me atENG 402 / [email protected]