STATIC.x

Kunal Dawn


Leave a comment

Writing a Simple USB Driver

Give your Linux box a multicolored light you can see from across the room, and learn how to write a simple driver for the next piece of hardware you want to hook up.

Since this column began, it has discussed how a Linux driver writer can create various types of kernel drivers, by explaining the different kernel driver interfaces including TTY, serial, I2C and the driver core. It is time to move on now and focus on writing real drivers for real hardware. We start by explaining how to determine what kind of kernel driver interface to use, tricks to help figure out how the hardware actually works and a lot of other real-world knowledge. Continue reading


Leave a comment

Writing device drivers in Linux: A brief tutorial

“Do you pine for the nice days of Minix-1.1, when men were men and wrote their own device drivers?”

Linus Torvalds

Pre-requisites

In order to develop Linux device drivers, it is necessary to have an understanding of the following:

  • C programming. Some in-depth knowledge of C programming is needed, like pointer usage, bit manipulating functions, etc.
  • Microprocessor programming. It is necessary to know how microcomputers work internally: memory addressing, interrupts, etc. All of these concepts should be familiar to an assembler programmer.

There are several different devices in Linux. For simplicity, this brief tutorial will only cover type chardevices loaded as modules. Kernel 2.6.x will be used (in particular, kernel 2.6.8 under Debian Sarge, which is now Debian Stable). Continue reading


Leave a comment

Device Drivers, Part 17: Module Interactions

As Shweta and Pugs gear up for their final semester’s project on Linux drivers, they’re closing in on some final titbits of technical romancing. This mainly includes the various communications with a Linux module (dynamically loadable and unloadable driver) like accessing its variables, calling its functions, and passing parameters to it. Continue reading


Leave a comment

Device Drivers, Part 16: Kernel Window — Peeping through /proc

After many months, Shweta and Pugs got together for some peaceful technical romancing. All through, they had been using all kinds of kernel windows, especially through the /proc virtual filesystem (usingcat), to help them decode various details of Linux device drivers. Here’s a non-exhaustive summary listing: Continue reading


Leave a comment

Device Drivers, Part 15: Disk on RAM — Playing with Block Drivers

After a delicious lunch, theory makes the audience sleepy. So, let’s start with the code itself.

Disk On RAM source code

Let’s us create a directory called DiskOnRAM which holds the following six files — three ‘C’ source files, two ‘C’ headers, and one Makefile.

partition.h

1
2
3
4
5
6
7
#ifndef PARTITION_H
#define PARTITION_H
#include <linux/types.h>
extern void copy_mbr_n_br(u8 *disk);
#endif

Continue reading


1 Comment

Device Drivers, Part 14: A Dive Inside the Hard Disk for Understanding Partitions

“Doesn’t it sound like a mechanical engineering subject: The design of the hard disk?” questioned Shweta. “Yes, it does. But understanding it gives us an insight into its programming aspect,” reasoned Pugs, while waiting for the commencement of the seminar on storage systems. Continue reading


Leave a comment

Device Drivers, Part 13: Data Transfer to and from USB Devices

Pugs continued, “To answer your question about how a driver selectively registers or skips a particular interface of a USB device, you need to understand the significance of the return value of the probe() callback.” Note that the USB core would invoke probe for all the interfaces of a detected device, except the ones which are already registered — thus, while doing it for the first time, it will probe for all interfaces. Now, if the probe returns 0, it means the driver has registered for that interface. Returning an error code indicates not registering for it. That’s all. “That was simple,” commented Shweta. Continue reading