A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)

Porting Android ICS to a custom board
                   A war story




Matthias Brugger
ELCE 2012 – Porting Android ICS




Outline

    ●
        Android beyond smartphones?
    ●
        Why a war story
    ●
        Our custom board
    ●
        Android building system
    ●
        Lessons learned
        ●
          Add device
        ●
          Bootloader/Kernel integration
        ●
          Powersupply
        ●
          Button
        ●
          Touchscreen calibration
        ●
          Wi-Fi
        ●
          Sound
        ●
          HW acceleration
ELCE 2012 – Porting Android ICS




Android beyond smartphones?

    ✔ Easy to implement applications (SDK, API, Java)
    ✔ Human-Machine-Interface
      ✔ well defined
      ✔ tested in the wild
    ✔ Reliability of the system
    ► good for HMI centred embedded systems


    ✗ Integrate native application
    ✗ Porting to a new board can be a war story
ELCE 2012 – Porting Android ICS




Why is it a war story

     ●
         Little documentation
     ●
         Small community
     ●
         Vendor specific communities
     ●
         Developing process of Android
     ●
         A huge jungle of programming languages
ELCE 2012 – Porting Android ICS




Why is it a war story

     ●
         Android is Linux, but... Android is not Linux!
         ●
           Patched Kernel adds new features
         ●
           Userspace varies widely
           ●
             Own libc (bionic)
           ●
             Lots of basic building blocks are not integrated
             ●
               XWindows
             ●
               Busybox
           ●
             Core system is executed on dalvikVM
           ●
             IPC implementation (binder) varies from SystemV
           ●
             Building blocks are compiled to dynamic libraries
             which are loaded by the core system in different ways and layers
ELCE 2012 – Porting Android ICS




Why is it a war story
ELCE 2012 – Porting Android ICS




Our custom board
ELCE 2012 – Porting Android ICS




Our custom board

    ●
        One button only
    ●
        No phone
    ●
        No battery monitor
    ●
        Ethernet
    ●
        Wifi
    ●
        Touchscreen
    ●
        Sound
    ●
        HW acceleration from OMAP3
ELCE 2012 – Porting Android ICS




Android building system

  ●
      Important folders
      ●
        build
      ●
        frameworks/base
      ●
        external
      ●
        hardware
      ●
        device
      ●
        out/target/product/<product_name>
ELCE 2012 – Porting Android ICS




           Lessons learned
ELCE 2012 – Porting Android ICS




Lesson learned I: Add device to our build
  ●
      Devices are found under device/<manufactor>/<board> folder
      ●
        <device_name>.mk
        ●
          Define which basic packages to install for the board
        ●
          Inherit from default product (in build/target/product)
        ●
          Add the proper device:
      ●
        device.mk
        ●
          Define files that have to be copyed to the rootfs
        ●
          Define where to find the overlay
      ●
        BoardConfig.mk
        ●
          Define build flags
      ●
        vendorsetup.sh
        ●
          Add “lunch” menu option
ELCE 2012 – Porting Android ICS




Lessons Learned II: Bootloader/Kernel integration
  ●
      Problems
      ●
        In AOSP precompiled Kernel image
      ●
        Specific compiler needed?

  ●
      Solution
      ●
        We add a “wrapper” in the Makefile
      ●
        After building the android “userspace” build
        ●
          Bootloader
        ●
          Kernel
        ●
          Copy kernel modules to out/target/product

  ●
      Extra boot parameter:
      ●
        androidboot.console=ttyO2
      ●
        init=/init
ELCE 2012 – Porting Android ICS




Lessons Learned III: Powersupply
  ●
      Boot hangs on splash screen
  ●
      Have a look with logcat what's going on
ELCE 2012 – Porting Android ICS




