4-Advance Linux Kernel-Drivers-porting and Embedded -2017

Post on 16-Oct-2021

7 views 0 download

transcript

www.embeddedact.com 1 page out of 10

Course Duration: 5 days Pre-Requisites :

• Good ‘C’ programming skills. • Required knowledge Linux as a User

Course Objective:

• To get Kernel and User Space of Linux and related programming • Linux Advance Programming • To get real-world exposure to embedded Linux using different demoboards–ARMforLabs

• To develop an application to run on an embedded Linux system • To understand what is required to set-up a Linux cross development

environment • To understand the different approaches to making Linux “realtime” Delegates

will learn: • How to configure a standard Linux kernel for use in a cross development

system. • The steps to write, compile, download and debug an embedded Linux

application with real hardware. • How threaded applications fit into Linux. • How drivers work in x86 and embedded environment.

Course Outline Kernel Internals

• Introduction to Kernel - History of Linux - Types of Kernel - The Linux kernel - Kernel Facilities

www.embeddedact.com 2 page out of 10

- Kernel Architecture - Kernel Version Numbers - Configure, Compile Kernel

• The File System

- Virtual File system & its role - Files associated with a process - System Calls

• Process management

- Process Defined - Process Descriptor Structures in the kernel - Process States - Process Scheduling - Process Creation - System calls related to process management

• Memory Management

- malloc, calloc, alloca, free - Demand Paging defined - Process Organization in Memory - Virtual Memory Management - Address Translation and page fault handling - Buddy System Algorithm - Slab Allocator - Swapping Memory Areas - Memory Mapping - Block Device Caching

• Interrupts - Conceptual Understanding About Interrupts Interrupt Handlers Softirqs Tasklets Work Queues

• Device Drivers – Conceptual understanding

Character Device Drivers Block Device Driers Network Device Drivers

• Kernel Configuration and Compilation - Kernel Building System - Patching the Kernel - Kernel Configuration - Compiling the Linux Kernel

www.embeddedact.com 3 page out of 10

• Kernel Parameters - Build-Time Parameters - Boot-Time Parameters - Run-Time Parameters

• Boot Process - understanding Power ON to login prompt process

- BIOS Level - Boot Loader

§ Setup, startup_32 functions § Available Bootloaders – GRUB, UBoot, etc. § Role of a Bootloader § Bootloader Phase

- Kernel Initialisation Phase § The start_kernel() function

- System Initialisation Phase § Understanding Runlevels § Various initialization scripts & customizing them § Kernel Command-Line Boot Parameters

Linux Advanced Programming

• Arguments, the environment, and popular system functions

- Arguments to a program. - Retrieving information from the environment. - Discovering the date and time - Getting system information.

• File I/O - Library functions and system calls for I/O - Getting file status information with stat() - Processing directories and directory entries.

• Shell Commands & Shell Scripting - Basic Shell commands - Bash Shell Essentials

• Creating Makefiles - Makefile basics - Creating make files for single or multiple source files project

• Creating Lilbraries

- Creating Static Library - Creating Shared Library

• Multi Process Programming - Creating child processes - fork(). vfork(), exec() - Parent synchronization with child

www.embeddedact.com 4 page out of 10

• Multi Thread Programming

- Creating multiple threads - Parent synchronization with other Threads

• Inter Process Communication - Pipes, FIFO's, - Signals - System-V IPC's - Message queues - Shared memory - Semaphores

• Introduction to Sockets - An Overview - System calls related to TCP and UDP sockets - Using Wireshark etc tool for network sniffing

• Network Programming - TCP Server Client Programming - UDP Server Client Programming - Lab exercises

• Programming & Debugging Tools

- Debugging and Analysis Tools - strace : Tracing System calls - ltrace : Tracing Library calls - Using gdb and ddd utilities - Core Dump Analysis etc

• Code checkers, memory checkers, profilers

Embedded Linux System Development

• Introduction to Embedded Linux - What is Embedded System? - Anatomy of an Embedded System - Why Linux? - Is Linux Real-Time Enough? - The Status of Embedded Linux Today - Which Embedded Linux Distribution to Choose? - Embedded Linux Architecture

• Basic requirements for Embedded Linux Product Development

- The four basic elements: toolchain, bootloader, kernel, root file system - Configuration, compilation and cross-compiling

www.embeddedact.com 5 page out of 10

• Building Development Environment ( Obisense ) - Toolchain installation - Cross compilation using Toolchain

• Target & Host Setup

• Setting Up Networking Services

- Network Settings § Static and Dynamic IP addresses § Subnet mask

- loading files using TFTP, HTTP, FTP etc.

• Bootloader commands and usage

- Getting familiar with bootloader commands - Downloading kernel images and RootFS on Target board.

• Loading RootFS in Platfrom by various techniques -

- Configuring TFTP and downloading kernel image over TFTP. - Configuring NFS and using rootfs over NFS. - Using SD-Card for rootfs. - Using USB for rootfs.

