Demystifying Linux Device Drivers Workshop, Report

The "Demystifying Linux Device Drivers, Workshop", was organized by Zilogic Systems on December 15-16 in Chennai. The workshop was done using our in-house hardware: ZKit-ARM-VF51 and DietIO. The ZKit-ARM-VF51 is the baseboard, powered by a Vybrid VF5xx SoC. The DietIO is the add-on board that has variety of devices for teaching and learning embedded systems and device drivers.

The Training Team

The training team consisted of Ashok Kumar, Babu, Deepak, Fadhel Habeeb, Joses Paul, Raashid, Vijay Kumar (in alphabetical order).


The Workshop was targeted for developers who are familiar with Linux in embedded systems, and would like to explore the world of devices and drivers. About 70 people from various organizations, including Visteon, Sasken Technologies, e-con Systems, VVDN Technologies, Niagra Networks and Gigamon attended the workshop.

Day 1, Forenoon: Device Drivers, Scratching the surface

The workshop started with an introduction on visualizing how the kernel and device drivers work. Vijay started the first session titled "Demystifying the MMU" in which he presented the necessity of a MMU and the problem of Protection, Fragmentation and supporting paging & relocation. The next session was given by Deepak on "System Call Internals" in which he illustrated the system call sequence and also discussed about the Address Space Isolation, Process Switching & Trap Calls, followed by which we had a quick discussion on the reasons behind the 3G/1G Address Space Split.

Now that we had an insight on the vicinity of device drivers it was time to get introduced to the art of writing device drivers. Vijay started off the next session by introducing driver APIs and discussed about File IO & Device IO. Vijay then explained how device files work, major number, minor number and how the kernel uses these numbers to associate and invoke the respective driver required by the device. Later he also demystified how mouse input works and the device files associated with it.

Day 1, Afternoon: Writing Modules & Building Kernel

Raashid started this session by briefing about the Linux Kernel. He illustrated the Kernel Versioning Scheme & Kernel Development Process. He also instructed the procedure to cross-compile the kernel for ARM. Now that the basics of drivers were covered, perhaps, it was time to write build and test our first module, Hello World Kernel Module.

Later that evening, Deepak explained GPIO Subsystem - gpiochip driver & GPIO controller, which is a hardware which provides register interface using which the pin can be accessed. He also discussed various terminologies associated with GPIO such as Direction, Ports, Pins, GPIO Numbering in Linux. Deepak then moved on to explain how GPIOs can be used to sense keys. At the end of the session, participants wrote, built and tested their driver to access RGB LED and read input from keys on the target board.

The last session for the day was about understanding the deferred execution, this was explained by writing a module to blink a led with a specific delay. Deepak gave an insight on the implementation of delay, we also had a quick discussion on Jiffy which is a counter variable which contains the no. of interrupts or ticks that have occurred since boot-up. Deepak then went on to explain the concept of deferring in kernel, one such typical infrastructure used to achieve this was "Workqueues". He then explained the implementation of workqueues for blinking LEDs. Later, Deepak also explained about threads in kernel, the first thread and the worker threads. The session then concluded with an hands-on exercise to access GPIO keys & LED with workqueue implementation.

Day 2, Forenoon: Writing Drivers for Devices

It is indeed trivial to completely understand a device to write a sane driver for the same. Deepak started this session by explaining the Linux I2C Subsystem. He also illustrated the I2C transactions and constituents of a typical I2C Controller. Deepak then showed the design of I2C in the target board which was then used to write & test the driver for I2C devices during the try-outs. The session concluded with a discussion on the USB subsystem which is simillar to the I2C subsystem model.

The next session was about Character Device Drivers which consisted of writing Y Driver, Echo Driver and I2C LCD Driver. Vijay explained the APIs for Character Driver Registration, Vijay also listed what could go wrong while performing read write operations from kernel space. Vijay then moved on to explain the Echo Driver and the need for kernel FIFO, defining kfifo, adding & clearing data form kfifo. This session ended with a try-out exercise to write a driver to access the on-board I2C LCD.

Day 2, Afternoon: Dive Deeper into Device Drivers.

This session was about handling, sharing, multiplexing, triggering, cascading and debugging interrupts. Followed by which we discussed about implementing Blocking IO, Process States. This session concluded with a quick discussion on the infamous Thundering Herd Problem. Deepak then explained the concept of concurrency and enlisted the source of concurrency, later he also explained locking and various locking schemes such as Mutex, Spin-lock and Semaphores. He also addressed the common problems associated with each of these locking mechanisms. Deepak concluded the session by giving an insight on choosing the right locking scheme. Later that evening we also discussed about Hotplugging, Limitations of Non-Hotplug Busses, Kernel Module Autoloading, Modalias, Depmod and Role of UDev.



We would like to thank all the participants and participating organizations, for all the enthusiasm. Stay tuned, for more exciting workshops, you can sign-up on our enquiry page, to get notifications about upcoming workshops.