Lessons Learned III: Powersupply
  E/BatteryService( 1008): Could not open /sys/class/power_supply
  (…)
  I/SystemServer( 1008): Battery Service
  W/dalvikvm( 1008): No implementation found for native Lcom/android/server/BatteryService;.native_update ()V
  W/dalvikvm( 1008): threadid=11: thread exiting with uncaught exception (group=0x409e11f8)
  I/Process ( 1008): Sending signal. PID: 1008 SIG: 9
  E/AndroidRuntime( 1008): *** FATAL EXCEPTION IN SYSTEM PROCESS: android.server.ServerThread
  E/AndroidRuntime( 1008): java.lang.UnsatisfiedLinkError: native_update
  E/AndroidRuntime( 1008): at com.android.server.BatteryService.native_update(Native Method)
  E/AndroidRuntime( 1008): at com.android.server.BatteryService.update(BatteryService.java:233)
  E/AndroidRuntime( 1008): at com.android.server.BatteryService.<init>(BatteryService.java:148)
  E/AndroidRuntime( 1008): at com.android.server.ServerThread.run(SystemServer.java:196)
  I/Zygote ( 967): Exit zygote because system server (1008) has terminated
  E/installd( 913): eof
  E/installd( 913): failed to read size
  I/installd( 913): closing connection
  I/installd( 913): new connection
  I/ServiceManager( 903): service 'gfxinfo' died
  I/ServiceManager( 903): service 'activity' died
  I/ServiceManager( 903): service 'cpuinfo' died
  I/ServiceManager( 903): service 'sensorservice' died
  I/ServiceManager( 903): service 'meminfo' died
  I/ServiceManager( 903): service 'account' died
  I/ServiceManager( 903): service 'usagestats' died
  I/ServiceManager( 903): service 'permission' died
  I/ServiceManager( 903): service 'hardware' died
  I/ServiceManager( 903): service 'content' died
  (...)
ELCE 2012 – Porting Android ICS




Lessons Learned III: Powersupply
ELCE 2012 – Porting Android ICS




Lessons Learned III: Powersupply
  ●
      What has happened?
      ●
        When JNI is loaded, it registers the low level services (e.g. BatteryService)
        ●
          read values from sysfs
        ●
          BatteryService JNI registers function native_update at BatteryService.java

      ●
          But...
          ●
            BatteryService JNI interface doesn't find “/sys/class/power_supply”
          ●
            Returns error, which is ignored by JNI_OnLoad

      ●
          SystemServer thread creates BatteryService when executed
          ●
            BatteryService tries to update values invoking native_update
          ●
            No JNI interface registered – SystemServer dies...
ELCE 2012 – Porting Android ICS




Lessons Learned III: Powersupply
  ●
      Solution
        ●
          No working battery monitor in our system
          → No power supply class in kernel
        ●
           Adding the power supply class
          ●
             Shows battery empty warning in status bar
        ●
           Add the “test power driver”
          ●
             Shows Battery at 50% charging fixed

  ●
      Has influence on the behaviour of the Power Manager
ELCE 2012 – Porting Android ICS




Lessons Learned IV: Button Integration
  ●
      Can be found in frameworks/base/services/input:
      ●
        Android scans /dev/input folder in a loop
      ●
        Polls for events using epoll
      ●
        Identifies touchscreens, joysticks, mice, keyboards automatically

      ●
          Key Layout File (/system/usr/keylayout) maps raw input key to
          internal Android key representation
      ●
          Key Char Map File (/system/usr/keychars) describes
          action for internal Android key
ELCE 2012 – Porting Android ICS




Lessons Learned IV: Button Integration
  ●
      Our case
      ●
        Just one button, no external keyboard
  ●
      Two alternatives:
      ●
        Define own Key Layout/Key Char Map files
      ●
        Configure key code in kernel appropriately
      ●
        Beware Key Layout File uses numeric number of key code
      ●
        Not all values in Key Layout have a define in include/linux/input.h
ELCE 2012 – Porting Android ICS




Lessons Learned V: Touchscreen calibration
  ●
      Detection and input analogous to button integration
  ●
      Driver sends X-Y-coordinates

  ●
      Callibrate the touchscreen
      ●
        We have to reach all parts of the screen easily
        ●
           Turn on show touches in Settings/Developer options
        ●
           Adjust max and min values of your touchscreen in the plattform data
ELCE 2012 – Porting Android ICS




Lessons Learned VI: Wi-Fi

  ●
    Example of complexity of Android source code
    ●
      Different libraries and services
    ●
      5 different folders with userspace code
  ●
    Uses wpa_supplicant to connect to a protected WLAN
    ●
      Enhanced with Android specific commands
      ●
        START, STOP, SCAN-ACTIVE, SCAN-PASSIVE, RSSI, LINKSPEED, …
ELCE 2012 – Porting Android ICS




Lessons Learned VI: Wi-Fi
ELCE 2012 – Porting Android ICS




