Running a Standard Linux Distribution on a Smartphone
Total Page:16
File Type:pdf, Size:1020Kb
CA R L VON O SS IETZKY DEPARTMENT FÜR INFORMATIK SYSTEMSOFTWARE UND VERTEILTE SYSTEME Running a standard Linux distribution on a smartphone Masterthesis Computer Science July 13, 2015 Sebastian Reichel (Matrikelnummer: 1104957) Otto-Wels-Str. 82 26133 Oldenburg Erstprüfer Prof. Dr.-Ing. Oliver Theel Zweitprüfer Eike Möhlmann, Dipl. Inform. Erklärung zur Urheberschaft Hiermit versichere ich, dass ich diese Arbeit selbstständig verfasst und keine anderen als die angegebenen Hilfsmittel und Quellen benutzt habe. Oldenburg, den July 12, 2015 Sebastian Reichel Contents 1. Introduction 2 2. Hardware Architecture6 3. Serial Access 12 4. Linux Kernel 23 4.1. N900 kernel support..................................... 25 4.2. Accelerometer......................................... 27 4.3. Modem............................................ 29 4.4. ARM Errata 430973..................................... 32 4.5. Bluetooth........................................... 33 4.6. Camera Subsystem...................................... 36 5. Userland 41 5.1. Graphical User Interface................................... 41 5.2. Wireless LAN......................................... 42 5.3. The modem.......................................... 43 6. Function tests 47 6.1. Updates & Security Updates................................. 47 6.2. Voice Calls.......................................... 47 6.3. Short Messages........................................ 48 6.4. Web Surfing.......................................... 49 6.5. Customization......................................... 50 7. Outlook 51 8. Conclusion 55 iv Contents Appendix 56 A. Debian Image 57 B. ISI-Protocol 62 C. Accelerometer Patches 70 D. OpenSCAD code 75 E. Bill of Materials 76 F. Simple Ofono Dialer 77 Bibliography 83 Glossary 86 v List of Figures 2.1. N900 DT graph........................................9 2.2. DT graph of OMAP3430’s system bus............................ 10 2.3. DT graph Nokia N900’s second I2C port........................... 10 3.1. Coverless N900’s back with labeled serial test pads..................... 12 3.2. Pogo-Pin profile........................................ 13 3.3. Battery adapter design in Inkscape.............................. 14 3.4. Serial adapter schematic (designed with KiCad)....................... 16 3.5. Generating G-Code for Gerber-files using FlatCAM..................... 18 3.6. left: Front and back of the adapter’s PCB; right: PCB with crepe-tape-stencil....... 18 3.7. Colorized vector information for the laser cutter....................... 19 3.8. 3D-rendering of the layers.................................. 20 3.9. N900 with attached debug adapter.............................. 21 4.1. Flow-graph of kernel forks.................................. 23 4.2. Kernel-development flow................................... 24 4.4. Modem interconnection.................................... 29 4.5. Modem protocol stack.................................... 31 4.6. BCM2048 setup........................................ 34 4.7. Camera setup......................................... 37 4.8. OMAP’s image signal processor in Linux.......................... 39 4.9. N900 camera setup in Linux................................. 40 5.1. Screenshot from Enlightenment running in vertical split mode............... 43 6.1. Voice call handling in ofono-dialer.............................. 48 6.2. SMS handling in ofono-dialer................................ 49 6.3. LXDE running on the Nokia N900.............................. 50 B.1. GPS Session.......................................... 64 B.2. GPS Session in Wireshark.................................. 69 vi List of Tables 1.1. Smartphone Operating System Comparison.........................4 4.1. Major Linux Kernel Releases................................. 25 4.2. N900 Linux Kernel Support (Status: Linux Kernel 4.0)................... 26 4.3. Nokia H4+ Packet Types................................... 34 B.1. PhoNet Header........................................ 62 B.2. ISI Resource IDs (excerpt of most important IDs)...................... 62 B.3. ISI Header........................................... 63 B.4. GPS Session: Status Indication Subscription......................... 63 B.5. GPS Session: Hybrid Tracking Request........................... 65 B.6. GPS Session: Hybrid Tracking Response.......................... 65 B.7. GPS Session: Socket Open Request............................. 66 B.8. GPS Session: Socket Send Request.............................. 66 B.9. GPS Session: Socket Receive Request............................ 67 B.10. GPS Session: GPS Status Indication: No Lock........................ 67 B.11. GPS Session: GPS Status Indication: Lock Acquired.................... 67 B.12. GPS Session: Hybrid Location Data............................. 68 E.1. Bill of Materials for UART Adapter PCB.......................... 76 vii Listings 2.1. Simplified Nokia N900 Device Tree Source File.......................7 2.2. Simplified and Merged SPI4 Excerpt from Nokia N900 Device Tree Source File......8 3.1. Nokia N900 Boot Log.................................... 21 4.1. Simplified Nokia N900 Display Connection DT excerpt................... 37 5.1. Starting X-Server together with an XTerm.......................... 41 5.2. X.org Touchscreen Configuration............................... 42 5.3. Patch adding ofono support to the cmt-speech plugin of the FSO-audio daemon...... 45 6.1. Initialize a voice call from command line using mdbus2................... 47 6.2. Send a SMS using mdbus................................... 48 C.1. [PATCH] lis3lv02d: DT: use s32 to support negative values................. 70 C.2. [PATCH] lis3lv02d: DT: add wakeup unit 2 and wakeup threshold............. 71 C.3. [PATCH] Documentation: DT: lis302: update wakeup binding............... 72 C.4. [PATCH] DTS: ARM: OMAP3-N900: Add lis3lv02d support................ 73 D.1. OpenSCAD-Code for 3D-rendering of the Serial-Adapter.................. 75 F.1. Simple Ofono dialing and short message application..................... 77 viii Abstract The aim of this thesis is running a free operating system on a smartphone, which shares many components and principles with the operating system already used on the desktop PC. As a result users and developers can use the software they are used to on their PC and on their smartphone. Compared to other closed source alternatives it also means, that any code audits are more likely reducing the probability of built-in backdoors. The thesis is written using Debian as example Linux distribution and uses the Nokia N900 as hardware base. One reason for choosing the Nokia N900 was, that the main Linux kernel used by the Debian project has already support for all base hardware components. The first part of the thesis will describe how the kernel support for the Nokia N900 can be improved, while the second part focuses on the userspace software. 1. Introduction Nowadays it is common, that one can install a arbitrary Linux distribution on ones notebook or desktop computer. Installing it on a smartphone is a completely different issue, though. Currently the Linux kernel, as available on kernel.org, does not support a complete smartphone and as a result most Linux distributions do not provide any smartphone support. Smartphones, in difference to desktop PCs and notebooks are commonly shipped with a locked down sys- tem running Android, iOS or Windows Phone these days [27]. Of these smartphone distributions only Android is mostly based on open source software, while iOS and Windows Phone are closed source soft- ware and always shipped with the hardware. From a users point of view the open source development model has a few advantages: 1. Auditability: Since the software’s source code is available in public, it is possible to review it. If the user does not understand the programming language, there is still an increased chance, that other people review the source code. This is an important factor in times of intelligence agencies being suspected of adding backdoors to software. 2. Freedom: Since everything is open, everything can be adjusted to fit the user’s preferences. This also counts for any bugs, that are found. While closed source software requires, that the vendor fixes the bug, user’s can do it themselves. There is no dependency on the vendor’s support. Additionally trying the software is most times free of charge. While the term free in free software refers to the independence, most software is also free of charge. Since Windows Phone and iOS are not open source software and may even come with a hardware lock, they will not be further compared with the aimed smartphone support for a major Linux distribution. Android’s base system on the other hand is available as open source software and is even using the Linux kernel as base. Nevertheless Android is quite different from most other Linux distributions, since it brings its own software stack on top of the Linux kernel with minimal use of existing projects already available. Apart from that vendors are not actively working on getting their software modifications back into the original projects. Instead many vendors copy the software’s source code and continue working on the copy (also known as fork). In the Android community these kind of forks are usually referred to as „vendor- customized”. As a result of the missing work on getting the software modifications back into the original projects, the current Linux kernel does not support the complete hardware components of any smartphone. At the same time the amount