0% found this document useful (0 votes)
34 views46 pages

1-Introduction To Embedded Linux

Uploaded by

Diego7120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views46 pages

1-Introduction To Embedded Linux

Uploaded by

Diego7120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Introduction to Embedded Linux

M2 SETI-B4 Embedded Linux

Maria Mushtaq
Maria.mushtaq@telecom-paris.fr
2022-2023

Une école de l’IMT


Outline

o Administrative Introduction

o World of Embedded System

o Open Source Licences

o Linux and Embedded

o References

2 Une école de l’IMT


Pedagogic Objectives

o Being able to implement a Linux system on an embedded system

o Understanding of boot mechanism -from the the bootloader to the applications

o Understanding the different elements needed and how to generate them

(kernel, device tree, initial file system, root file system...)

o Know how to write a simple device driver

3 Une école de l’IMT


o Examples of device drivers????

4 Une école de l’IMT


Pre-requisites

o Programming in C language –for writing device drivers

o Basic use of Linux, the command line. Classic compilation tools

(gcc, make…)

o Architecture of computers and embedded systems

(buses, interrupts, DMA, virtual memory)

o Basic use of git

5 Une école de l’IMT


Timetable 2022-2023
o Tuesday 13h30-17h 13/12 (1 Session)

o Tuesday 13h30-17h 03/01 (1 Session)

o Tuesday 13h30-17h 10/01 (1 Session)

o Tuesday 13h30-17h 17/01 (1 Session)

o Tuesday 13h30-17h 24/01 (1 Session)

o Tuesday 13h30-17h 31/01 (1 Session)

o Tuesday 13h30-17h 07/02 (1 Session)

o Tuesday 13h30-17h 14/02 (1 Session)

o Tuesday 13h30-17h 20/02 (Exam)

6 Une école de l’IMT


Practical Work

o Themes

o Compiling the Kernel

o Creating file system (distribution)

o Creating a device driver

o Use of Qemu to simulate an embedded system based on ARM Cortex-A processor

o No need for TP mock-ups (work at home, remote access)

o Easier to debug

7 Une école de l’IMT


Practical Work (Personal Computer)

o Computer under Linux with a relatively recent distribution

o 8 GB of RAM

o 50 GB of free disk space (kernel sources, disk image, etc.)

o Classic development tools (gcc, make, git...)

o Other necessary software (qemu, arm-linux-eabi-gcc...) will be installed afterwards

8 Une école de l’IMT


Action Plan

o Session 1

- Course Introduction

- Course Starting a Linux system (beginning)

o Session 2

- Course Starting a Linux system (end)

- TP Kernel, init, initramfs, BusyBox and U-Boot

o Session 3

- Course Root file system

- TP Build your complete distribution with Buildroot

9 Une école de l’IMT


Action Plan
o Session 4

- Course introduction to kernel development,

- first module, debugging mechanisms and memory allocation

- TP Write your first module

o Session 5

- Course Device Model

- TP

o Session 6

- Course Interface with user space

- Course Scheduling and waiting

10 Une école de l’IMT


Action Plan

o Session 7

- Course Interruptions

- TP

Session 8

- Course Concurrence

- Course Access to memory mapped devices memory

- TP

11 Une école de l’IMT


Evaluation Criteria

o Final grade
• - 25% of the TP renderings on the device driver (Group Assignment)

• - 75% final exam on table

- MCQ type questions and/or open questions

- Only document allowed: one A4 page with what you want to write on it

- Any other document, course material, computer telephone, calculator... forbidden

- For the moment, the conditions are met to take this exam in person. Nevertheless, if the situation requires it, this exam could take

place at a distance with adapted modalities

12 Une école de l’IMT


Some Remarks!!

o Course taken over from last year (taught by another teacher in previous years) and reassembled

from scratch in English

o Medium of course will remain English

o Do not hesitate to point out any error that you find in the in the course, the texts of the practical