Lessons Learned VI: Wi-Fi
  ●
      Integration
      ●
        Legacy implementation reads wpa supplicant config file
        ●
          /data/misc/wifi/wpa_supplicant.conf → product specific
        ●
          /system/etc/wifi/wpa_supplicant.conf → template

      ●
          Kernel and firmware module
          ●
            In BoardConfig.mk define:
            ●
              WIFI_DRIVER_MODULE_PATH
            ●
              WIFI_DRIVER_MODULE_NAME
            ●
              WIFI_FIRMWARE_LOADER
          ●
            Hardware legacy layer in charge of loading/unloading
            kernel module and firmware; starts/stops wpa_supplicant

      ●
          Start wpa_supplicant and dhcp for wlan
            ●
              service wpa_supplicant /system/bin/wpa_supplicant -Dwext -iwlan0
            ●
              service dhcpcd_wlan0 /system/bin/dhcpcd -ABKL
ELCE 2012 – Porting Android ICS




Lessons Learned VII: Audio
  ●
      Audio player is stagefright
  ●
      AudioFlinger interfaces hardware abstraction
      ●
        Uses struct audio_hw_device in hardware/libhardware/include
  ●
      audio.primary.<device_name>
      ●
        Encapsulates the hardware - custom implementation
ELCE 2012 – Porting Android ICS




Lessons Learned VIII: Hardware Acceleration
  ●
      Two possibilities
      ●
        Integrate mulitmedia framework supporting HW acceleration
        ✔ Has bindings for HW accelerator
        ✔ Might have more codecs then stagefright


          ✗ Maintenace might be costly


      ●
          Integrate HW acceleration support in existing Android multimedia framework
          ✔ Should be easy to maintain


          ✗ Need to create bindings for the HW accelerator
ELCE 2012 – Porting Android ICS




Lessons Learned VIII: Hardware Acceleration
  libmediaplayerservice:
ELCE 2012 – Porting Android ICS




Lessons Learned VIII: Hardware Acceleration
  ●
      Add own multimedia framework
      ●
        Register your framework as MediaPlayerInterface
      ●
        Create player instance in MediaPlayerService
      ●
        Implement new MetadataRetriever in MetadataRetrieverClient

  ●
      Implement wrapper
      ●
        Audio sink using AudioTrack
      ●
        Video sink using Surface
ELCE 2012 – Porting Android ICS




Lessons Learned VIII: Hardware Acceleration
  libsurfaceflinger:
ELCE 2012 – Porting Android ICS




Lessons Learned VI: Hardware Acceleration
  libstagefright:
Porting Android ICS to a custom board
                A war story




matthias.bgg@gmail.com
A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)
1 of 31

Recommended

Android porting for dummies @droidconin 2011 by
Android porting for dummies @droidconin 2011Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011pundiramit
5.5K views27 slides
Q4.11: Porting Android to new Platforms by
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsLinaro
4.4K views24 slides
Porting Android by
Porting AndroidPorting Android
Porting AndroidOpersys inc.
4K views42 slides
Jollen's Presentation: Introducing Android low-level by
Jollen's Presentation: Introducing Android low-levelJollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-levelJollen Chen
2.5K views120 slides
Android OS Porting: Introduction by
Android OS Porting: IntroductionAndroid OS Porting: Introduction
Android OS Porting: IntroductionJollen Chen
12K views66 slides
Using and Customizing the Android Framework / part 4 of Embedded Android Work... by
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Opersys inc.
10K views61 slides

More Related Content

What's hot

Porting Android by
Porting AndroidPorting Android
Porting AndroidOpersys inc.
5 views49 slides
Understanding the Android System Server by
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
53.6K views25 slides
Android crash debugging by
Android crash debuggingAndroid crash debugging
Android crash debuggingAshish Agrawal
49.3K views26 slides
Workshop su Android Kernel Hacking by
Workshop su Android Kernel HackingWorkshop su Android Kernel Hacking
Workshop su Android Kernel HackingDeveler S.r.l.
2.5K views34 slides
Inside Android's UI by
Inside Android's UIInside Android's UI
Inside Android's UIOpersys inc.
7.6K views44 slides
Android for Embedded Linux Developers by
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux DevelopersOpersys inc.
5.9K views60 slides

What's hot(20)

