Linux Kernel and Android Development Class Linux Kernel and Android Development Class
Total Page:16
File Type:pdf, Size:1020Kb
Linux Kernel and Android Development Class Linux Kernel and Android Development Class Gr´egory Cl´ement,Michael Opdenacker, Maxime Ripard, S´ebastienJan, Thomas Petazzoni, Alexandre Belloni, Gr´egory Lemercier Free Electrons, Adeneo Embedded c Copyright 2004-2012, Free Electrons, Adeneo Embedded. Creative Commons BY-SA 3.0 license. Latest update: December 5, 2012. Document updates and sources: http://adeneo-embedded.com Corrections, suggestions, contributions and translations are welcome! Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 1/742 Rights to copy c Copyright 2004-2012, Free Electrons, Adeneo Embedded License: Creative Commons Attribution - Share Alike 3.0 http://creativecommons.org/licenses/by-sa/3.0/legalcode You are free: I to copy, distribute, display, and perform the work I to make derivative works I to make commercial use of the work Under the following conditions: I Attribution. You must give the original author credit. I Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. I For any reuse or distribution, you must make clear to others the license terms of this work. I Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above. Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 2/742 Welcome! I Audience: embedded software students I Purpose of this course: development environment setup, drivers and kernel development, image building I Prerequisites: basic knowledge of Linux, good knowledge of C, basic knowledge of OS I Agenda Course 1 : Linux kernel - Principles and deployment on embedded platforms (2 hours) Course 2 : Android - Principles and architecture (2 hours) Course 3 : Linux - Driver development (2 hours) I Targeted hardware platform : PandaBoard ES Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 3/742 Who is Adeneo Embedded? I BSP and driver development I Hardware Design and design reviews I Systems optimization I Embedded application development I Support contract I Training and Workshop I Consulting and engineering services Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 4/742 PandaBoard ES I Core Architecture: ARM I Core Sub-Architecture: Cortex-A9 dual-core I OMAP4460 I kit: ES Board revision B1, µSD card and Adaptor I features: High-Speed USB 2.0 OTG Port, Stereo Audio Out/In, Ethernet, HDMI, DVI, Camera I/F I clock max: 1.5 GHz Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 5/742 Linux Kernel Introduction Linux Kernel Introduction Gr´egory Cl´ement,Michael Opdenacker, Maxime Ripard, S´ebastienJan, Thomas Petazzoni, Alexandre Belloni, Gr´egory Lemercier Free Electrons, Adeneo Embedded c Copyright 2004-2012, Free Electrons, Adeneo Embedded. Creative Commons BY-SA 3.0 license. Corrections, suggestions, contributions and translations are welcome! Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 6/742 Linux Kernel Introduction Linux features Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 7/742 Linux kernel in the system Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 8/742 History I The Linux kernel is one component of a system, which also requires libraries and applications to provide features to end users. I The Linux kernel was created as a hobby in 1991 by a Finnish student, Linus Torvalds. I Linux quickly started to be used as the kernel for free software operating systems I Linus Torvalds has been able to create a large and dynamic developer and user community around Linux. I Nowadays, hundreds of people contribute to each kernel release, individuals or companies big and small. Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 9/742 Linux license I The whole Linux sources are Free Software released under the GNU General Public License version 2 (GPL v2). I For the Linux kernel, this basically implies that: I When you receive or buy a device with Linux on it, you should receive the Linux sources, with the right to study, modify and redistribute them. I When you produce Linux based devices, you must release the sources to the recipient, with the same rights, with no restriction.. Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 10/742 Linux kernel key features I Portability and hardware I Security. It can't hide its support. Runs on most flaws. Its code is reviewed architectures. by many experts. I Scalability. Can run on I Stability and reliability. super computers as well as I Modularity. Can include on tiny devices (4 MB of only what a system needs RAM is enough). even at run time. I Compliance to standards I Easy to program. You can and interoperability. learn from existing code. I Exhaustive networking Many useful resources on support. the net. Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 11/742 Supported hardware architectures I See the arch/ directory in the kernel sources I Minimum: 32 bit processors, with or without MMU, and gcc support I 32 bit architectures (arch/ subdirectories) Examples: arm, avr32, blackfin, m68k, microblaze, mips, score, sparc, um I 64 bit architectures: Examples: alpha, arm64, ia64, sparc64, tile I 32/64 bit architectures Examples: powerpc, x86, sh I Find details in kernel sources: arch/<arch>/Kconfig, arch/<arch>/README, or Documentation/<arch>/ Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 12/742 System calls I The main interface between the kernel and userspace is the set of system calls I About 300 system calls that provide the main kernel services I File and device operations, networking operations, inter-process communication, process management, memory mapping, timers, threads, synchronization primitives, etc. I This interface is stable over time: only new system calls can be added by the kernel developers I This system call interface is wrapped by the C library, and userspace applications usually never make a system call directly but rather use the corresponding C library function Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 13/742 Virtual filesystems I Linux makes system and kernel information available in user-space through virtual filesystems. I Virtual filesystems allow applications to see directories and files that do not exist on any real storage: they are created on the fly by the kernel I The two most important virtual filesystems are I proc, usually mounted on /proc: Operating system related information (processes, memory management parameters...) I sysfs, usually mounted on /sys: Representation of the system as a set of devices and buses. Information about these devices. Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 14/742 Linux Kernel Introduction Linux versioning scheme and development process Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 15/742 Until 2.6 (1) I One stable major branch every 2 or 3 years I Identified by an even middle number I Examples: 1.0.x, 2.0.x, 2.2.x, 2.4.x I One development branch to integrate new functionalities and major changes I Identified by an odd middle number I Examples: 2.1.x, 2.3.x, 2.5.x I After some time, a development version becomes the new base version for the stable branch I Minor releases once in while: 2.2.23, 2.5.12, etc. Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 16/742 Until 2.6 (2) Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 17/742 Changes since Linux 2.6 (1) I Since 2.6.0, kernel developers have been able to introduce lots of new features one by one on a steady pace, without having to make major changes in existing subsystems. I So far, there was no need to create a new development branch (such as 2.7), which would massively break compatibility with the stable branch. I Thanks to this, more features are released to users at a faster pace. Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 18/742 Changes since Linux 2.6 (2) Since 2.6.14, the kernel developers agreed on the following development model: I After the release of a 2.6.x version, a two-weeks merge window opens, during which major additions are merged. I The merge window is closed by the release of test version 2.6.(x+1)-rc1 I The bug fixing period opens, for 6 to 10 weeks. I At regular intervals during the bug fixing period, 2.6.(x+1)-rcY test versions are released. I When considered sufficiently stable, kernel 2.6.(x+1) is released, and the process starts again. Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 19/742 Merge and bug fixing windows Adeneo Embedded. Consulting, Engineering, Training and Support. http://www.adeneo-embedded.com/ 20/742 More stability for the kernel source tree I Issue: bug and security fixes only released for most recent stable kernel versions. I Some people need to have a recent kernel, but with long term support for security updates. I You could get long term support from a commercial embedded Linux provider. I You could reuse sources for the kernel used in Ubuntu Long Term Support releases (5 years of free security updates). I The http://kernel.org front page shows which versions will be supported for some time (up to 2 or 3 years), and which ones won't be supported any more ("EOL: End Of Life") Adeneo Embedded.