exercises, etc.

o Your feedback will be precious to improve this course for the next years

o Don't hesitate to ask questions during the course and the tutorials!

13 Une école de l’IMT


Outline

o Administrative Introduction

o World of Embedded System

o Open Source Licences

o Linux and Embedded

o References

14 Une école de l’IMT


The world of embedded systems

o Core: from a small 8-bit microcontroller to several 64-bit multi-core/multi-threaded 64-bit processors

o RAM: from a few KB to several GB

o Mass storage: from a few KB of ROM to several GB/TB of flash or hard disk

o Memory protection: MPU (Memory Protection Unit), MMU (Memory Management Unit)

o Constraints: cost, consumption, real time, safety, security, etc.

o We will see later on the minimal characteristics to run Linux

15 Une école de l’IMT


The role of an operating system (OS)

o Securely share the resources of the execution media between the different tasks

o Processor(s): allocates processor time to the different tasks wishing to execute (with priority management,

preemption, etc.)

o Memory: distributes the memory to the tasks and ensures isolation between them (based on hardware:

MPU, MMT, etc.)

o Peripherals

o Provides

o Hardware abstraction for tasks

o Communication and synchronization mechanisms between tasks

16 Une école de l’IMT


Operating Systems in embedded systems
n Examples

o Generalists : Linux, *BSD (FreeBSD, NetBSD...), Windows...

o Dedicated

o Windows IoT (ex. Windows Embedded, proprietary), QNX (proprietary), iOS (proprietary), Android (open

source)...

o Real time: VxWorks (proprietary), FreeRTOS (open source), ChibiOS/RT (open source), INTEGRITY

(proprietary, classified), RTX (proprietary)...

17 Une école de l’IMT


Operating Systems in embedded systems (Cont…)
o According to [1], operating systems used in embedded systems:

o Embedded Linux: 21%

o Home: 19%

o FreeRTOS: 18%

o Ubuntu: 14%

o Debian: 13% of the total

o Android: 13% of the total

o Windows 10: 10% of the total


o Multiple answers allowed, sum > 100%.

o The market share of Linux (all distributions combined) is therefore very important in the embedded world

18 Une école de l’IMT


Why chose Linux?

o Free license and open source code

o Support for many architectures

o Many device drivers

o Dynamic ecosystem

o Long-term viability

19 Une école de l’IMT


Why not to chose Linux?

o Free license and open source code

o No commercial support

o Liability in case of problems

o Large ecosystem

o Not suitable for all embedded systems

20 Une école de l’IMT


Outline

o Administrative Introduction

o World of Embedded System

o Open Source Licences

o Linux and Embedded

o References

21 Une école de l’IMT


Free Lisences?
n Rights and Obligations

o Important point to check, especially if you distribute or sell an embedded system

o containing free software

o Some licenses impose constraints on access to the source code, patents or the possibility to update the software

o Main licenses used

o Copyleft licenses

- GNU General Public License (GPL) v2

- GNU General Public License (GPL) v3

- GNU Lesser General Public License (LGPL)

o Permissive licenses

- BSD, MIT, Apache

22 Une école de l’IMT


GNU General Public License (GPL) V2 [3]

o Used by the Linux kernel, many tools (busybox for example) and some libraries (GNU Readline!)

o Rights (for the user)

o Use the software

o Study how it works

o Copy and distribute the software

o Modify the software and distribute those modifications

23 Une école de l’IMT


GNU General Public License (GPL) V2 [3]

o Obligations (when distributing the software)

o Keep the copyright notices

o Provide access to the source code

o Modifications made to the software must be distributed under the same terms (and therefore distribute the source code of the

modifications)

o The link with a static or dynamic library is considered a derivative work and therefore requires publication of the

software under the GPL

o A module compiled outside of the kernel source tree can be distributed under another license (but it will not have

access to certain features of the kernel, and the kernel will be marked as tainted)