Understanding the Android System Server by Opersys inc.
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
Opersys inc.53.6K views
Android crash debugging by Ashish Agrawal
Android crash debuggingAndroid crash debugging
Android crash debugging
Ashish Agrawal49.3K views
Workshop su Android Kernel Hacking by Develer S.r.l.
Workshop su Android Kernel HackingWorkshop su Android Kernel Hacking
Workshop su Android Kernel Hacking
Develer S.r.l.2.5K views
Inside Android's UI by Opersys inc.
Inside Android's UIInside Android's UI
Inside Android's UI
Opersys inc.7.6K views
Android for Embedded Linux Developers by Opersys inc.
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
Opersys inc.5.9K views
Working with the AOSP - Linaro Connect Asia 2013 by Opersys inc.
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
Opersys inc.5.1K views
Android Security, From the Ground Up by Opersys inc.
Android Security, From the Ground UpAndroid Security, From the Ground Up
Android Security, From the Ground Up
Opersys inc.895 views
Android Internals by Opersys inc.
Android InternalsAndroid Internals
Android Internals
Opersys inc.7.8K views
Android On Development Boards at AnDevCon3 by Opersys inc.
Android On Development Boards at AnDevCon3Android On Development Boards at AnDevCon3
Android On Development Boards at AnDevCon3
Opersys inc.1.1K views
Embedded Android Workshop with Marshmallow by Opersys inc.
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
Opersys inc.4K views
Android Variants, Hacks, Tricks and Resources by Opersys inc.
Android Variants, Hacks, Tricks and ResourcesAndroid Variants, Hacks, Tricks and Resources
Android Variants, Hacks, Tricks and Resources
Opersys inc.3.6K views
Android Hacks, Variants, Tricks and Resources ESC SV 2012 by Opersys inc.
Android Hacks, Variants, Tricks and Resources ESC SV 2012Android Hacks, Variants, Tricks and Resources ESC SV 2012
Android Hacks, Variants, Tricks and Resources ESC SV 2012
Opersys inc.2.2K views
Customizing AOSP For Different Embedded Devices And Integration at Applicatio... by ijafrc
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
ijafrc2.4K views
Android Variants, Hacks, Tricks and Resources presented at AnDevConII by Opersys inc.
Android Variants, Hacks, Tricks and Resources presented at AnDevConIIAndroid Variants, Hacks, Tricks and Resources presented at AnDevConII
Android Variants, Hacks, Tricks and Resources presented at AnDevConII
Opersys inc.2.9K views
Booting Android: bootloaders, fastboot and boot images by Chris Simmonds
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
Chris Simmonds120.9K views

Viewers also liked

ABS 2013: Android Jelly Bean Device Porting Walkthrough by
ABS 2013: Android Jelly Bean Device Porting WalkthroughABS 2013: Android Jelly Bean Device Porting Walkthrough
ABS 2013: Android Jelly Bean Device Porting WalkthroughBenjamin Zores
10.9K views127 slides
ABS 2014 - Android Kit Kat Internals by
ABS 2014 - Android Kit Kat InternalsABS 2014 - Android Kit Kat Internals
ABS 2014 - Android Kit Kat InternalsBenjamin Zores
6.8K views66 slides
Apache Any23 - Anything to Triples by
Apache Any23 - Anything to TriplesApache Any23 - Anything to Triples
Apache Any23 - Anything to TriplesMichele Mostarda
2.2K views43 slides
Script writing & story board (Grade 10 Movie Project - Class work) by
Script writing & story board (Grade 10 Movie Project - Class work)Script writing & story board (Grade 10 Movie Project - Class work)
Script writing & story board (Grade 10 Movie Project - Class work)Jess Hugo
9.4K views13 slides
M Dot Extinction: The Next Evolution of Mobile Web by
M Dot Extinction: The Next Evolution of Mobile WebM Dot Extinction: The Next Evolution of Mobile Web
M Dot Extinction: The Next Evolution of Mobile WebMobify
41.9K views10 slides
AUDIENCE - 4 Keys to the Future of Mobile Video by
AUDIENCE - 4 Keys to the Future of Mobile Video AUDIENCE - 4 Keys to the Future of Mobile Video
AUDIENCE - 4 Keys to the Future of Mobile Video Liam Boogar-Azoulay
113K views44 slides

Viewers also liked(10)

