Virtualization of the RIOT Operating System
Total Page:16
File Type:pdf, Size:1020Kb
Computer Systems and Telematics — Distributed, Embedded Systems Diploma Thesis Virtualization of the RIOT Operating System Ludwig Ortmann Matr. 3914103 Supervisor: Dr. Emmanuel Baccelli Assisting Supervisor: Prof. Dr.-Ing. Jochen Schiller Institute of Computer Science, Freie Universität Berlin, Germany March 2, 2015 iii I hereby declare to have written this thesis on my own. I have used no other literature and resources than the ones referenced. All text passages that are literal or logical copies from other publications have been marked accordingly. All figures and pictures have been created by me or their sources are referenced accordingly. This thesis has not been submitted in the same or a similar version to any other examination board. Berlin, March 2, 2015 (Ludwig Ortmann) Abstract Abstract Software developers in the growing field of the Internet of Things face many hurdles which arise from the limitations of embedded systems and wireless networking. The employment of hardware and network virtualization promises to allow developers to test and debug hard- ware independent code without being affected by these limitations. This thesis presents RIOT native, a hardware and network emulation implementation for the RIOT operating system, which enables developers to compile and run RIOT as a process in their host operat- ing system. Running the operating system as a process allows for the use of debugging tools and techniques only available on desktop computers otherwise, the integration of common network analysis tools, and the emulation of arbitrary network topologies. By enabling the use of these tools and techniques for the development of software for distributed embedded systems, the hurdles they impose on the development process are significantly reduced. Contents List of Figures xi List of Tables xiii Listings xv Acronyms xvii 1. Introduction 1 1.1. Motivation . .1 1.1.1. The Rise of Embedded Systems . .1 1.1.2. The Complementary Worlds of Traditional and Embedded Systems .1 1.1.3. The Internet of Things . .2 1.1.4. The Caveats of Software Development for the Internet of Things (IoT)2 1.1.5. The Future of Embedded Software Development . .3 1.1.6. The Need for Open Source Software . .4 1.1.7. The Problem at Hand . .4 1.1.8. Compatibility of Software for Embedded with Desktop Systems . .5 1.1.9. Facilitating the Problems of Software Development for Embedded Sys- tems . .5 1.1.10. The Software Environment . .6 1.2. Terminology . .7 1.3. Goals for this Thesis . .8 1.4. Contribution . .8 1.4.1. The Emulator Platform . .8 1.4.2. A Development Methodology for the IoT . .9 1.4.3. Improving the Development Process . .9 1.4.4. Virtual Networking Support . .9 1.4.5. In-Process Preemptive Threading . .9 2. Background and Related Work 11 2.1. The Open Source Project . 11 2.1.1. Community . 11 2.1.2. Project Goals . 12 2.1.3. Development Process . 12 2.1.4. Implications . 13 viii Contents 2.2. Software Quality . 13 2.2.1. Quality Characteristics . 13 2.2.2. Functionality . 14 2.2.3. Reliability . 14 2.2.4. Efficiency . 15 2.2.5. Maintainability . 15 2.2.6. Assuring Software Quality . 15 2.3. Development Tools for Quality Assurance . 15 2.3.1. Constructive . 16 2.3.2. Conclusion . 16 2.4. Analytical Software Development Tools . 16 2.4.1. Functionality . 16 2.4.2. Reliability . 17 2.4.3. Efficiency . 17 2.4.4. Maintainability . 18 2.4.5. Methods and Tools . 18 2.4.6. Preliminary Conclusion . 19 2.5. Tools for IoT Analysis . 19 2.5.1. Model Checking . 19 2.5.2. Static Analysis . 19 2.5.3. Dynamic Analysis . 20 2.5.4. Conclusion . 22 2.6. Tools for Desktop Systems . 23 2.6.1. GDB – Debugger . 23 2.6.2. Valgrind memcheck – Memory Debugger . 23 2.6.3. gprof and Valgrind – Memory and Performance Profiling . 23 2.6.4. Structured Automated Tests . 24 2.6.5. Wireshark - Network Analyzer . 24 2.6.6. Conclusion . 24 2.7. System Virtualization . 24 2.7.1. System Abstraction Levels . 25 2.7.2. Emulation versus Simulation . 27 2.7.3. Conclusion . 27 2.8. Network Virtualization . 28 2.8.1. Network Simulation versus Emulation . 28 2.8.2. TAP Networking . 29 2.9. Productivity . 29 2.9.1. Waiting Destroys Productivity . 29 2.9.2. Test-Driven Development . 30 2.9.3. Conclusion . 30 2.10. The native Platform . 31 2.10.1. Related Work . 31 3. Design and Implementation of the native Platform 33 3.1. Overview . 33 3.2. Threads . 35 3.2.1. The Thread Concept . 35 Contents ix 3.2.2. Threads in RIOT . 35 3.2.3. POSIX ucontext API . 36 3.2.4. Threads in Native ............................ 36 3.2.5. Alternatives to ucontext ......................... 37 3.3. Interrupts . 37 3.3.1. Interrupt Concepts . 37 3.3.2. POSIX Signals . 37 3.3.3. Native Interrupts . 38 3.4. Hardware Timers . 41 3.4.1. Timers in RIOT ............................. 41 3.4.2. Timers in Native ............................. 41 3.5. Virtual Networking . 41 3.5.1. TAP Networking . 42 3.5.2. TAP networking in native . 42 3.5.3. Nativenet Implementation . 43 3.5.4. Configurability . 43 3.6. Traffic Analysis Support . 44 3.7. Virtual Testbed Support . 44 3.7.1. DES-Virt ................................. 45 3.8. UART . 45 3.8.1. UARTs in RIOT ............................. 45 3.8.2. stdio in C and POSIX . 46 3.8.3. uart0 in Native .............................. 47 3.9. RTC . 47 3.9.1. realtime clock (RTC) in Native ..................... 48 3.10. GPIO . 48 3.10.1. RIOT GPIO API . 48 3.10.2. Linux sysfs GPIO . 48 3.10.3. GPIOin Native .............................. 49 3.11. Valgrind memcheck . 49 3.12. Stack Smashing Protection . 50 3.13. Profiling . 51 3.13.1. gprof . 51 3.13.2. cachegrind ................................. 52 3.14. Ramifications of Using Native Libraries . 52 3.14.1. Host Transparency . 54 3.14.2. OS X . 54 4. Evaluation of Functionality, Performance and Impact of the native Platform 57 4.1. Functional Analysis . 57 4.1.1. Virtualization . 57 4.1.2. Network Virtualization . 58 4.2. Support for Development Tools . 58 4.2.1. Coverage . ..