Implementation of Embedded OS Lab3 Linux Kernel Modules.

Slides:



Advertisements
Similar presentations
DEVICE DRIVER VINOD KAMATH CS691X PROJECT WORK. Introduction How to write/install device drivers Systems, Kernel Programming Character, Block and Network.
Advertisements

Linux device-driver issues
Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
Sogang University Advanced Operating Systems (Linux Device Drivers) Advanced Operating Systems (Linux Device Drivers) Sang Gue Oh, Ph.D.
Lecture for Lab 3, Exp1 of EE505 (Developing Device Driver) T.A. Chulmin Kim CoreLab. Mar, 11, 2011 [XenSchedulerPaper_Hotcloud-commits] r21 - /
Computer System Laboratory
Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1.
52 Advanced Operating Systems Writing Device Drivers.
Embedded Systems Programming Writing Device Drivers.
How to make a pseudo-file As a follow-up to our first lab, we examine the steps needed to create our own ‘/proc’ file.
Downloading to Altera Nios Development Kit CSCE 488 Witawas Srisa-an.
Tutorial and Demos on Linux Virtual Machine
Computer System Laboratory
Intel Do-It-Yourself Challenge Hello World with the Arduino IDE Nicolas Vailliet Intel.
COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards.
Operating Systems Sameer Mahajan. Overview Process management Interrupts Memory management File system Device drivers Networking (TCP/IP, UDP) Security.
M. Muztaba Fuad Advanced Operating System Project Device Drivers.
COMPUTER SYSTEM LABORATORY Lab4 - Bootloader. Lab 4 Experimental Goal Learn how to build U-Boot bootloader for PXA /10/8/ 142.
Kernel module programming Nezer J. Zaidenberg. reference This guide is built on top of The Linux Kernel Module Programming Guide The guide is available.
Part 1 Using the ARM board And start working with C Tutorial 5 and 6
Operating System Program 5 I/O System DMA Device Driver.
Lab 3 Department of Computer Science and Information Engineering National Taiwan University Lab3 - Cross Tools 2014/10/7/ 20 1.
Bolin Hsu CS6900 Independent study Bolin Hsu
COMPUTER SYSTEM LABORATORY Lab10 - Sensor II. Lab 10 Experimental Goal Learn how to write programs on the PTK development board (STM32F207). 2013/11/19/
For OS Experiments. What Do We Need? A Computer &
Computer System Laboratory
Lab 11 Department of Computer Science and Information Engineering National Taiwan University Lab11 - Porting 2014/12/9/ 26 1.
COMP 3438 – Part I - Lecture 4 Introduction to Device Drivers Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Lab 1 Department of Computer Science and Information Engineering National Taiwan University Lab1 - Sensor 2014/9/23/ 13 1.
Lab 10 Department of Computer Science and Information Engineering National Taiwan University Lab10 – Debugging II 2014/12/2 1 /16.
COMPUTER SYSTEM LABORATORY Lab6 - Root Filesystem.
Kernel Modules. Kernel Module Pieces of code that can be loaded and unloaded into the kernel upon demand. Compiled as an independent program With appropriate.
LINUX System : Lecture 7 Bong-Soo Sohn Lecture notes acknowledgement : The design of UNIX Operating System.
Lab 14 Department of Computer Science and Information Engineering National Taiwan University Lab14 – Camera 2014/12/30 1 /14.
Lab 13 Department of Computer Science and Information Engineering National Taiwan University Lab13 – Interrupt + Timer 2014/12/23 1 /16.
Kernel module programming Nezer J. Zaidenberg. reference This guide is built on top of The Linux Kernel Module Programming Guide The guide is available.
LOGO System Call. Introduction System call is the mechanism used by an application program to request service from the OS. Users use it to communicate.
Interfacing Device Drivers with the Kernel
Implementation of Embedded OS Lab4 Cortex-M3 Programming.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
Implementation of Embedded OS Lab5 Real-time Programming on μ C/OS-III.
Implementation of Embedded OS Lab3 Porting μC/OS-II.
COMP 3438 – Part I - Lecture 5 Character Device Drivers
Lab 5 Department of Computer Science and Information Engineering National Taiwan University Lab5 – Bootloader + OS Kernel 2015/10/27/ 25 1.
Lab 8 Department of Computer Science and Information Engineering National Taiwan University Lab8 - Root Filesystem 2015/11/10/ 22 1.
1 The File System. 2 Linux File System Linux supports 15 file systems –ext, ext2, xia, minix, umsdos, msdos, vfat, proc, smb, ncp, iso9660, sysv, hpfs,
Implementation of Embedded OS
Lab 5 Department of Computer Science and Information Engineering National Taiwan University Lab5 - OS Kernel 2014/10/21/ 16 1.
1 Intro to Kernel Modules and /proc Sarah Diesburg CS 3430 Operating Systems.
Finish up OS topics Group plans. Today Finish up and review Linux device driver stuff – Walk example again – See how it all goes together – Discuss talking.
Lecture 3 Module Programming and Device Driver (Homework#1 included) Kyu Ho Park Sept. 15, 2015.
Virtual Memory Mohammad H. Mofrad February 23, 2016
Implementation of Embedded OS
Computer System Laboratory
Lecture 3 Module Programming and Device Driver (Homework#1 included)
Linux Kernel Module Programming
Computer System Laboratory
Implementation of Embedded OS
Computer System Laboratory
Linux Kernel Driver.
Intro to Kernel Modules and /proc
chapter 2 - Hello World Model
CS 6560 Operating System Design
Lab 4 Kernel Module Operating System Lab.
CS 6560 Operating System Design Kernel Loadable Modules
LINUX System : Lecture 7 Lecture notes acknowledgement : The design of UNIX Operating System.
Implementation of Embedded OS
Computer System Laboratory
Computer System Laboratory
Presentation transcript:

Implementation of Embedded OS Lab3 Linux Kernel Modules

Lab3 Goal  Learn how to write Linux kernel modules. 2014/4/8 / 132 * source: The Linux Device Drivers, 3rd

Lab3 Environment  Host System  Windows XP  Build System  VirtualBox + Ubuntu 8.04  Target System  Creator XScale PXA270  Software  Drivers for Creator PXA270 LCD, 8-bit LED lamps, and 4-digit 7-segment LED.  You can download them from RSWiki IEOS Course SoftwareRSWiki IEOS Course Software 2014/4/8 / 133

Lab3 First Step 2014/4/8 / 134  Finish lab2-kernel first.  Please make sure you have modified the flash partition in Linux and flashed the correct file system (20MB).

Lab3 Linux Device Drivers 2014/4/8 / 135  Three major types  Character device driver  Block device driver  Network device driver  Other types  USB driver  PCI driver  …… User Mode Kernel Mode Hardware Application Physical Device System Call Interface Virtual File System (VFS) Buffer Cache Network Subsystem Network Subsystem Character Device Driver Block Device Driver Block Device Driver Network Device Driver Network Device Driver Device Interface

Lab3 A Simple Kernel Module 2014/4/8 / 136 #include /* Needed by all modules */ #include /* Needed for KERN_INFO */ #include /* Needed for the macros */ static int __init init_hello(void) { printk(KERN_INFO "Hello, world\n"); return 0; } static void __exit cleanup_hello(void) { printk(KERN_INFO "Goodbye, world\n"); } module_init(init_hello); module_exit(cleanup_hello); MODULE_LICENSE("GPL"); /* License type of this module */ MODULE_AUTHOR("DRIVER_AUTHOR"); /* Who wrote this module */ MODULE_DESCRIPTION("DRIVER_DESC"); /* What does this module do */ initial function cleanup function declaration of initial/cleanup functions

Lab3 Makefile for Kernel Modules 2014/4/8 / 137  Suppose the filename of the module source is hello.c.  Write a Makefile like this:  Type “ make ” to compile the module.  Then transfer the output file hello.ko to the target board.  Type “ insmod hello.ko ” to load the module and “ rmmod hello ” to remove the module. obj-m += hello.o all: make -C M=$(PWD) modules clean: make -C M=$(PWD) clean

Lab3 Module Parameters 2014/4/8 / 138  You can define module parameters as follows.  You can pass the argument when loading the module as follows.  $ insmod hello.ko myint=123  Further information about module parameters can be found on the websites listed in References. /* Needed for the macro module_param */ #include static int myint = 0;/* define a integer variable */ /* declare the variable as a module parameter */ module_param(myint, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);

Lab3 Virtual File System (VFS) (1/2) 2014/4/8 / 139  User processes can communicate with device drivers through several ways, and VFS is the most common one.  A device driver can define a set of file operations including open, read, write, ioctl, etc., and associate it with an device number (inode). devno = MKDEV(MAJOR_NUM, MINOR_NUM); register_chrdev_region(devno, MAX_MINORS, MODULE_NAME)); cdev_init(pcdev, &fops); cdev_add(pcdev, devno, MAX_MINORS);

Lab3 Virtual File System (VFS) (2/2) 2014/4/8 / 1310  A process can use ordinary file I/O functions to access the device.  First, create the corresponding file at /dev.  $ mknod /dev/demo c  In lab2, the major number is 120 and the minor number is 0.  Then, open the file /dev/demo and use the function ioctl to control the device.

Lab3 An Example of the User Programs 2014/4/8 / 1311  Please use the cross compiler to compile this program. #include #include "creator_pxa270_lcd.h" int main() { int fd; if((fd = open("/dev/demo", O_WRONLY)) < 0){ perror("couldn't open /dev/demo"); return 1; } ioctl(fd, _7SEG_IOCTL_ON, 0); close(fd); return 0; }

Lab3 Lab Requirements 2014/4/8 / 1312  Compile the kernel module.  Write a Makefile for the driver provided.  Compile the driver as a module and load it into Linux.  Implement a stopwatch app.  The resolution should be in 0.1 seconds.  The value of the counter should be display on the 4-digit 7- segment LED in decimal form.  It can be started, suspended, resumed, and reset by pressing the buttons of the keypad.  Please refer to the reference PDFs available on our course website if you have any questions about the driver.

Lab3 References 2014/4/8 / 1313  Linux Device Drivers, Third Edition   The Linux Kernel Module Programming Guide 