SlideShare una empresa de Scribd logo
1 de 58
Descargar para leer sin conexión
Android Hacks,
Variants, Tricks and
     Resources
Embedded Systems Conference SV 2012

         Karim Yaghmour
         @karimyaghmour


                             1
These slides are made available to you under a Creative Commons          Delivered and/or customized by
Share-Alike 3.0 license. The full terms of this license are here:
https://creativecommons.org/licenses/by-sa/3.0/


Attribution requirements and misc., PLEASE READ:
●   This slide must remain as-is in this specific location (slide #2),
    everything else you are free to change; including the logo :-)
●   Use of figures in other documents must feature the below
    “Originals at” URL immediately under that figure and the below
    copyright notice where appropriate.
●   You are free to fill in the “Delivered and/or customized by” space
    on the right as you see fit.
●   You are FORBIDEN from using the default “About” slide as-is or
    any of its contents.


(C) Copyright 2012, Opersys inc.
These slides created by: Karim Yaghmour
Originals at: www.opersys.com/community/docs
                                                                                  2
About
●   Author of:




●   Introduced Linux Trace Toolkit in 1999
●   Originated Adeos and relayfs (kernel/relay.c)
●   Training, Custom Dev, Consulting, ...
                                              3
Agenda
●   AOSP's limitations
●   Tearing AOSP apart
●   Forks
●   Ports
●   Mods
●   Melding with “Classic” Linux Stack
●   Headless Android

                                         4
AOSP's limits
●   Rigid
●   Closed dev model
●   Fits Google's prerogatives
●   Excludes a lot of stuff
●   ... IOW, doesn't always fit what you need




                                          5
Tearing AOSP apart
●   Forks
●   Ports
●   Mods
●   Melds




                                 6
Forks
●   Cyanogenmod
●   Replicant
●   MIUI
●   Cyborgstack




                          7
Cyanogenmod
●   After-market handset firmware
●   Requires rooted phone
●   http://www.cyanogenmod.com
●   Advertized features:
    ●   Lockscreen Gestures
    ●   Phone Goggles
    ●   OpenVPN
    ●   Incognito mode
    ●   Themes support
    ●   DSP Equalizer
                                    8
9
●   More interestingly:
    ●   http://wiki.cyanogenmod.com/
    ●   https://github.com/CyanogenMod
    ●   Includes Busybox
    ●   Custom Launcher (ADWLauncher)
    ●   Lots of tiny tweaks and mods ... worth doing a “diff”




                                                 10
Replicant
●   Android distro that is 100% Free Software
●   http://replicant.us/
●   Includes FDroid free software app store




                                        11
MIUI
●   Closed-source fork with slick UI enhancements
●   Many translations
●   http://en.miui.com/
●   Advertized features:
    ●   Home screen
    ●   Dialer
    ●   SMS
    ●   Contacts
    ●   Themes
    ●   Camera
    ●   Gallery
    ●   Net disk, File manager, Traffic monitor, Backup, Notes, ...
                                                                 12
13
Cyborgstack
A truly open, no holds barred Android-based distro




              www.cyborgstack.org


   “Boldly go where no droid has gone before”

                                        14
What the AOSP does




                     15
Where Cyborgstack is going




                        16
Goals

●   Truly Open development community
●   Nothing is off limits
    ●   Accept things which will likely never make it to AOSP
●   Configurability
●   Customizability
●   Mission-critical
●   Ability to provide high security
●   Vendor/Platform Independent

                                                    17
What's there?

●   glibc-based rootfs add-ons
●   LTTng
●   “Headless Android”
●   BusyBox




                                  18
Ports
●   RIM Playbook
●   BlueStacks
●   Alien Dalvik




                           19
RIM Playbook




               20
BlueStacks




             21
Alien Dalvik (Myriad Group)




                       22
Mods
●   XDA Developers
●   ...




                            23
Melding with “Classic” Linux stack
1. Rationale
2. Roadblocks
3. Where do I start?
4. Coexistence Approaches
5. Been there done that
6. Unresolved / Uncharted
7. Tools
8. Embedded Linux Workspace
9. Basic Root Filesystem Structure
10. Libraries
11. Main System Applications
12. Demos
                                     24
1. Rationale
“Android took GNU out the back door, shot him in the head, and ran away with
the penguin” -- Surely from Tarantino's next flick


●   A ton of mature user-space packages available
    ●   Linux has been around for 20 years
    ●   Linux's user-space has been developed in the open
●   A ton of “Linux”-centric stacks have been developed through the years
    ●   “Porting” to Android not always possible/desirable/realistic
●   Android doesn't provide everything
    ●   Touch-based, consumer-oriented
    ●   Linux is very strong on backend/server side
●   Android exhibits symptoms of “my way or the highway” design
●   A whole GNU world
    ●   glibc vs. Bionic
                                                                       25
2. Roadblocks
●   Filesystem
    ●   Android is non-FHS-compliant
●   C library
    ●   Bionic vs. glibc
●   Interconnect fabric
    ●   Intents vs. DBUS
●   IPC
    ●   Binder vs. Sockets and other std Unix IPC
●   Display management
    ●   SurfaceFlinger vs. X
●   I/O
    ●   Framebuffer, keyboard, mouse, disk, ...
                                                    26
3. Where do I start?
●   Android-side:
    ●   AOSP
●   “Linux”-side:
    ●   Traditional distro
        –   Ubuntu, Fedora, Debian, Gentoo, ...
    ●   Embedded distro
        –   Yocto, Buildroot, LTIB, ...
    ●   Build Your Own
    ●   Cherry-picking
                                                  27