• Building an Embedded File System from Scratch -

- Creating a minimal root file-system using Busybox - Creating a RAM disk image

• Intro to Building Own Embedded Linux Distribution - - Buildroot - Scratchbox - OpenEmbedded - Crosstool - Angstrom – Narcissus

• Kernel Configuration and Compilation

- Kernel Building System - Patching the Kernel - Kernel Configuration for Embedded Systems Settings (Porting) - Cross-compiling the Linux Kernel

- Booting Linux

- The Linux boot sequence - boot-loaders : U-boot - System Initialization Scripts

- Bring up X11 (X-Windows) on Embedded Platform (GUI) - Loading various RootFS (Distributions) in platform

• Angstrom, Ubuntu, Fedora etc. RootFS

www.embeddedact.com 6 page out of 10

- Board Bring-ups of following Embedded Linux Hardware Platforms • Different Boards Used for differentiation and initialization • Friendly ARM 2440 (main board used)

• Raspberry Pi (intro and demonstration)

www.embeddedact.com 7 page out of 10

• Beaglebone Black (intro and demonstration)

- Embedded Apps & Device Drivers Labs on Embedded Linux Boards • Writing Device Drivers & Applications for Embedded Platforms • Accessing GPIOs • Interfacing LED, Switch, Camera, Seven Segment Display • Installing Web Server on Embedded Platform

Porting Issues in Linux

• Linux Porting Issues • Kernel Compilation and Architecture Specific Issues • Cross Compilation • Building Application in to Kernel • Other issues

Linux Device Drivers

• An introduction to device drivers

- User space vs Kernel space - Kernel Architecture or Model - Splitting the kernel - Kernel modules - Kernel Module vs Applications - Role of the Device Drivers - Classes of devices and modules

www.embeddedact.com 8 page out of 10

• Kernel Module Programming Basics

- Modules Defined - Data Type in the Kernel - Version dependency - Building and Running Modules - Types of Modules in the kernel - Writing Your first kernel module - Module Related Commands - Statically linked vs Dynamically linked drivers/modules - The kernel symbol table - Exporting symbols from modules - Module Parameters - Lab exercises for above mentioned topics

• Kernel Debugging Techniques

- Kernel Debugging: dmesg, printk - Lab exercises for above mentioned topics

• Accessing Hardware Mechanisms

- System Memory - Device Memory - I/O Ports - I/O ports vs. memory mapping - Allocating and mapping I/O space - Functions for reading and writing I/O ports - Side effects and compiler optimization - Accessing hardware from User Space - Example: the Parallel Port - Driver example - Barriers - User-Mode Access to Devices

§ open, close, read, write § ioctl § ioperm, iopl, inb, outb § mmap, munmap

• The proc file system programming

- Using /proc - Creating proc file system entries - Registration - Reading from /proc - Writing to /proc

- Lab exercises

• Hardware and Interrupt Handling - Installing and implementing an interrupt handler

www.embeddedact.com 9 page out of 10

- Restrictions of kernel code running in interrupt context - IRQs & their Registration - IRQ Handling & Control - Top & Bottom Halves - Enabling and Disabling Interrupts - Lab exercises

• Tasklets and Bottom halves

- Task queues - Lab exercises

• Kernel Threads - Lab exercises

• Sleep and wakeup (wait queues)

• Memory Management - Allocating Memory - Accessing Memory - Get Some Space (kmalloc()), kfree(), various flags - Get Some Pages (get_free_page()) - Get Some Virtual Memory - vmalloc() - Get Some Boot-time Space

• Concurrency and Race Conditions

- Combating Race Conditions - Atomic Operations - Semaphores - Spin Locks

• Time, Delays and Deferred Work

- Kernel Timers - Timer handling - HZ and Jiffies - Time of Day - Delayed Execution - Kernel Timers - Current time

• The Linux Device Model

• Character Device Drivers

- Registering a character device driver - The file structure

- Major and minor numbers - Character Device Methods open(), release(), read(), write() - Data Transfers between User Process and Driver

www.embeddedact.com 10 page out of 10

§ copy_from_user(), copy_to_user() - Making a Device File -Memory Access in Kernel Space - Programming with ioctl( ), mmap() - devfs / lseek /ioctl

- Lab exercises

• Writing various Character Drivers - Memory Based Driver - IO PORT (Hardware) Based Driver

• Programming with ioctl( )

- writing device driver with ioctl() - Adding ioctl’s in an existing device driver - Lab exercises

• Netlink socket interface

- point to point, multicast and broadcast - UDP, TCP and Raw sockets - Writed kernel module and userspace applilcations using Netlink sockets - Lab exercises

• Network Drivers

- The net_device structure in detail - Packet transmission - Packet reception - Simulating a network device - Lab exercises

• Adding a Driver to the Kernel Tree

• Sample Hardware based device driver projects

* * * * * * * *