ABS 2013: Android Jelly Bean Device Porting Walkthrough by Benjamin Zores
ABS 2013: Android Jelly Bean Device Porting WalkthroughABS 2013: Android Jelly Bean Device Porting Walkthrough
ABS 2013: Android Jelly Bean Device Porting Walkthrough
Benjamin Zores10.9K views
ABS 2014 - Android Kit Kat Internals by Benjamin Zores
ABS 2014 - Android Kit Kat InternalsABS 2014 - Android Kit Kat Internals
ABS 2014 - Android Kit Kat Internals
Benjamin Zores6.8K views
Apache Any23 - Anything to Triples by Michele Mostarda
Apache Any23 - Anything to TriplesApache Any23 - Anything to Triples
Apache Any23 - Anything to Triples
Michele Mostarda2.2K views
Script writing & story board (Grade 10 Movie Project - Class work) by Jess Hugo
Script writing & story board (Grade 10 Movie Project - Class work)Script writing & story board (Grade 10 Movie Project - Class work)
Script writing & story board (Grade 10 Movie Project - Class work)
Jess Hugo9.4K views
M Dot Extinction: The Next Evolution of Mobile Web by Mobify
M Dot Extinction: The Next Evolution of Mobile WebM Dot Extinction: The Next Evolution of Mobile Web
M Dot Extinction: The Next Evolution of Mobile Web
Mobify41.9K views
AUDIENCE - 4 Keys to the Future of Mobile Video by Liam Boogar-Azoulay
AUDIENCE - 4 Keys to the Future of Mobile Video AUDIENCE - 4 Keys to the Future of Mobile Video
AUDIENCE - 4 Keys to the Future of Mobile Video
Liam Boogar-Azoulay113K views
Y&R Global CEO David Sable on Mobile Disruption at 2016 Mobile World Congress by Young & Rubicam
Y&R Global CEO David Sable on Mobile Disruption at 2016 Mobile World CongressY&R Global CEO David Sable on Mobile Disruption at 2016 Mobile World Congress
Y&R Global CEO David Sable on Mobile Disruption at 2016 Mobile World Congress
Young & Rubicam22.2K views
Mobile Is Eating the World (2016) by a16z
Mobile Is Eating the World (2016)Mobile Is Eating the World (2016)
Mobile Is Eating the World (2016)
a16z1.7M views
Mobile-First SEO - The Marketers Edition #3XEDigital by Aleyda Solís
Mobile-First SEO - The Marketers Edition #3XEDigitalMobile-First SEO - The Marketers Edition #3XEDigital
Mobile-First SEO - The Marketers Edition #3XEDigital
Aleyda Solís471.4K views
UX, ethnography and possibilities: for Libraries, Museums and Archives by Ned Potter
UX, ethnography and possibilities: for Libraries, Museums and ArchivesUX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and Archives
Ned Potter1M views

Similar to A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)

Android Attacks by
Android AttacksAndroid Attacks
Android AttacksMichael Scovetta
4K views45 slides
Robot controlled car using Wireless Module by
 Robot controlled car using Wireless Module Robot controlled car using Wireless Module
Robot controlled car using Wireless Moduleshreyaseksambe
3K views24 slides
OWF12/PAUG Conf Days Alternative to google's android emulator, daniel fages, ... by
OWF12/PAUG Conf Days Alternative to google's android emulator, daniel fages, ...OWF12/PAUG Conf Days Alternative to google's android emulator, daniel fages, ...
OWF12/PAUG Conf Days Alternative to google's android emulator, daniel fages, ...Paris Open Source Summit
1.7K views24 slides
Android Things, from mobile apps to physical world by
Android Things, from mobile apps to physical worldAndroid Things, from mobile apps to physical world
Android Things, from mobile apps to physical worldStefano Sanna
371 views44 slides
Using the NDK and Renderscript by
Using the NDK and RenderscriptUsing the NDK and Renderscript
Using the NDK and RenderscriptMotorola Mobility - MOTODEV
5K views46 slides
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni... by
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...Codemotion
93 views44 slides

Similar to A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)(20)

Robot controlled car using Wireless Module by shreyaseksambe
 Robot controlled car using Wireless Module Robot controlled car using Wireless Module