24 Une école de l’IMT


GNU General Public License (GPL) V3 [4]

o Main additions to v2
o In case of hardware + software distribution, obligation to provide the necessary information so that the

user can run a modified version of the software

o In case of distribution of the software, provision of a license on the patents necessary to the user to

exercise his rights

o In case of an attack for patent infringement the attacker loses the rights granted by the license

25 Une école de l’IMT


GNU Lesser General Public License (LGPL) [5]

o Similar to the GPL, especially dedicated to libraries

o Facilitates the use of an LGPL library by a non-GPL/LGPL application


o In case of static linking, it is necessary to allow the user to modify the LGPL library and link it back to your

application (so provide your application in object form for example)

o In case of dynamic linking, if the LGPL library is already present on the user's computer, there is no need to

distribute the code of the library.

26 Une école de l’IMT


Permissive licenses (BSD, MIT, Apache...)

o Unlike copyleft licenses, they do not require the distribution of derivative works under

the same license

o In general, in case of redistribution, they oblige simply mention the use of the

component, its license and its authors, and the absence of warranty

27 Une école de l’IMT


Free licenses (Conclusion)

o Be very careful with licenses: if you have any doubt, ask a specialized lawyer

o Important point: almost all free licenses explicitly mention the absence of guarantees

on the functioning of the software component

o You will not be able to turn against such a software component if a bug in the latter has

caused a critical failure of your system.

o The legality of this exclusion is debated in some countries

28 Une école de l’IMT


Outline

o Administrative Introduction

o World of Embedded System

o Open Source Licences

o Linux and Embedded

o References

29 Une école de l’IMT


The Linux Kernel –Brief History

o In 1991, while studying in Helsinki (Finland), Linus Torvalds (21 years old), started to

write a small kernel intended to run on a 80386 processor

o On August 25th 1991, he announced his project on the newsgroup comp.os.minix

30 Une école de l’IMT


The Linux Kernel –Brief History

o September 1991 : version 0.01 published on a FTP server, about 10,000 lines of code

o December 1992: version 0.99 distributed under GNU GPL license

o Thanks to the democratization of the Internet in the early 90's, Linux federates a

growing community of developers

o March 1994: Version 1.0.0 (175,000 lines of code)

o January 1999: Version 2.2.0 (1.800.000 lines of lines of code)

o January 2001: Version 2.4.0 (3,400,000 lines of lines of code)

o December 2003: Version 2.6.0 (6,000,000 lines of code)


31 Une école de l’IMT
The Linux Kernel –Minimum equipment required
o 32-bit or higher processor (see Embedded Linux Kernel Subset [2] for minimal support for 16-bit

processors)

o Supported architectures (v5.9): DEC Alpha, ARC, ARM, ARM 64, C6x, C-SKY, Renesas H8, Qualcomm

Hexagon, Intel IA-64, Freescale 68k, Xilinx Microblaze, MIPS, Andes NDS32, Altera NiosII, OpenRISC,

HP PA-RISC, PowerPC, RISC-V, IBM System/390, SuperH, SPARC, x86, x86-64, Tensilica Xtensa

o Memory Management Unit (MMU) (see μClinux for systems without MMU, it supports

microcontrollers)

o Several MB of RAM (the minimum depends on the kernel configuration, around 4-8 MB, but then

you have to count the executables)

32 Une école de l’IMT


The Linux Kernel

o It is not real time

o Patch PREEMPT_RT to make the kernel able to respect hard real-time constraints

o RTLinux : real time microkernel running Linux as one of its tasks

33 Une école de l’IMT


The Minimum Software Components of a Linux System
(1)

