Character Device Drivers in deep
What you'll learn
- Write character device driver from scratch
- Understand the various file operations provided by character driver
Requirements
- Should be able to write/compile/load/unload Hello World Linux Kernel Modules
Description
Updated on Oct 10: Added Downloads section
What will you learn from this course?
Introduction to character drivers
What is device number and device file
Allocating device number - statically and dynamically
Creating device file - Manually(mknod) and automatically (udev)
Registering character device and its file operation with Kernel
Copying data from user space to kernel space and vice versa
Understanding the various structures - struct file and struct inode
Implementation of open, release, read, write, llseek, ioctl file operations
How to create multiple device nodes and add support for private data
Flow of write system call from kernel system call entry point to driver write file operations
Handling all the error cases in ioctl implementation
Sending a signal to user space from kernel space
Various access control mechanisms and capabilities
Misc Driver
API's covered in this course:
MAJOR
MINOR
MKDEV
register_chrdev_region
alloc_chrdev_region
class_create
device_create
class_destroy
device_destroy
unregister_chrdev_region
imajor
iminor
copy_from_user
copy_to_user
put_user
get_user
print_dev_t
format_dev_t
strnlen_user
container_of
access_ok
Commands used in this course:
mknod
udevadm monitor
Who this course is for:
- Developers interested in learning Linux Kernel Programming
Course content
- Preview03:36
- Preview02:28
- Preview00:41
- Preview03:32
- 01:58How to choose a device number
- 00:50Data type for device number dev_t
- 03:27Example of MAJOR,MINOR,MKDEV macros
- 01:03/proc/devices file
- 01:36Static Allocation of Device Numbers
- 02:26Example of static allocation of device numbers
- 01:58Test cases on Previous Example
- Preview01:39
- 01:36What happens if i try to register same name
- 03:27Registering Maximum Minor Numbers
- Preview03:02
- 00:48Dynamic Allocation of Device Number
- 01:54Example of dynamic allocation of device number
- 04:12Calling alloc_chrdev_region in loop
- 03:54Manual Device Node Creation
- 04:02Automatic Device Node Creation - class_create
- 02:48Automatic Device Node Creation - device_create
- 01:54Example of automatic device node creation
- 11 questionsQuiz 1
Instructor
I have been working on Linux for more than 7 years. I have seen many people still lack their skills on Linux. So, i am working on courses for Linux which will make them Learn Linux in an easy way. The agenda of my courses will be more practical and less theoretical. Show more examples and you will easily grab the concepts.
Order of Learning
1. Learn Linux User Space Debugging
2. Learn Linux Kernel Programming
3. Character Device Drivers in Deep
4. Memory management in Linux Kernel
5. Synchronization in Linux Kernel Programming
6. Linux Kernel Development Model and Compilation
7. Linux Device Drivers - Communicating with Hardware
8. Interrupts and Bottom Halves in Linux Kernel
9. System calls in deep
10. Timing Subsystem in deep
11. Embedded Linux using Yocto
12. Embedded Linux using Yocto Part 2
13. Embedded Linux using Yocto Part 3
14. Embedded Linux using Yocto Part 4
15. Testing Linux Kernel
16. Debugging Linux kernel in deep - Part 1
17. Debugging Linux kernel in deep - Part 2