Robot controlled car using Wireless Module
shreyaseksambe3K views
OWF12/PAUG Conf Days Alternative to google's android emulator, daniel fages, ... by Paris Open Source Summit
OWF12/PAUG Conf Days Alternative to google's android emulator, daniel fages, ...OWF12/PAUG Conf Days Alternative to google's android emulator, daniel fages, ...
OWF12/PAUG Conf Days Alternative to google's android emulator, daniel fages, ...
Android Things, from mobile apps to physical world by Stefano Sanna
Android Things, from mobile apps to physical worldAndroid Things, from mobile apps to physical world
Android Things, from mobile apps to physical world
Stefano Sanna371 views
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni... by Codemotion
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
Codemotion93 views
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an... by Codemotion
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...
Codemotion190 views
Ami device driver_services ver. 1.1 by Sunil Sam
Ami device driver_services ver.  1.1Ami device driver_services ver.  1.1
Ami device driver_services ver. 1.1
Sunil Sam2.1K views
ios-mobile-app-development-intro by Remesh Govind M
ios-mobile-app-development-introios-mobile-app-development-intro
ios-mobile-app-development-intro
Remesh Govind M4.5K views
Droidcon uk2012 androvm by dfages
Droidcon uk2012 androvmDroidcon uk2012 androvm
Droidcon uk2012 androvm
dfages1.4K views
Android internals by rabah3
Android internalsAndroid internals
Android internals
rabah3196 views
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu... by ICS
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
ICS395 views
iphone application development by arpitnot4u
iphone application developmentiphone application development
iphone application development
arpitnot4u431 views
[Android Codefest Germany] Adding x86 target to your Android app by Xavier Ha... by BeMyApp
[Android Codefest Germany] Adding x86 target to your Android app by Xavier Ha...[Android Codefest Germany] Adding x86 target to your Android app by Xavier Ha...
[Android Codefest Germany] Adding x86 target to your Android app by Xavier Ha...
BeMyApp2.7K views
Accessing Hardware on Android by Gary Bisson
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on Android
Gary Bisson18.4K views
Android Internals and Toolchain by Vladimir Kotov
Android Internals and ToolchainAndroid Internals and Toolchain
Android Internals and Toolchain
Vladimir Kotov5.2K views

Recently uploaded

"Package management in monorepos", Zoltan Kochan by
"Package management in monorepos", Zoltan Kochan"Package management in monorepos", Zoltan Kochan
"Package management in monorepos", Zoltan KochanFwdays
34 views18 slides
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...ShapeBlue
164 views13 slides
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlueShapeBlue
152 views23 slides
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueShapeBlue
224 views7 slides
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...Jasper Oosterveld
35 views49 slides
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsShapeBlue
247 views13 slides

Recently uploaded(20)

"Package management in monorepos", Zoltan Kochan by Fwdays
"Package management in monorepos", Zoltan Kochan"Package management in monorepos", Zoltan Kochan
"Package management in monorepos", Zoltan Kochan
Fwdays34 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue164 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue152 views
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue224 views
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue247 views
The Power of Generative AI in Accelerating No Code Adoption.pdf by Saeed Al Dhaheri
The Power of Generative AI in Accelerating No Code Adoption.pdfThe Power of Generative AI in Accelerating No Code Adoption.pdf
The Power of Generative AI in Accelerating No Code Adoption.pdf
Saeed Al Dhaheri39 views
Optimizing Communication to Optimize Human Behavior - LCBM by Yaman Kumar
Optimizing Communication to Optimize Human Behavior - LCBMOptimizing Communication to Optimize Human Behavior - LCBM
Optimizing Communication to Optimize Human Behavior - LCBM
Yaman Kumar38 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue139 views
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023 by BookNet Canada
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
BookNet Canada44 views
The Role of Patterns in the Era of Large Language Models by Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li91 views
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue120 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue183 views
Digital Personal Data Protection (DPDP) Practical Approach For CISOs by Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash162 views
Business Analyst Series 2023 - Week 4 Session 8 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray10145 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu437 views