4. Coexistence Approaches
●   Single filesystem
    ●   Build system integration
    ●   Build-time aggregation
    ●   Image repackaging
●   chroot jails
    ●   Have a look at AlwaysInnovating Gregoire Gentil's ELC presentation
    ●   Patching to lots of pieces of the OS
    ●   Use of one FB for each OS or chvt
●   Virtualization / Paravirtualization
    ●   QEMU
    ●   XEN?

                                                            28
29
5. Been there done that
●   BusyBox in CyanogenMod
●   Gstreamer vs. Stagefright
●   Don't know how they do it:
    ●     Alien Dalvik: Android on Meego
●   ...




                                           30
6. Unresolved / Uncharted
●   Binder from glibc
●   Intent <-> DBUS bridge
●   Running Android apps in X
●   Running X apps in Android
      “The easier thing to do, which would work on just about all Android phones
      without having to modify the system software at all, would be to port an X
      server to the NDK, using a SurfaceFlinger Surface as its root window.
      You could do a generic "X11WrapperApp" that has you XSurfaceFlinger
      bundled and launches whatever X based app you want, and have it all play
      nice together.
      A bit more work would be to just do an implementation of xlib that sits on top of
      a native Android window (opengl ES 2 if you like) without any server in the
      middle, and again bundle this and the X based app of your choice and you
      have something that is a first class app on the phone without any need for
      modifying the OS.”
                                                                     31
7. Tools
●   GNU cross-development toolchain:
    ●   gcc - compiler
    ●   as - assembler
    ●   ld - linker
    ●   gdb/gdbserver - debugger
    ●   etc.
●   C library: uClibc, eglibc or glibc


                                         32
8. Embedded Linux Workspace
●   Need to organize the components used during
    cross-platform development. Workspace layout:
      bootldr:       target bootloader (s)
      build-tools:   toolchain build packages and sources
      debug:         debugging tools
      doc:           project documentation
      images:        binary images ready to be used on target
      kernel:        sources and build directories for target kernels
      project:       your own custom code for the target
      rootfs:        root filesystem as seen on the target
      sysapps:       sources for target's system applications
      tmp:           temporary data and experiments
      tools:         toolchain and all other tools required to build
                     software for the target.

                                                           33
8.1. Workspace env. vars. script
●   Complete workspace script (devex)
    export PROJECT=emblinux
    export PRJROOT=/home/karim/${PROJECT}
    export TARGET=arm-none-linux-gnueabi
    export PATH=${PATH}:[CODESOURCERY_DIR]/bin
    cd $PRJROOT
●   To use this script:
     $ .⌴ devex
●   Possible values for $TARGET:
     ●   ARM:    arm-linux, arm-unknown-linux-gnueabi
     ●   MIPS:   mips-linux, mipsel-unknown-linux-gnu
     ●   I386:   i386-linux, i586-geode-linux-uclibc
                                                 34
9. Basic root filesystem structure
●   Unix FS structured for multi-user systems
●   Some directories not necessary for embedded
●   Filesystem Hierarchy Standard (FHS):
    ●   /bin    =>   Essential user binaries
    ●   /boot   =>   Bootloader and kernel images
    ●   /dev    =>   Device files
    ●   /etc    =>   System configuration
    ●   /home   =>   User home directories
    ●   /lib    =>   Essential shared libs and kernel modules
    ●   /mnt    =>   Temporary mount point
    ●   /opt    =>   Add-on software packages
    ●   /sbin   =>   Essential system binaries
    ●   /tmp    =>   Temporary files
    ●   /usr    =>   Secondary hierarchy (mostly user apps)
    ●   /var    =>   Variable data generated by daemons
                                                     35
●   Non-essential multi-user dirs:
    ●   /home, /mnt, /opt, /root
●   Depends on bootloader:
    ●   /boot
●   Traditionally “essential”:
    ●   /bin, /dev, /etc, /lib, /proc, /sbin, /usr, /tmp, /var
●   Careful with “/etc”, Android needs it to point to
    “/system/etc” for Dbus config ... Just hack it.
●   Contain their own hierarchy:
    ●   /usr, /var                                     36
●   What are all these binaries directories for?
    ●   /bin     =>   Essential binaries for user and admin
    ●   /sbin    =>   Essential binaries for admin
    ●   /usr/bin =>   Non-essential user and admin binaries
    ●   /usr/sbin=>   Non-essential admin binaries
●   What are all those libraries directories for?
    ●   /lib     =>   Essential system libraries
    ●   /usr/lib =>   Non-essential libraries
●   The kernel does not force FS layout. Layout is
    “universally” agree upon (i.e. FHS.)


                                                   37
●   To start working on rootfs:
    $ cd ${PRJROOT}/rootfs
●   Create core rootfs directories:
    $ mkdir bin lib sbin usr var
●   Create the /usr hierarchy:
    $ mkdir usr/{bin,lib,sbin}
●   Create the /var hierarchy:
    $ mkdir var/{lib,lock,log,run,tmp}
    $ chmod 1777 var/tmp




                                         38
10. Libraries
1.glibc
2.uClibc




                           39
10.1. glibc
●   glibc components:
    ●   Actual shared libraries:
        –   Format: libLIB_NAME-GLIBC_VER.so
        –   Examples: libm-2.3.2.so, libc-2.3.2.so
    ●   Major revision version symbolic links:
        –   Format: libLIB_NAME.so.MAJOR_REV_VER
        –   Examples: libdl.so.2, libc.so.6
    ●   Version-independent symbolic links to the major
        revision version symbolic links:
        –   Format: libLIB_NAME.so
        –   Examples: libdl.so, libm.so
    ●   Static library archives:
        –   Format: libLIB_NAME.a
        –   Examples: libdl.a, libm.a
                                                     40