o The Linux kernel needs a number of additional software components (it can't do much on its own)

o A mechanism to allow it to identify the hardware (processor, memory, peripherals...)

o Device tree or data structure passed by the bootloader (ATAG...)

o Static description of the platform compiled with the kernel

o Automatic mechanism to identify devices (ACPI tables, enumeration of USB devices...)

34 Une école de l’IMT


The Minimum Software Components of a Linux System
(2)

o A bootloader

o Basic initialization of the platform (clock tree caches, DRAM controller...)

o Loading the kernel from a mass storage medium storage media (hard disk, flash memory...)

o Setting up the complementary structures in memory for the kernel startup (device tree, initial memory disk

(initrd...))

35 Une école de l’IMT


The Minimum Software Components of a Linux System
(3)

o A root file system

- Either a minimal system in RAM set up from an image provided to the kernel at (initrd or initramfs)

- Or a more complete file system mounted from a mass storage medium or from the network

- Note: in many systems the two methods above are used one after the other. Methods above are used

one after the other (will be detailed in the following)

36 Une école de l’IMT


The Minimum Software Components of a Linux System
(4)

o An init process (launched from /sbin/init)

o First process executed by the kernel

o Ancestor of all other processes

o Once this process is launched, the kernel startup phase is over

o It is this process that will be in charge of the rest of the system startup

37 Une école de l’IMT


Other Common Components

o Configuration files and executables for (SysV init or systemd)

o Shared libraries (at least libc)

o Shell and classic utilities (sh, mount, test...)

o Most of the essential libraries and tools come from the GNU project, hence the name GNU/Linux

o Daemons (udev, sshd...)

o A console (keyboard/screen)

38 Une école de l’IMT


Construction of a Complete Linux System (1)

o Use of a Linux distribution (generic or specialized)

o Debian

o Ubuntu

o Raspberry Pi OS (formerly Raspbian), based on Debian

o ...

o Advantages : ready to use, maintenance (security) on the long term

o Disadvantages: difficult to adapt for a particular situation, difficult to optimize

39 Une école de l’IMT


Construction of a Complete Linux System (2)

o Linux distribution generator

o Yocto Project : https://www.yoctoproject.org/

o OpenEmbedded : http://www.openembedded.org

o Buildroot : https://buildroot.org/

o Advantages: increased flexibility and optimization

o Disadvantages: more difficult to set up than a ready-made distribution, compilation time

40 Une école de l’IMT


Construction of a Complete Linux System (3)

o Creation of the different elements by hand

o Advantages: total flexibility, total understanding of the system

o Disadvantages: very long to set up, problems of dependency between tools or versions, difficult

learning curve

41 Une école de l’IMT


Outline

o Administrative Introduction

o World of Embedded System

o Open Source Licences

o Linux and Embedded

o References

42 Une école de l’IMT


References

[1] Aspencore. 2019 embedded markets study.


https://www.embedded.com/wp-
content/uploads/2019/11/EETimes_Embedded_2019_Embedded_Markets_Study.pdf, March 2019.
[2] Embeddable linux kernel subset.
https://github.com/jbruchon/elks, 2020.
[3] GNU. General Public License, version 2.
https://www.gnu.org/licenses/old-licenses/gpl-2.0.html, June 1991.
[4] GNU. General public license, version 3.
https://www.gnu.org/licenses/gpl-3.0.html, June 2007.
[5] GNU. Lesser general public license, version 3.
https://www.gnu.org/licenses/lgpl-3.0.html, June 2007.

46/

43 Une école de l’IMT


Outline

o Administrative Introduction

o World of Embedded System

o Open Source Licences

o Linux and Embedded

o References

44 Une école de l’IMT


Group Assignment

n Group of 3
n Build your file system
n Take help from internet
n Discuss in your group
n Support Material:
n https://opensource.com/article/19/4/create-
filesystem-linux-partition

45 Une école de l’IMT


Group Assignment

n Group of 3
n Build/Compile your Linux Kernel
n Take help from internet
n Discuss in your group
n Support Material:
n https://phoenixnap.com/kb/build-linux-kernel

46 Une école de l’IMT

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy