Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Making a Headless Android Device (Oslo Embedded Meetup 2018)

258 views

Published on

This talk explores the options when trying to bing up a device using an Android Board Support Package (BSP) or AOSP. In particular the options when you don't want to ship a traditional Android device or you have an existing Embedded Linux code base, but all you have available is Android. Headless can mean both be an Android without Java and a device without a display, both are discussed.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Making a Headless Android Device (Oslo Embedded Meetup 2018)

  1. 1. Making a Headless-Android Device Lessons Learned Oslo Embedded S/W Meetup, 2018 Patricia Aas & Johan Herland Pictures from pixabay.com (CC0)
  2. 2. Patricia Aas Vivaldi Technologies Cisco Systems Opera Software Twitter: @pati_gallardo Johan Herland Cisco Systems Opera Software Git Dev Community Twitter: @jherland
  3. 3. Outline - Why? - Architecture - Devices - Composition - Gpu Access - Lessons Learned
  4. 4. So… What do we know?
  5. 5. And why should you care?
  6. 6. The Problem Full Android Using Google’s AOSP, or a more customized Android Board Support Package (BSP) from a chip vendor. Embedded Linux No Android parts. Typically based on glibc, busybox, etc.
  7. 7. Unchartered Territory
  8. 8. Important questions Do you have: - Existing codebase? - Upstream BSP? - 3rd party dependencies? What kind of device: - Display? - Single or multiple apps? - Custom H/W?
  9. 9. Architecture : Deep Dive
  10. 10. Full Stack Android - Java App ecosystem - Graphics infrastructure - Supported by modern SoCs - Linux kernel w/Android features - Libc : Bionic Embedded Linux - Stable/well-known components - “Mix-and-match” - C/C++ or web apps - “Vanilla” kernel (or not...) - Libc : GNU glibc
  11. 11. Bionic - Developed specifically for Android - Focus: small size and speed - Compatibility: - Almost all of C11 and POSIX - Some GNU/BSD extensions - C++ : “It’s complicated” GNU glibc - Used “everywhere” - Focus: - Application support - Standards compliance - Completeness - Compatibility: Yes ☺
  12. 12. Platform Architecture - Embedded Linux Linux kernel Device drivers GNU glibc Libraries (SSL, SQLite, etc.) System utils (systemd, busybox)H/W abstraction (OpenGL, alsalib, etc.) Compositor (XServer, Wayland) Application framework (Qt, GTK) Apps Services/daemons (sshd, httpd) Your application
  13. 13. Platform Architecture - Full Stack Android Linux kernel (w/Android features: binder, wakelocks, etc.) Device drivers Bionic libc H/W Abstraction Layer (HWC, etc.) Libraries (SSL, SQLite, etc.) Services (SurfaceFlinger, AudioFlinger, etc.) Android runtime (ART; previously Dalvik JVM) Android Application Framework Android Apps System utils (init, ADB, toolbox) Your application
  14. 14. Platform Architecture - Headless Android based on Bionic Linux kernel (w/Android features: binder, wakelocks, etc.) Device drivers Bionic libc H/W Abstraction Layer (HWC, etc.) Libraries (SSL, SQLite, etc.) Services? (SurfaceFlinger, etc.) System utils (init, ADB, toolbox) Your application
  15. 15. Platform Architecture - Headless Android based on glibc Linux kernel (w/Android features: binder, wakelocks, etc.) Device drivers Bionic libc H/W Abstraction Layer (HWC, etc.) Libraries (SSL, SQLite, etc.) Services? (SurfaceFlinger, etc.) System utils (systemd, busybox) GNU glibc Hybris? Your application
  16. 16. Embedded LinuxFull stack Android Headless GlibcHeadless Bionic
  17. 17. Devices
  18. 18. Display Composition - No display - Single full-screen app - Multiple apps
  19. 19. No display Multi app Single app Embedded LinuxFull stack Android Headless GlibcHeadless Bionic
  20. 20. No Display Traditional Embedded - Appliance / IOT No Graphics Integration No Composition
  21. 21. No display Multi app Single app Embedded LinuxFull stack Android Headless GlibcHeadless Bionic Java app/service C/C++ app/service C/C++ app/daemon C/C++ app/daemon No bionic dependencies
  22. 22. No display Multi app Single app Embedded LinuxFull stack Android Headless GlibcHeadless Bionic Java app/service C/C++ app/service C/C++ app/daemon C/C++ app/daemon OpenWRT et al
  23. 23. Single full-screen app Single-purpose device : - Digital signage - Kiosk-style device - Videoconferencing endpoint Needs Graphics Integration No Complex Composition
  24. 24. No display Multi app Single app Embedded LinuxFull stack Android Headless GlibcHeadless Bionic Java app/service One “home screen” app EGL Window/Framebuffer C/C++ app/service C/C++ app/daemon C/C++ app/daemon SurfaceFlinger/HWC SurfaceFlinger/HWC via e.g. Hybris Needs glibc/bionic bridge for graphics integration
  25. 25. No display Multi app Single app Embedded LinuxFull stack Android Headless GlibcHeadless Bionic Java app/service One “home screen” app EGL Window/Framebuffer C/C++ app/service C/C++ app/daemon C/C++ app/daemon SurfaceFlinger/HWC SurfaceFlinger/HWC via e.g. Hybris Cisco Webex Board Cisco Webex Room Series Cisco TelePresence MX/SX Tesla Car OS? OpenWRT et al
  26. 26. Multiple Apps Consumer Device : - Phone - Tablet - Smart TV Needs App Store (e.g. Google Play) Needs Complex Composition
  27. 27. No display Multi app Single app Embedded LinuxFull stack Android Headless GlibcHeadless Bionic Java app/service One “home screen” app App Store (Google’s Play Store if CDD-compliant) Multiple apps composited by XServer/Wayland EGL Window/Framebuffer C/C++ app/service C/C++ app/daemon C/C++ app/daemon Multiple apps composited by SurfaceFlinger/HWC via e.g. Hybris Multiple apps composited by SurfaceFlinger/HWC SurfaceFlinger/HWC SurfaceFlinger/HWC via e.g. Hybris Needs glibc/bionic bridge Needs complex composition
  28. 28. No display Multi app Single app Embedded LinuxFull stack Android Headless GlibcHeadless Bionic Java app/service One “home screen” app App Store (Google’s Play Store if CDD-compliant) Multiple apps composited by XServer/Wayland EGL Window/Framebuffer C/C++ app/service C/C++ app/daemon C/C++ app/daemon Multiple apps composited by SurfaceFlinger/HWC via e.g. Hybris Multiple apps composited by SurfaceFlinger/HWC SurfaceFlinger/HWC SurfaceFlinger/HWC via e.g. Hybris Kindle Fire Boot2Qt (1st version) Sailfish (Jolla), Ubuntu Touch Cisco Webex Board Cisco Webex Room Series Samsung Tizen, LG webOS Cisco TelePresence MX/SX Tesla Car OS? OpenWRT et al
  29. 29. Composition
  30. 30. Composition Need to get pixels on screen - Compose just one window with OpenGL - Compose multiple windows using external composer / Hardware Composer
  31. 31. The Hardware Composer Standardized Android porting API for rendering to the screen. Takes a set of surfaces and composes them to the full frame for the screen.
  32. 32. LibHybris : Runtime Linker Magic
  33. 33. What is LibHybris? Dynamically loads and links bionic libc and bionic linked libs into a glibc process Gives access to the bionic libs in a glibc process Creator : Carsten Munk
  34. 34. Linux kernel (w/Android features: binder, wakelocks, etc.) Headless Glibc Android using LibHybris Your Compositor / GUI App LibHybris Bionic SurfaceFlinger / HWC OpenGL shared lib GUI lib GNU glibc Other libs
  35. 35. A bionic GPU process? Pipe GPU commands over a local pipe to a bionic process that does the composition.
  36. 36. Linux kernel (w/Android features: binder, wakelocks, etc.) Headless Glibc Android using a Bionic GPU Process + IPC GUI AppCompositor GUI lib GNU glibc IPC-GL client SurfaceFlinger / HWC OpenGL shared lib Bionic IPC Other libs IPC-GL server
  37. 37. Chromium GPU Process Architecture
  38. 38. Communication Architecture Renderer Gpu Process Browser Renderer IPC Channels Shared Memory Gpu Memory BuffersCommand Buffers
  39. 39. Client Renderer / Browser - Write commands to shared memory - Update ‘put’ pointer - Signal GPU process @pati_gallardo
  40. 40. Server GPU Process - Read commands from shared memory - Validate command and arguments - Make actual call@pati_gallardo
  41. 41. Gpu Process Command Buffer IPC Channel Command Stream Ordering Barrier Unverified Sync Token Wait Sync Token Wait Sync TokenCommandCommand Command Command Command Command CommandVerified Sync TokenBrowser Renderer Renderer Command Command CommandCommand CommandCommand
  42. 42. Not Exactly Cut A nd Paste @pati_gallardo
  43. 43. Lessons Learned CC image courtesy of penjelly on Flickr
  44. 44. Existing Codebase Porting to Java? Porting from glibc to Bionic? Rewrite to Android APIs? What about other APIs you use? - Do they exist in Android?
  45. 45. 3rd-party dependencies? Port to Bionic? Really !? Will upstream accept the port? Remove deps if possible! What about alternative deps? Push towards glibc platform!
  46. 46. Bringup & Maintenance Minimize custom hardware! Decouple customizations from upstream BSP/platform Keep changes out of the BSP - Above the Android APIs - Or below user space (kernel drivers, device tree)
  47. 47. Maintaining Patches
  48. 48. Avoid patches when you can! Minimize changes to the BSP itself Decouple your changes from the guts of Android
  49. 49. Structure your patches! Patches across many different repos: - Common scheme for maintenance - Enumerate your current patchset - Integrating new upstream release: - Remove and Refresh
  50. 50. Big Ball of Mud
  51. 51. Plan for updates! AOSP / BSP : Every year 3rd-party dependencies : Varies Strict security policies (e.g. OpenSSL) Chromium : Every month Chip vendor : Hopefully never!
  52. 52. Too many patches! - Can’t update Android version - Can’t update 3rd-party libs - Security pipeline clogged - Project stalled!
  53. 53. Wrap it up!
  54. 54. No display Multi app Single app Embedded LinuxFull stack Android Headless GlibcHeadless Bionic Java app/service One “home screen” app App Store (Google’s Play Store if CDD-compliant) Multiple apps composited by XServer/Wayland EGL Window/Framebuffer C/C++ app/service C/C++ app/daemon C/C++ app/daemon Multiple apps composited by SurfaceFlinger/HWC via e.g. Hybris Multiple apps composited by SurfaceFlinger/HWC SurfaceFlinger/HWC SurfaceFlinger/HWC via e.g. Hybris Your code + 3rd-party dependencies built against Bionic Your code + 3rd-party dependencies built against glibc Bionic / Glibc bridge needed for graphics & composition
  55. 55. No display Multi app Single app Embedded LinuxFull stack Android Headless GlibcHeadless Bionic Java app/service One “home screen” app App Store (Google’s Play Store if CDD-compliant) Multiple apps composited by XServer/Wayland EGL Window/Framebuffer C/C++ app/service C/C++ app/daemon C/C++ app/daemon Multiple apps composited by SurfaceFlinger/HWC via e.g. Hybris Multiple apps composited by SurfaceFlinger/HWC SurfaceFlinger/HWC SurfaceFlinger/HWC via e.g. Hybris
  56. 56. Plan for maintenance
  57. 57. Questions?
  58. 58. Feedback, please Swag!

×