●   For target, need:
    ●   The actual shared libs
    ●   The major revision version symbolic links
●   Also need dynamic linker:
    ●   Actual linker: ld-GLIBC_VER.so
    ●   Symbolic link to linker:
        –   x86, ARM, SH, m68k   => ld-linux.so.MAJOR_REV_VER
        –   MIPS, PPC            => ld.so.MAJOR_REV_VER
●   Must determine exact library components required.
●   BELS table 6.2 contains complete list


                                                  41
●   Most important components:
    ●   ld     =>   the dynamic linker
    ●   libc   =>   the C library
    ●   libm =>     the math library
    ●   libdl =>    the shared objects manipulation library
●   Must determine exact dependencies of your
    applications.
●   Native ldd is not cross-platform-capable
●   Can use readelf or uclibc-ldd:
                                                 42
●   Copying all libraries:
    $ cp -d [CODESOURCERY_DIR]/arm-none-linux-gnueabi/libc/lib/* 
    > ${PRJROOT}/rootfs/lib

●   Stripping all target libraries for space efficiency:
    $ arm-none-linux-gnueabi-strip ${PRJROOT}/rootfs/lib/*.so*




                                                    43
10.2. uClibc
●   Same naming conventions as glibc
●   Implements most of the glibc components:
    ●   ld, libc, libcrypt, libdl, libm, libpthread, libresolv, libutil.
●   uClibc libraries can coexist with glibc libraries in
    target's /lib directory.
●   Copying all uClibc components:
    $ cd ${PREFIX}/uclibc/lib
    $ cp *-*.so ${PRJROOT}/rootfs/lib
    $ cp -d *.so.[*0-9] ${PRJROOT}/rootfs/lib
●   No need to strip uClibc libraries, they are stripped
    by the uClibc build script

                                                        44
11. Main system applications
●   Unix systems rely on a common set of commands
●   Standard distros have one binary per command
●   May compile each relevant command one-by-one
    or use packages that provide many commands in
    a single binary:
    1.Busybox
    2.Distro




                                       45
11.1. BusyBox
●   Main package used in embedded Linux to provide
    core set of Unix commands: busybox.net
     [, [[, acpid, add-shell, addgroup, adduser, adjtimex, arp, arping, ash, awk, base64, basename, beep, blkid, blockdev,
     bootchartd, brctl, bunzip2, bzcat, bzip2, cal, cat, catv, chat, chattr, chgrp, chmod, chown, chpasswd, chpst, chroot, chrt,
     chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab, cryptpw, cttyhack, cut, date, dc, dd, deallocvt, delgroup, deluser,
     depmod, devmem, df, dhcprelay, diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, du, dumpkmap, dumpleases,
     echo, ed, egrep, eject, env, envdir, envuidgid, ether-wake, expand, expr, fakeidentd, false, fbset, fbsplash, fdflush, fdformat,
     fdisk, fgconsole, fgrep, find, findfs, flock, fold, free, freeramdisk, fsck, fsck.minix, fsync, ftpd, ftpget, ftpput, fuser, getopt,
     getty, grep, gunzip, gzip, halt, hd, hdparm, head, hexdump, hostid, hostname, httpd, hush, hwclock, id, ifconfig, ifdown,
     ifenslave, ifplugd, ifup, inetd, init, insmod, install, ionice, iostat, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule, iptunnel,
     kbd_mode, kill, killall, killall5, klogd, last, length, less, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger, login,
     logname, logread, losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lspci, lsusb, lzcat, lzma, lzop, lzopcat, makedevs, makemime, man,
     md5sum, mdev, mesg, microcom, mkdir, mkdosfs, mke2fs, mkfifo, mkfs.ext2, mkfs.minix, mkfs.vfat, mknod, mkpasswd,
     mkswap, mktemp, modinfo, modprobe, more, mount, mountpoint, mpstat, mt, mv, nameif, nbd-client, nc, netstat, nice,
     nmeter, nohup, nslookup, ntpd, od, openvt, passwd, patch, pgrep, pidof, ping, ping6, pipe_progress, pivot_root, pkill, pmap,
     popmaildir, poweroff, powertop, printenv, printf, ps, pscan, pwd, raidautorun, rdate, rdev, readahead, readlink, readprofile,
     realpath, reboot, reformime, remove-shell, renice, reset, resize, rev, rm, rmdir, rmmod, route, rpm, rpm2cpio, rtcwake, run-
     parts, runlevel, runsv, runsvdir, rx, script, scriptreplay, sed, sendmail, seq, setarch, setconsole, setfont, setkeycodes,
     setlogcons, setsid, setuidgid, sh, sha1sum, sha256sum, sha512sum, showkey, slattach, sleep, smemcap, softlimit, sort,
     split, start-stop-daemon, stat, strings, stty, su, sulogin, sum, sv, svlogd, swapoff, swapon, switch_root, sync, sysctl, syslogd,
     tac, tail, tar, tcpsvd, tee, telnet, telnetd, test, tftp, tftpd, time, timeout, top, touch, tr, traceroute, traceroute6, true, tty, ttysize,
     tunctl, udhcpc, udhcpd, udpsvd, umount, uname, unexpand, uniq, unix2dos, unlzma, unlzop, unxz, unzip, uptime, usleep,
     uudecode, uuencode, vconfig, vi, vlock, volname, wall, watch, watchdog, wc, wget, which, who, whoami, xargs, xz, xzcat,
     yes, zcat, zcip

                                                                                                           46
●   Download BusyBox (1.18.3) to your $
    {PRJROOT}/sysapps directory and extract it there.
●   Move to the directory for the rest of the setup:
    $ cd ${PRJROOT}/sysapps/busybox-1.18.3

●   Configuration of BusyBox's options:
    $ make menuconfig




                                             47
48
●   “Busybox Settings”:
    ●   “Build Options” -> Cross-compiler prefix:
               ${TARGET}-
    ●   “Installation Options” -> Installation prefix:
               ${PRJROOT}/rootfs
●   Build:
    $ make

●   Install:
    $ make install

                                                    49
12. Demos
●   All:
    ●   AOSP
    ●   BYO glibc-based rootfs
●   Demo 1: BusyBox
●   Demo 2: Client-Server app talking through socket
    ●   glibc client
    ●   bionic server
●   Demo 3: Surprise!

                                        50
12.1. Demo 1 - BusyBox
●   Configure, build and “install” BusyBox
●   Get it copied into final RAM disk image
●   Modify AOSP to:
    ●   Make sure /lib/* is executable
    ●   Path start with “/bin”
    ●   adb shell is BusyBox, not Toolbox




                                            51
12.2. Demo 2 – Client/Server




                        52
12.3. Demo 3 – LTTng
●   Patch kernel
●   Cross-build ltt-ctl
●   Modify AOSP to log to LTTng




                                  53
Headless Android




               +                    =

“And then GNU came back for revenge ...”
-- Tarantino's sequel
                                           54
Android's display architecture




                         55
How to decapitate Android
●   Disable:
    ●   SurfaceFlinger
    ●   WindowManager
    ●   WallpaperService
    ●   InputMethodManager
    ●   SystemUI
●   Don't let SurfaceFlinger Client try to open binder to SurfaceFlinger
●   Feed bogus values back from SurfaceFlinger Client
●   Disable qemud (emulator artefact)
●   Tweak internals by disabling key calls:
    ●   In ActivityStack.java:
        –   startHomeActivityLocked()
        –   setAppStartingWindow()
    ●   wm.detectSafeMode()
    ●   wm.systemReady()
    ●   wm.reclaimSuraceMemoryLocked()

                                                                           56
What's in there?
●   Most everything Android gives you:
    ●   No UX
    ●   Fully-integrated Eclipse IDE
    ●   SDK/NDK
    ●   ADB
    ●   Fastboot
    ●   Published, well-known, and very rich APIs
    ●   A large and growing developer community
    ●   And still we can use the usual suspects:
        –   GNU toolchain, BusyBox, u- boot, glibc, ...
●   Caveat -- “Activity” no longer works
●   You have:
    ●   Services
    ●   ContentProviders
    ●   BroadcastReceivers
                                                          57
Thank you ...

karim.yaghmour@opersys.com

     @karimyaghmour




                         58

Más contenido relacionado

La actualidad más candente

Working with the AOSP - Linaro Connect Asia 2013
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.
 
Leveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IVLeveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IV
Opersys inc.
 
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...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 

La actualidad más candente (20)

Headless Android at AnDevCon3
Headless Android at AnDevCon3Headless Android at AnDevCon3
Headless Android at AnDevCon3
 
Embedded Android Workshop at ELC Europe
Embedded Android Workshop at ELC EuropeEmbedded Android Workshop at ELC Europe
Embedded Android Workshop at ELC Europe
 
Leveraging Android's Linux Heritage
Leveraging Android's Linux HeritageLeveraging Android's Linux Heritage
Leveraging Android's Linux Heritage
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
 
Android jumpstart at ESC Boston 2011
Android jumpstart at ESC Boston 2011Android jumpstart at ESC Boston 2011
Android jumpstart at ESC Boston 2011
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UI
 
Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
 
Cyborgstack
CyborgstackCyborgstack
Cyborgstack
 
Leveraging Android's Linux Heritage at ELC-E 2011
Leveraging Android's Linux Heritage at ELC-E 2011Leveraging Android's Linux Heritage at ELC-E 2011
Leveraging Android's Linux Heritage at ELC-E 2011
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
 
Leveraging Android's Linux Heritage at Android Open 2011
Leveraging Android's Linux Heritage at Android Open 2011Leveraging Android's Linux Heritage at Android Open 2011
Leveraging Android's Linux Heritage at Android Open 2011
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
 
Leveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IVLeveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IV
 
Embedded Android Workshop at Android Open 2011
Embedded Android Workshop at Android Open 2011Embedded Android Workshop at Android Open 2011
Embedded Android Workshop at Android Open 2011
 
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...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things Internals
 

Destacado (6)

Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Customizing Android's UI
Customizing Android's UICustomizing Android's UI
Customizing Android's UI
 
Android Storage - Internal and External Storages
Android Storage - Internal and External StoragesAndroid Storage - Internal and External Storages
Android Storage - Internal and External Storages
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things Internals
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 

Similar a Android Hacks, Variants, Tricks and Resources ESC SV 2012

Leveraging Android's Linux Heritage at AnDevCon V
Leveraging Android's Linux Heritage at AnDevCon VLeveraging Android's Linux Heritage at AnDevCon V
Leveraging Android's Linux Heritage at AnDevCon V
Opersys inc.
 
Is Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon VIs Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon V
Opersys inc.
 
Leveraging Android's Linux Heritage at AnDevCon VI
Leveraging Android's Linux Heritage at AnDevCon VILeveraging Android's Linux Heritage at AnDevCon VI
Leveraging Android's Linux Heritage at AnDevCon VI
Opersys inc.
 
Is Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VIIs Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VI
Opersys inc.
 
Is Android the New Embedded Linux? at AnDevCon IV
Is Android the New Embedded Linux? at AnDevCon IVIs Android the New Embedded Linux? at AnDevCon IV
Is Android the New Embedded Linux? at AnDevCon IV
Opersys inc.
 
Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014
Opersys inc.
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 
Embedded Android Workshop at AnDevConII
Embedded Android Workshop at AnDevConIIEmbedded Android Workshop at AnDevConII
Embedded Android Workshop at AnDevConII
Opersys inc.
 

Similar a Android Hacks, Variants, Tricks and Resources ESC SV 2012 (20)

Leveraging Android's Linux Heritage at AnDevCon V
Leveraging Android's Linux Heritage at AnDevCon VLeveraging Android's Linux Heritage at AnDevCon V
Leveraging Android's Linux Heritage at AnDevCon V
 
Is Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon VIs Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon V
 
Leveraging Android's Linux Heritage at AnDevCon VI
Leveraging Android's Linux Heritage at AnDevCon VILeveraging Android's Linux Heritage at AnDevCon VI
Leveraging Android's Linux Heritage at AnDevCon VI
 
Is Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VIIs Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VI
 
Is Android the New Embedded Linux? at AnDevCon IV
Is Android the New Embedded Linux? at AnDevCon IVIs Android the New Embedded Linux? at AnDevCon IV
Is Android the New Embedded Linux? at AnDevCon IV
 
Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
Embedded Android Workshop / ELC 2013
Embedded Android Workshop / ELC 2013Embedded Android Workshop / ELC 2013
Embedded Android Workshop / ELC 2013
 
Linux as a gaming platform, ideology aside
Linux as a gaming platform, ideology asideLinux as a gaming platform, ideology aside
Linux as a gaming platform, ideology aside
 
Brillo / Weave Internals
Brillo / Weave InternalsBrillo / Weave Internals
Brillo / Weave Internals
 
Embedded Android Workshop at Embedded World Conference 2013
Embedded Android Workshop at Embedded World Conference 2013Embedded Android Workshop at Embedded World Conference 2013
Embedded Android Workshop at Embedded World Conference 2013
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
 
Hacking with Linux on Android devices #MOCPON
Hacking with Linux on Android devices    #MOCPONHacking with Linux on Android devices    #MOCPON
Hacking with Linux on Android devices #MOCPON
 
Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013
 
Headless Android (Wearable DevCon 2014)
Headless Android (Wearable DevCon 2014)Headless Android (Wearable DevCon 2014)
Headless Android (Wearable DevCon 2014)
 
Android on Intel Architecture: ROM Cooking Tutorial
Android on Intel Architecture: ROM Cooking TutorialAndroid on Intel Architecture: ROM Cooking Tutorial
Android on Intel Architecture: ROM Cooking Tutorial
 
BKK16-105 HALs for LITE
BKK16-105 HALs for LITEBKK16-105 HALs for LITE
BKK16-105 HALs for LITE
 
Is Android the New Embedded Embedded Linux? at Embedded World 2013
Is Android the New Embedded Embedded Linux? at Embedded World 2013Is Android the New Embedded Embedded Linux? at Embedded World 2013
Is Android the New Embedded Embedded Linux? at Embedded World 2013
 
Embedded Android Workshop at AnDevConII
Embedded Android Workshop at AnDevConIIEmbedded Android Workshop at AnDevConII
Embedded Android Workshop at AnDevConII
 
Embedded Android Workshop at Embedded Linux Conference Europe 2011
Embedded Android Workshop at Embedded Linux Conference Europe 2011Embedded Android Workshop at Embedded Linux Conference Europe 2011
Embedded Android Workshop at Embedded Linux Conference Europe 2011
 

Más de Opersys inc.

Más de Opersys inc. (20)

Android Automotive
Android AutomotiveAndroid Automotive
Android Automotive
 
Android 10 Internals Update
Android 10 Internals UpdateAndroid 10 Internals Update
Android 10 Internals Update
 
Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security Internals
 
Embedded Android Workshop with Pie
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with Pie
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HAL
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
 
Embedded Android Workshop with Oreo
Embedded Android Workshop with OreoEmbedded Android Workshop with Oreo
Embedded Android Workshop with Oreo
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
 
Android Things: Android for IoT
Android Things: Android for IoTAndroid Things: Android for IoT
Android Things: Android for IoT
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
 
Brillo / Weave Internals
Brillo / Weave InternalsBrillo / Weave Internals
Brillo / Weave Internals
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
 
Project Ara
Project AraProject Ara
Project Ara
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Brillo/Weave Internals
Brillo/Weave InternalsBrillo/Weave Internals
Brillo/Weave Internals
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Android Hacks, Variants, Tricks and Resources ESC SV 2012

  • 1. Android Hacks, Variants, Tricks and Resources Embedded Systems Conference SV 2012 Karim Yaghmour @karimyaghmour 1
  • 2. These slides are made available to you under a Creative Commons Delivered and/or customized by Share-Alike 3.0 license. The full terms of this license are here: https://creativecommons.org/licenses/by-sa/3.0/ Attribution requirements and misc., PLEASE READ: ● This slide must remain as-is in this specific location (slide #2), everything else you are free to change; including the logo :-) ● Use of figures in other documents must feature the below “Originals at” URL immediately under that figure and the below copyright notice where appropriate. ● You are free to fill in the “Delivered and/or customized by” space on the right as you see fit. ● You are FORBIDEN from using the default “About” slide as-is or any of its contents. (C) Copyright 2012, Opersys inc. These slides created by: Karim Yaghmour Originals at: www.opersys.com/community/docs 2
  • 3. About ● Author of: ● Introduced Linux Trace Toolkit in 1999 ● Originated Adeos and relayfs (kernel/relay.c) ● Training, Custom Dev, Consulting, ... 3
  • 4. Agenda ● AOSP's limitations ● Tearing AOSP apart ● Forks ● Ports ● Mods ● Melding with “Classic” Linux Stack ● Headless Android 4
  • 5. AOSP's limits ● Rigid ● Closed dev model ● Fits Google's prerogatives ● Excludes a lot of stuff ● ... IOW, doesn't always fit what you need 5
  • 6. Tearing AOSP apart ● Forks ● Ports ● Mods ● Melds 6
  • 7. Forks ● Cyanogenmod ● Replicant ● MIUI ● Cyborgstack 7
  • 8. Cyanogenmod ● After-market handset firmware ● Requires rooted phone ● http://www.cyanogenmod.com ● Advertized features: ● Lockscreen Gestures ● Phone Goggles ● OpenVPN ● Incognito mode ● Themes support ● DSP Equalizer 8
  • 9. 9
  • 10. More interestingly: ● http://wiki.cyanogenmod.com/ ● https://github.com/CyanogenMod ● Includes Busybox ● Custom Launcher (ADWLauncher) ● Lots of tiny tweaks and mods ... worth doing a “diff” 10
  • 11. Replicant ● Android distro that is 100% Free Software ● http://replicant.us/ ● Includes FDroid free software app store 11
  • 12. MIUI ● Closed-source fork with slick UI enhancements ● Many translations ● http://en.miui.com/ ● Advertized features: ● Home screen ● Dialer ● SMS ● Contacts ● Themes ● Camera ● Gallery ● Net disk, File manager, Traffic monitor, Backup, Notes, ... 12
  • 13. 13
  • 14. Cyborgstack A truly open, no holds barred Android-based distro www.cyborgstack.org “Boldly go where no droid has gone before” 14
  • 15. What the AOSP does 15
  • 17. Goals ● Truly Open development community ● Nothing is off limits ● Accept things which will likely never make it to AOSP ● Configurability ● Customizability ● Mission-critical ● Ability to provide high security ● Vendor/Platform Independent 17
  • 18. What's there? ● glibc-based rootfs add-ons ● LTTng ● “Headless Android” ● BusyBox 18
  • 19. Ports ● RIM Playbook ● BlueStacks ● Alien Dalvik 19
  • 22. Alien Dalvik (Myriad Group) 22
  • 23. Mods ● XDA Developers ● ... 23
  • 24. Melding with “Classic” Linux stack 1. Rationale 2. Roadblocks 3. Where do I start? 4. Coexistence Approaches 5. Been there done that 6. Unresolved / Uncharted 7. Tools 8. Embedded Linux Workspace 9. Basic Root Filesystem Structure 10. Libraries 11. Main System Applications 12. Demos 24
  • 25. 1. Rationale “Android took GNU out the back door, shot him in the head, and ran away with the penguin” -- Surely from Tarantino's next flick ● A ton of mature user-space packages available ● Linux has been around for 20 years ● Linux's user-space has been developed in the open ● A ton of “Linux”-centric stacks have been developed through the years ● “Porting” to Android not always possible/desirable/realistic ● Android doesn't provide everything ● Touch-based, consumer-oriented ● Linux is very strong on backend/server side ● Android exhibits symptoms of “my way or the highway” design ● A whole GNU world ● glibc vs. Bionic 25
  • 26. 2. Roadblocks ● Filesystem ● Android is non-FHS-compliant ● C library ● Bionic vs. glibc ● Interconnect fabric ● Intents vs. DBUS ● IPC ● Binder vs. Sockets and other std Unix IPC ● Display management ● SurfaceFlinger vs. X ● I/O ● Framebuffer, keyboard, mouse, disk, ... 26
  • 27. 3. Where do I start? ● Android-side: ● AOSP ● “Linux”-side: ● Traditional distro – Ubuntu, Fedora, Debian, Gentoo, ... ● Embedded distro – Yocto, Buildroot, LTIB, ... ● Build Your Own ● Cherry-picking 27
  • 28. 4. Coexistence Approaches ● Single filesystem ● Build system integration ● Build-time aggregation ● Image repackaging ● chroot jails ● Have a look at AlwaysInnovating Gregoire Gentil's ELC presentation ● Patching to lots of pieces of the OS ● Use of one FB for each OS or chvt ● Virtualization / Paravirtualization ● QEMU ● XEN? 28
  • 29. 29
  • 30. 5. Been there done that ● BusyBox in CyanogenMod ● Gstreamer vs. Stagefright ● Don't know how they do it: ● Alien Dalvik: Android on Meego ● ... 30
  • 31. 6. Unresolved / Uncharted ● Binder from glibc ● Intent <-> DBUS bridge ● Running Android apps in X ● Running X apps in Android “The easier thing to do, which would work on just about all Android phones without having to modify the system software at all, would be to port an X server to the NDK, using a SurfaceFlinger Surface as its root window. You could do a generic "X11WrapperApp" that has you XSurfaceFlinger bundled and launches whatever X based app you want, and have it all play nice together. A bit more work would be to just do an implementation of xlib that sits on top of a native Android window (opengl ES 2 if you like) without any server in the middle, and again bundle this and the X based app of your choice and you have something that is a first class app on the phone without any need for modifying the OS.” 31
  • 32. 7. Tools ● GNU cross-development toolchain: ● gcc - compiler ● as - assembler ● ld - linker ● gdb/gdbserver - debugger ● etc. ● C library: uClibc, eglibc or glibc 32
  • 33. 8. Embedded Linux Workspace ● Need to organize the components used during cross-platform development. Workspace layout: bootldr: target bootloader (s) build-tools: toolchain build packages and sources debug: debugging tools doc: project documentation images: binary images ready to be used on target kernel: sources and build directories for target kernels project: your own custom code for the target rootfs: root filesystem as seen on the target sysapps: sources for target's system applications tmp: temporary data and experiments tools: toolchain and all other tools required to build software for the target. 33
  • 34. 8.1. Workspace env. vars. script ● Complete workspace script (devex) export PROJECT=emblinux export PRJROOT=/home/karim/${PROJECT} export TARGET=arm-none-linux-gnueabi export PATH=${PATH}:[CODESOURCERY_DIR]/bin cd $PRJROOT ● To use this script: $ .⌴ devex ● Possible values for $TARGET: ● ARM: arm-linux, arm-unknown-linux-gnueabi ● MIPS: mips-linux, mipsel-unknown-linux-gnu ● I386: i386-linux, i586-geode-linux-uclibc 34
  • 35. 9. Basic root filesystem structure ● Unix FS structured for multi-user systems ● Some directories not necessary for embedded ● Filesystem Hierarchy Standard (FHS): ● /bin => Essential user binaries ● /boot => Bootloader and kernel images ● /dev => Device files ● /etc => System configuration ● /home => User home directories ● /lib => Essential shared libs and kernel modules ● /mnt => Temporary mount point ● /opt => Add-on software packages ● /sbin => Essential system binaries ● /tmp => Temporary files ● /usr => Secondary hierarchy (mostly user apps) ● /var => Variable data generated by daemons 35
  • 36. Non-essential multi-user dirs: ● /home, /mnt, /opt, /root ● Depends on bootloader: ● /boot ● Traditionally “essential”: ● /bin, /dev, /etc, /lib, /proc, /sbin, /usr, /tmp, /var ● Careful with “/etc”, Android needs it to point to “/system/etc” for Dbus config ... Just hack it. ● Contain their own hierarchy: ● /usr, /var 36
  • 37. What are all these binaries directories for? ● /bin => Essential binaries for user and admin ● /sbin => Essential binaries for admin ● /usr/bin => Non-essential user and admin binaries ● /usr/sbin=> Non-essential admin binaries ● What are all those libraries directories for? ● /lib => Essential system libraries ● /usr/lib => Non-essential libraries ● The kernel does not force FS layout. Layout is “universally” agree upon (i.e. FHS.) 37
  • 38. To start working on rootfs: $ cd ${PRJROOT}/rootfs ● Create core rootfs directories: $ mkdir bin lib sbin usr var ● Create the /usr hierarchy: $ mkdir usr/{bin,lib,sbin} ● Create the /var hierarchy: $ mkdir var/{lib,lock,log,run,tmp} $ chmod 1777 var/tmp 38
  • 40. 10.1. glibc ● glibc components: ● Actual shared libraries: – Format: libLIB_NAME-GLIBC_VER.so – Examples: libm-2.3.2.so, libc-2.3.2.so ● Major revision version symbolic links: – Format: libLIB_NAME.so.MAJOR_REV_VER – Examples: libdl.so.2, libc.so.6 ● Version-independent symbolic links to the major revision version symbolic links: – Format: libLIB_NAME.so – Examples: libdl.so, libm.so ● Static library archives: – Format: libLIB_NAME.a – Examples: libdl.a, libm.a 40
  • 41. For target, need: ● The actual shared libs ● The major revision version symbolic links ● Also need dynamic linker: ● Actual linker: ld-GLIBC_VER.so ● Symbolic link to linker: – x86, ARM, SH, m68k => ld-linux.so.MAJOR_REV_VER – MIPS, PPC => ld.so.MAJOR_REV_VER ● Must determine exact library components required. ● BELS table 6.2 contains complete list 41
  • 42. Most important components: ● ld => the dynamic linker ● libc => the C library ● libm => the math library ● libdl => the shared objects manipulation library ● Must determine exact dependencies of your applications. ● Native ldd is not cross-platform-capable ● Can use readelf or uclibc-ldd: 42
  • 43. Copying all libraries: $ cp -d [CODESOURCERY_DIR]/arm-none-linux-gnueabi/libc/lib/* > ${PRJROOT}/rootfs/lib ● Stripping all target libraries for space efficiency: $ arm-none-linux-gnueabi-strip ${PRJROOT}/rootfs/lib/*.so* 43
  • 44. 10.2. uClibc ● Same naming conventions as glibc ● Implements most of the glibc components: ● ld, libc, libcrypt, libdl, libm, libpthread, libresolv, libutil. ● uClibc libraries can coexist with glibc libraries in target's /lib directory. ● Copying all uClibc components: $ cd ${PREFIX}/uclibc/lib $ cp *-*.so ${PRJROOT}/rootfs/lib $ cp -d *.so.[*0-9] ${PRJROOT}/rootfs/lib ● No need to strip uClibc libraries, they are stripped by the uClibc build script 44
  • 45. 11. Main system applications ● Unix systems rely on a common set of commands ● Standard distros have one binary per command ● May compile each relevant command one-by-one or use packages that provide many commands in a single binary: 1.Busybox 2.Distro 45
  • 46. 11.1. BusyBox ● Main package used in embedded Linux to provide core set of Unix commands: busybox.net [, [[, acpid, add-shell, addgroup, adduser, adjtimex, arp, arping, ash, awk, base64, basename, beep, blkid, blockdev, bootchartd, brctl, bunzip2, bzcat, bzip2, cal, cat, catv, chat, chattr, chgrp, chmod, chown, chpasswd, chpst, chroot, chrt, chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab, cryptpw, cttyhack, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df, dhcprelay, diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, du, dumpkmap, dumpleases, echo, ed, egrep, eject, env, envdir, envuidgid, ether-wake, expand, expr, fakeidentd, false, fbset, fbsplash, fdflush, fdformat, fdisk, fgconsole, fgrep, find, findfs, flock, fold, free, freeramdisk, fsck, fsck.minix, fsync, ftpd, ftpget, ftpput, fuser, getopt, getty, grep, gunzip, gzip, halt, hd, hdparm, head, hexdump, hostid, hostname, httpd, hush, hwclock, id, ifconfig, ifdown, ifenslave, ifplugd, ifup, inetd, init, insmod, install, ionice, iostat, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kbd_mode, kill, killall, killall5, klogd, last, length, less, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger, login, logname, logread, losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lspci, lsusb, lzcat, lzma, lzop, lzopcat, makedevs, makemime, man, md5sum, mdev, mesg, microcom, mkdir, mkdosfs, mke2fs, mkfifo, mkfs.ext2, mkfs.minix, mkfs.vfat, mknod, mkpasswd, mkswap, mktemp, modinfo, modprobe, more, mount, mountpoint, mpstat, mt, mv, nameif, nbd-client, nc, netstat, nice, nmeter, nohup, nslookup, ntpd, od, openvt, passwd, patch, pgrep, pidof, ping, ping6, pipe_progress, pivot_root, pkill, pmap, popmaildir, poweroff, powertop, printenv, printf, ps, pscan, pwd, raidautorun, rdate, rdev, readahead, readlink, readprofile, realpath, reboot, reformime, remove-shell, renice, reset, resize, rev, rm, rmdir, rmmod, route, rpm, rpm2cpio, rtcwake, run- parts, runlevel, runsv, runsvdir, rx, script, scriptreplay, sed, sendmail, seq, setarch, setconsole, setfont, setkeycodes, setlogcons, setsid, setuidgid, sh, sha1sum, sha256sum, sha512sum, showkey, slattach, sleep, smemcap, softlimit, sort, split, start-stop-daemon, stat, strings, stty, su, sulogin, sum, sv, svlogd, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac, tail, tar, tcpsvd, tee, telnet, telnetd, test, tftp, tftpd, time, timeout, top, touch, tr, traceroute, traceroute6, true, tty, ttysize, tunctl, udhcpc, udhcpd, udpsvd, umount, uname, unexpand, uniq, unix2dos, unlzma, unlzop, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, volname, wall, watch, watchdog, wc, wget, which, who, whoami, xargs, xz, xzcat, yes, zcat, zcip 46
  • 47. Download BusyBox (1.18.3) to your $ {PRJROOT}/sysapps directory and extract it there. ● Move to the directory for the rest of the setup: $ cd ${PRJROOT}/sysapps/busybox-1.18.3 ● Configuration of BusyBox's options: $ make menuconfig 47
  • 48. 48
  • 49. “Busybox Settings”: ● “Build Options” -> Cross-compiler prefix: ${TARGET}- ● “Installation Options” -> Installation prefix: ${PRJROOT}/rootfs ● Build: $ make ● Install: $ make install 49
  • 50. 12. Demos ● All: ● AOSP ● BYO glibc-based rootfs ● Demo 1: BusyBox ● Demo 2: Client-Server app talking through socket ● glibc client ● bionic server ● Demo 3: Surprise! 50
  • 51. 12.1. Demo 1 - BusyBox ● Configure, build and “install” BusyBox ● Get it copied into final RAM disk image ● Modify AOSP to: ● Make sure /lib/* is executable ● Path start with “/bin” ● adb shell is BusyBox, not Toolbox 51
  • 52. 12.2. Demo 2 – Client/Server 52
  • 53. 12.3. Demo 3 – LTTng ● Patch kernel ● Cross-build ltt-ctl ● Modify AOSP to log to LTTng 53
  • 54. Headless Android + = “And then GNU came back for revenge ...” -- Tarantino's sequel 54
  • 56. How to decapitate Android ● Disable: ● SurfaceFlinger ● WindowManager ● WallpaperService ● InputMethodManager ● SystemUI ● Don't let SurfaceFlinger Client try to open binder to SurfaceFlinger ● Feed bogus values back from SurfaceFlinger Client ● Disable qemud (emulator artefact) ● Tweak internals by disabling key calls: ● In ActivityStack.java: – startHomeActivityLocked() – setAppStartingWindow() ● wm.detectSafeMode() ● wm.systemReady() ● wm.reclaimSuraceMemoryLocked() 56
  • 57. What's in there? ● Most everything Android gives you: ● No UX ● Fully-integrated Eclipse IDE ● SDK/NDK ● ADB ● Fastboot ● Published, well-known, and very rich APIs ● A large and growing developer community ● And still we can use the usual suspects: – GNU toolchain, BusyBox, u- boot, glibc, ... ● Caveat -- “Activity” no longer works ● You have: ● Services ● ContentProviders ● BroadcastReceivers 57