Innovation... driven by intelligence and logic

Pre-requisite for Device Driver Development

Here is a comprehensive checklist of prerequisites you need before you start typing code for a Linux character device driver. Since you are starting "from scratch," having these foundations solid will save you hours of debugging later.

1. Technical Skill Set

You don't need to be a kernel wizard yet, but you must be comfortable with these specific areas of C and OS theory:

Linux System Administration(Basic)...

Shell Scripting using Bash...

Advanced C Programming...

Pointers: You must be very comfortable with pointers, including pointers to functions. The kernel relies heavily on passing functions as arguments (callbacks) to handle hardware events.
Bitwise Operations: Setting, clearing, and testing specific bits (|, &, ^, <<, >>) is daily life when talking to hardware registers.
Structures: The kernel uses massive structures (like struct file_operations) to define driver behavior.

• Operating System Concepts:

Kernel Space vs. User Space: Understand that your driver runs in Kernel Space. If your driver crashes, the whole system might crash (unlike a regular app).
Concurrency: Understanding Race Conditions is critical. Since hardware and user apps can try to access your driver at the same time, you need to understand the concept of locking (Mutexes, Spinlocks).

2. Development Environment Setup

You cannot compile a kernel module with just a standard C compiler setup. You need specific kernel build artifacts.

• A Running Linux System:

This can be a physical machine, a Dual Boot, or a Virtual Machine (VirtualBox/VMware). A VM is highly recommended for beginners so you don't freeze your main computer if the driver bugs out.

• Kernel Headers:

This is the most common missing piece. You need the header files that correspond exactly to the kernel currently running on your machine.
Command to check kernel version: uname -r
Command to install (Ubuntu/Debian): sudo apt-get install linux-headers-$(uname -r)
Command to install (RHEL/CentOS): sudo yum install kernel-devel

• Build Essentials:

You need gcc (Compiler) and make (Build automation tool).
Command: sudo apt-get install build-essential

3. The "Un-Learning" (Conceptual Prerequisites)

Writing a driver requires you to forget some things you use in standard application programming:
No libc: You cannot use standard C library functions like printf(), malloc(), or scanf().
Replacement: You will use kernel equivalents like printk() and kmalloc().
No main(): A driver does not start at main(). It works on an Event-Driven model.
It has an Init function (called when loaded) and an Exit function (called when unloaded). In between, it sits idle waiting for the OS or Hardware to ask it to do something.
Floating Point: You generally cannot use floating-point math (decimals) in the kernel. It's strictly integer arithmetic for performance and safety.

4. Hardware Knowledge (Optional but Helpful)

If you are writing a driver for a physical device (like a sensor), you need its Datasheet. However, for this training, we will likely write a "Loopback" or "Ramdisk" driver first, which simulates a hardware device using system RAM, so no physical hardware is required yet.

EmbLogic™ is an ISO 9001:2008(QMS) (Quality Management System) Certified Company.
Go to Top ^