Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to Embedded Linux

1,249 views

Published on

Over the years Linux is being used as operating system in many intelligent and smart electronic devices starting from mobile phone, refrigerator to cow milking devices apart from desktops and server computers. Though Linux is open source, its often difficult for a beginner to get started. In this presentation embedded system and embedded Linux have been introduced through examples, animation and short explanation. This presentation is targeted to the absolute beginner or embedded software engineer who wants to be part of exciting world of Linux and the enthusiast or even manager who just wants to get idea about embedded Linux.

Published in: Software
  • Be the first to comment

Introduction to Embedded Linux

  1. 1. 2 Preface Over the years Linux is being used or embedded as operating system in many intelligent and smart electronic devices starting from mobile phone, refrigerator to cow milking devices apart from desktops and server computers. Though Linux is open source, its often difficult for a beginner to get started. In this presentation embedded system and embedded Linux have been introduced through examples, animation and short explanation. This presentation is targeted to the absolute beginner or embedded software engineer who wants to be part of exciting world of Linux and the enthusiast or even manager who just wants to get idea about embedded Linux.
  2. 2. 3 About Author Hossain Reja, a graduate in computer science and engineering from National Institute of Technology, Hamirpur, has over seventeen years of expertise in building embedded systems. He has experience and working knowledge in multiple domains – process control, set-top box, cable modems, mobile domains and vehicle electronics and infotainment. Hossain is passionate about kernel.
  3. 3. 4 Introduction to Embedded Systems
  4. 4.  Wild Life Preservation is very much important  Technology can help to preserve the wild lives  One such technology is drone  Drone is a mini helicopter that can fly at low altitude and can keep an eye on the wild lives in a forest 5 Wild Life Preservation
  5. 5. 6 Drone – The Flying Machine  An example of typical drone is a quad-copter  This drone can take areal images – like wild lives images in a forest , crop images in a firming land etc  These images can be processed to design and develop various applications like – wild life preservation, crop pesticide management  This drone can be controlled by smart phone, tablet, iPhone and iPad etc
  6. 6. 7 Things Google Glass A wearable device with optical head mounted display that helps to navigate, talk to internet through voice commands and much more Nike+ Shoes This tracks a run and record it and can communicate with Smart Phone Smart Phone This does not need a description Smart Watch A computerized wristwatch that essentially is a smart phone, phone app can run on it and it’s application is bound by your imagination
  7. 7. 8 Some more things In-Vehicle Infotainment System Provides driver assistance information, navigation, entertainment inside car and much more Learning Thermostat An smart thermostat that learns your AC usage behavior and control it saving energy and connects to internet so virtually it can be controlled from anywhere Smart Refrigerator Apart from its basic function of refrigeration, it learns your food stock and automatically order for you and takes instruction from you from anywhere
  8. 8. 9 Embedded Systems  These devices have at least one thing in common  They are essentially a computer that runs software to accomplish a specialized function - learning your AC usage behavior, jogging behavior, food stock in your refrigerator or entertaining you inside your car on a along drive  A computer device with specialized function is an Embedded System
  9. 9. 10 Inside Embedded Systems
  10. 10. 11 Drone – Tear down Mechanical  Chassis  Propeller Electrical  Servo motor Electronics  Printed Circuit Board  Digital Camera
  11. 11. 12 Drone – PCB Tear Down  Main board  Navigation board Hardware Vertical Camera Flash ROM (128MB) 16-bit Micro & 10-Bit ADC RAM (128MB) XY-axis Gyroscope WiFi Processor (ARM)
  12. 12. 13 Hardware Components Processor : Central Processing Unit RAM: Main Memory ROM: Secondary (Persistent) Memory Propeller: Driven by Servo Motor (Navigation) Gyroscope: Keeps drone stable (Navigation) Camera: Wild Life Image Capture, Weed Detection at Firm House WiFi: Wireless communication, Remote Control through Smart Phone, iPad etc
  13. 13. 14 Embedded Hardware and Software  Hardware  Operating System  Application Operating System Applications Hardware
  14. 14. ApplicationOS 15 Embedded Hardware and Software Hardware Vertical Camera Flash ROM (128MB) 16-bit Micro & 10-Bit ADC RAM (128MB) XY-axis Gyroscope WiFi Processor (ARM) Operating System  Linux  Android (Linux based)  Windows  VxWorks  iOS Application Examples  Navigation  Video capture and image processing  Wild image detection  Wild Life Protection  Navigation board
  15. 15. 16 Embedded Linux
  16. 16. 17 Linux as Embedded OS Application Hardware Linux OS
  17. 17. 18 Booting Process – x86 BIOS/EFI/UEFI Boot Loader (First Stage) Boot Loader (Second Stage) (grub, elilo) Kernel (bzImage) User Application (init)  Staged booting process  Main components  BIOS/EFI/UEFI (Firmware)  Boot Loader (First Stage, optional)  Boot Loader (elilo, grub etc)  Linux Kernel  User application
  18. 18. 19 Booting Process – x86 BIOS/EFI/UEFI Boot Loader (First Stage) Boot Loader (Second Stage) (grub, elilo) Kernel (bzImage) User Application (init) * Starts on power on/reset * Does basic initialization *Does basic test * Loads and runs First Stage Boot Loader in SRAM * Initialize DRAM * Loads and run Second Stage Boot Loader from DRAM * Boot loader with full festuree *Iinitialize hardware (DRAM) * Loads Linux kernel from a file system (i.e. SD card/Flash) * Runs linux kernel * Linux kernel initializes all the subsystems (memory manager scheduler, device drivers etc) * Runs first user space program * User space start-up runs * Mutli-user or Graphical systems up and running and ready to be used  Staged boot process  System partially initialized and specific task is achieved at each stage from power on to system boot (user prompt or application)  Embedded system generally prompt for user login prompt, it start application during the boot process automatically
  19. 19. 20 Boot Process - ARM ROM Code init SRAM Load boot strap on SRAM Runs SRAM Boot Strap Init clock, SDRAM Load u-boot from Flash to SDRAM Runs u-boot u-boot Uncompress zImage Loads it to DRAM Runs Kernel Linux Kernel Initialize all sub-system (clock, memory manager, scheduler, device driver, file system etc) Runs user process init User space init process rootfs Storage ViewExecution View Flash (u-boot.bin) MTD/SD/MMC (zImage) SD/MMC/MTD rootfs DRAM (u-boot) DRAM kernel (uncompressed zImage) DRAM (init and ...) Flash ROMROM (ROM code) SRAM (boot strap)
  20. 20. 21 Customization Required for Embedded Linux ROM Code Boot Strap u-boot Linux Kernel Provided by chip manufacturer and available in chip Provided by chip manufacturer and available in chip u-boot project http://www.denx.de/wiki/U-Boot main line kernel source code https://www.kernel.org No change required No change required Customization Required as per the hardware Configuration, customization and extension are required rootfs Need to build a root file systems where all required software will be available Need to build a root file systems where all required software will be available Actions on Software ComponentsSoftware Components
  21. 21. 22 Boot Loader
  22. 22. 23 U-boot  Under Construction
  23. 23. 24 EFI  Under Construction
  24. 24. 25 Linux Kernel
  25. 25. LinuxKernel Hardware 26 Linux Kernel Components Veritical Camera Flash ROM (128MB) 16-bit Micro & 10-Bit ADC RAM (128MB) XY-axis Gyroscope WiFi Memory Manager Virtual Memory Manager Network Drivers Network Network Protocol Scheduler Process Management Character Devices Device Drivers Block/MTD Devices File System Virtual File System Processor (ARM) • Process Management • Memory Management • I/O Management (File system) • Network Management • Device Management
  26. 26. UserSpace 27 Kernel Space & User Space System Call (Linux Kernel Gateway) System Software, Middleware, Application Scheduler Block/MTD Devices Character Devices Network Drivers Memory Manager Process ManagementFile System Device Drivers NetworkVirtual Memory Manager Network Protocol Virtual File System KernelSpace (Privileged) Hardware Hardware • Kernel Space • User Space • System Calls – gateway to kernel from user space
  27. 27. 28 Kernel Space & User Space UserSpace System Calls (Kernel Gateway) System Software (glibc, libudev, ...) Hardware Hardware Kernel Kernel Space Middleware Network Services () Internet Services (Webkit) Graphics Services (Qt) Media Services (pulseaudio, gstreamer...)
  28. 28. KernelComponents 29 Kernel Code Organization Scheduler Process Manage- ment Character Devices Device Drivers Memory Manager Virtual Memory Manager Network Drivers Network Network Protocol Block/M TD Devices File System Virtual File System Hardware HardwareKernelCode ConfigurationConfiguration mmdrivers i2c mmc fs ext4 jffs2 net wireless ipv4 kernel sched timer
  29. 29. 30 Kernel Source Organization
  30. 30. KernelComponents 31 Kernel Configuration SchedulerBlock/MT D Devices Character Devices Network Drivers Memory Manager Process Manage- mentFile System Device Drivers NetworkVirtual Memory Manager Network Protocol Virtual File System Hardware (ARM, USB, SD, Flash...) Hardware .... CONFIG_ARM=y CONFIG_USB=y CONFIG_EXT4=y .... CONFIG_MTD=y • Configure kernel based on hardware and features required • Eliminate kernel components or features that are not required to optimize the image size
  31. 31. 32 Linux System Build Environment
  32. 32. 33 Build Environment Host (Development PC) Target • Cross Development Platform
  33. 33. 34 Build Tools gcc - Compiler, Assembler, Linker binutils - binary manipulation apps gdb - software debugger Host (Development PC)
  34. 34. 35 Tools Brief Note arm-linux-gnueabi-gcov Coverage testing tool arm-linux-gnueabi-gprof Display call graph profile arm-linux-gnueabi-nm List symbols from object files arm-linux-gnueabi-objcopy Copy and translate object files arm-linux-gnueabi-objdump Display information from object file arm-linux-gnueabi-readelf Display information from elf file arm-linux-gnueabi-strip Discard symbols from object files binutils for ARM architecture with EABI
  35. 35. 36 Tools Brief Note arm-linux-gnueabi-gcc C compiler arm-linux-gnueabi-cpp C++ compiler arm-linux-gnueabi-ld Linker & Loader arm-linux-gnueabi-as Assembler Complier tool chain for ARM architecture with EABI
  36. 36. 37 Building Blocks (ARM…) Host PC tool chain- Compiler, Assembler , Linker root file system source kernel source u-boot source Target bzImage u-boot.bin rootfs
  37. 37. 38 Embedded Linux Building Activities Kernel Configuration - Genrally configuration are supplied by the board supplier to start with, however some changes may require to meet some specification Board Specific Changes - Hardware configuration that depends on the user setting like device address, IRQ etc SoC Specific Changes - The kernel may have support to the SoC, however some configuration may be required Device Specific Drivers - If new devices are available and the driver is not present in the mainline kernel, driver for that device need to be devloped Kernel Optimization - Kernel may be optimized for space, some unnecessary modules or features may be disabled Kernel Debugging - Kernel provides may debugging features built int he kernel code, one need to enable those features int he kernel configuration
  38. 38. 39 Embedded Linux Components Build Process Get sources Configure and Apply patches Build
  39. 39. 40 Boot Loader Build
  40. 40. 41 U-boot Boot Loader Build hr@ed# wget https://www.kernel.org/pub/linux/kernel/v3.0/linux- 3.13.tar.xz hr@ed# tar xJvf linux-3.13.tar.xz hr@ed# cd linux-3.13 hr@ed# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- vexpress_defconfig hr@ed# make menuconfig hr@ed# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- vexpress_defconfig hr@ed# patch -l < [patch files] Get BusyBox source Configure & Patch Build
  41. 41. 42 See Your Freshly Baked u-boot Run… Run u-boot… # qemu-system-arm -M vexpress-a9 -m 256 M -nographic -kernel uboot.bin Run u-boot with qemu See your u- boot run
  42. 42. 43 Linux Kernel Build
  43. 43. 44 Kernel Configuration Linux Kernel Source Kernel Config (.config) (Drone) Kernel Config (.config) (Learning Thermostat) Kernel Image (zImage) - Drone Kernel Image (bzImage) - Learning Thermostat
  44. 44. 45 Kernel Configuration  Add Text
  45. 45. 46 Kernel Patch Linux Kernel Source (Base kernel) Kernel Patch (customization, extension on base kernel) Resultant Kernel Source Code Kernel Config (.config) (Drone) Resultant Kernel Source Code Kernel Build Image (bzImage/zImage) apply patch build
  46. 46. 47 Linux Kernel Build Linux Kernel Build hr@ed# wget https://www.kernel.org/pub/linux/kernel/v3.0/linux- 3.13.tar.xz hr@ed# tar xJvf linux-3.13.tar.xz hr@ed# cd linux-3.13 hr@ed# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- vexpress_defconfig hr@ed# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig hr@ed# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- vexpress_defconfig hr@ed# patch -l < [patch files] Get Kernel source Configure & Patch Build
  47. 47. 48 See Your Freshly Baked Kernel Run…  Add Text Run Linux kernel… # qemu-system-arm -M vexpress-a9 -m 256 M -nographic -kernel zImage Run Linux kernel with qemu See your Linux kernel run
  48. 48. 49 Root File System Build
  49. 49. 50 Root File System C Library (glibc.so) Kernelboot loader cp, mv, ls, modprobe, ... init and init script shell device filesprocfs, sysfs /bin, /usr, /lib, /sbin ... Minimal Root File System • C library (glibc) • Basic Linux commands • Linux Shell • Device files • procfs and sysfs • Init Script
  50. 50. 51 C Library glibc (POSIX interfaces) C standard library (string operations, ) folder pipestimer filesprocess signal memory manager mutexthread semaphore shared memory C Library (glibc) • Process management • Memory management • File Management • Process Synchronization
  51. 51. 52 Root File System - BusyBox  Update C Library (glibc.so) BusyBox
  52. 52. 53 BusyBox Build hr@ed# wget http://www.busybox.net/downloads/busybox-1.20.0.tar.bz2 hr@ed# tar xjf busybox-1.20.0.tar.bz2 hr@ed# cd busybox- busybox-1.20.0 hr@ed# $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- defconfig hr@ed# make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig hr@ed# make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- install Apply patch if any Get BusyBox source Configure & Patch Build Root File System with BusyBox
  53. 53. 54 Root File System Rootfs with BusyBox # cd _install # mkdir proc sys dev etc etc/init.d # mknod /dev/tty2 c 4 2 # mknod /dev/tty3 c 4 3 # mknod /dev/tty4 c 4 4 # chmod +x etc/init.d/rcS # find . | cpio -o --format=newc > ../rootfs.img #!/bin/sh #File : /etc/init.d/rcS mount -t proc none /proc mount -t sysfs none /sys /sbin/mdev -s Create folders Create device node Create rootfs cpio image Create /etc/init.d/ rcS
  54. 54. 55 Root File System Rootfs with busybox # qemu-system-arm -M vexpress-a9 -m 256M -kernel zImage -initrd rootfs.img - append "root=/dev/ram rdinit=/sbin/init" Run Linux with BusyBox rootfs # Welcome to myLinux See your Linux with BusyBox run

×