A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)

  • 1. Porting Android ICS to a custom board A war story Matthias Brugger
  • 2. ELCE 2012 – Porting Android ICS Outline ● Android beyond smartphones? ● Why a war story ● Our custom board ● Android building system ● Lessons learned ● Add device ● Bootloader/Kernel integration ● Powersupply ● Button ● Touchscreen calibration ● Wi-Fi ● Sound ● HW acceleration
  • 3. ELCE 2012 – Porting Android ICS Android beyond smartphones? ✔ Easy to implement applications (SDK, API, Java) ✔ Human-Machine-Interface ✔ well defined ✔ tested in the wild ✔ Reliability of the system ► good for HMI centred embedded systems ✗ Integrate native application ✗ Porting to a new board can be a war story
  • 4. ELCE 2012 – Porting Android ICS Why is it a war story ● Little documentation ● Small community ● Vendor specific communities ● Developing process of Android ● A huge jungle of programming languages
  • 5. ELCE 2012 – Porting Android ICS Why is it a war story ● Android is Linux, but... Android is not Linux! ● Patched Kernel adds new features ● Userspace varies widely ● Own libc (bionic) ● Lots of basic building blocks are not integrated ● XWindows ● Busybox ● Core system is executed on dalvikVM ● IPC implementation (binder) varies from SystemV ● Building blocks are compiled to dynamic libraries which are loaded by the core system in different ways and layers
  • 6. ELCE 2012 – Porting Android ICS Why is it a war story
  • 7. ELCE 2012 – Porting Android ICS Our custom board
  • 8. ELCE 2012 – Porting Android ICS Our custom board ● One button only ● No phone ● No battery monitor ● Ethernet ● Wifi ● Touchscreen ● Sound ● HW acceleration from OMAP3
  • 9. ELCE 2012 – Porting Android ICS Android building system ● Important folders ● build ● frameworks/base ● external ● hardware ● device ● out/target/product/<product_name>
  • 10. ELCE 2012 – Porting Android ICS Lessons learned
  • 11. ELCE 2012 – Porting Android ICS Lesson learned I: Add device to our build ● Devices are found under device/<manufactor>/<board> folder ● <device_name>.mk ● Define which basic packages to install for the board ● Inherit from default product (in build/target/product) ● Add the proper device: ● device.mk ● Define files that have to be copyed to the rootfs ● Define where to find the overlay ● BoardConfig.mk ● Define build flags ● vendorsetup.sh ● Add “lunch” menu option
  • 12. ELCE 2012 – Porting Android ICS Lessons Learned II: Bootloader/Kernel integration ● Problems ● In AOSP precompiled Kernel image ● Specific compiler needed? ● Solution ● We add a “wrapper” in the Makefile ● After building the android “userspace” build ● Bootloader ● Kernel ● Copy kernel modules to out/target/product ● Extra boot parameter: ● androidboot.console=ttyO2 ● init=/init
  • 13. ELCE 2012 – Porting Android ICS Lessons Learned III: Powersupply ● Boot hangs on splash screen ● Have a look with logcat what's going on
  • 14. ELCE 2012 – Porting Android ICS Lessons Learned III: Powersupply E/BatteryService( 1008): Could not open /sys/class/power_supply (…) I/SystemServer( 1008): Battery Service W/dalvikvm( 1008): No implementation found for native Lcom/android/server/BatteryService;.native_update ()V W/dalvikvm( 1008): threadid=11: thread exiting with uncaught exception (group=0x409e11f8) I/Process ( 1008): Sending signal. PID: 1008 SIG: 9 E/AndroidRuntime( 1008): *** FATAL EXCEPTION IN SYSTEM PROCESS: android.server.ServerThread E/AndroidRuntime( 1008): java.lang.UnsatisfiedLinkError: native_update E/AndroidRuntime( 1008): at com.android.server.BatteryService.native_update(Native Method) E/AndroidRuntime( 1008): at com.android.server.BatteryService.update(BatteryService.java:233) E/AndroidRuntime( 1008): at com.android.server.BatteryService.<init>(BatteryService.java:148) E/AndroidRuntime( 1008): at com.android.server.ServerThread.run(SystemServer.java:196) I/Zygote ( 967): Exit zygote because system server (1008) has terminated E/installd( 913): eof E/installd( 913): failed to read size I/installd( 913): closing connection I/installd( 913): new connection I/ServiceManager( 903): service 'gfxinfo' died I/ServiceManager( 903): service 'activity' died I/ServiceManager( 903): service 'cpuinfo' died I/ServiceManager( 903): service 'sensorservice' died I/ServiceManager( 903): service 'meminfo' died I/ServiceManager( 903): service 'account' died I/ServiceManager( 903): service 'usagestats' died I/ServiceManager( 903): service 'permission' died I/ServiceManager( 903): service 'hardware' died I/ServiceManager( 903): service 'content' died (...)
  • 15. ELCE 2012 – Porting Android ICS Lessons Learned III: Powersupply
  • 16. ELCE 2012 – Porting Android ICS Lessons Learned III: Powersupply ● What has happened? ● When JNI is loaded, it registers the low level services (e.g. BatteryService) ● read values from sysfs ● BatteryService JNI registers function native_update at BatteryService.java ● But... ● BatteryService JNI interface doesn't find “/sys/class/power_supply” ● Returns error, which is ignored by JNI_OnLoad ● SystemServer thread creates BatteryService when executed ● BatteryService tries to update values invoking native_update ● No JNI interface registered – SystemServer dies...
  • 17. ELCE 2012 – Porting Android ICS Lessons Learned III: Powersupply ● Solution ● No working battery monitor in our system → No power supply class in kernel ● Adding the power supply class ● Shows battery empty warning in status bar ● Add the “test power driver” ● Shows Battery at 50% charging fixed ● Has influence on the behaviour of the Power Manager
  • 18. ELCE 2012 – Porting Android ICS Lessons Learned IV: Button Integration ● Can be found in frameworks/base/services/input: ● Android scans /dev/input folder in a loop ● Polls for events using epoll ● Identifies touchscreens, joysticks, mice, keyboards automatically ● Key Layout File (/system/usr/keylayout) maps raw input key to internal Android key representation ● Key Char Map File (/system/usr/keychars) describes action for internal Android key
  • 19. ELCE 2012 – Porting Android ICS Lessons Learned IV: Button Integration ● Our case ● Just one button, no external keyboard ● Two alternatives: ● Define own Key Layout/Key Char Map files ● Configure key code in kernel appropriately ● Beware Key Layout File uses numeric number of key code ● Not all values in Key Layout have a define in include/linux/input.h
  • 20. ELCE 2012 – Porting Android ICS Lessons Learned V: Touchscreen calibration ● Detection and input analogous to button integration ● Driver sends X-Y-coordinates ● Callibrate the touchscreen ● We have to reach all parts of the screen easily ● Turn on show touches in Settings/Developer options ● Adjust max and min values of your touchscreen in the plattform data
  • 21. ELCE 2012 – Porting Android ICS Lessons Learned VI: Wi-Fi ● Example of complexity of Android source code ● Different libraries and services ● 5 different folders with userspace code ● Uses wpa_supplicant to connect to a protected WLAN ● Enhanced with Android specific commands ● START, STOP, SCAN-ACTIVE, SCAN-PASSIVE, RSSI, LINKSPEED, …
  • 22. ELCE 2012 – Porting Android ICS Lessons Learned VI: Wi-Fi
  • 23. ELCE 2012 – Porting Android ICS Lessons Learned VI: Wi-Fi ● Integration ● Legacy implementation reads wpa supplicant config file ● /data/misc/wifi/wpa_supplicant.conf → product specific ● /system/etc/wifi/wpa_supplicant.conf → template ● Kernel and firmware module ● In BoardConfig.mk define: ● WIFI_DRIVER_MODULE_PATH ● WIFI_DRIVER_MODULE_NAME ● WIFI_FIRMWARE_LOADER ● Hardware legacy layer in charge of loading/unloading kernel module and firmware; starts/stops wpa_supplicant ● Start wpa_supplicant and dhcp for wlan ● service wpa_supplicant /system/bin/wpa_supplicant -Dwext -iwlan0 ● service dhcpcd_wlan0 /system/bin/dhcpcd -ABKL
  • 24. ELCE 2012 – Porting Android ICS Lessons Learned VII: Audio ● Audio player is stagefright ● AudioFlinger interfaces hardware abstraction ● Uses struct audio_hw_device in hardware/libhardware/include ● audio.primary.<device_name> ● Encapsulates the hardware - custom implementation
  • 25. ELCE 2012 – Porting Android ICS Lessons Learned VIII: Hardware Acceleration ● Two possibilities ● Integrate mulitmedia framework supporting HW acceleration ✔ Has bindings for HW accelerator ✔ Might have more codecs then stagefright ✗ Maintenace might be costly ● Integrate HW acceleration support in existing Android multimedia framework ✔ Should be easy to maintain ✗ Need to create bindings for the HW accelerator
  • 26. ELCE 2012 – Porting Android ICS Lessons Learned VIII: Hardware Acceleration libmediaplayerservice:
  • 27. ELCE 2012 – Porting Android ICS Lessons Learned VIII: Hardware Acceleration ● Add own multimedia framework ● Register your framework as MediaPlayerInterface ● Create player instance in MediaPlayerService ● Implement new MetadataRetriever in MetadataRetrieverClient ● Implement wrapper ● Audio sink using AudioTrack ● Video sink using Surface
  • 28. ELCE 2012 – Porting Android ICS Lessons Learned VIII: Hardware Acceleration libsurfaceflinger:
  • 29. ELCE 2012 – Porting Android ICS Lessons Learned VI: Hardware Acceleration libstagefright:
  • 30. Porting Android ICS to a custom board A war story matthias.bgg@gmail.com