Questions tagged [linux-device-driver]

Device drivers take on a special role in the Linux kernel. They are distinct programmatically abstracted “black boxes” that make a particular piece of hardware respond to a well-defined internal programming interface; they hide completely the details of how the device works.

User activities are performed by means of a set of standardized calls that are independent of the specific driver. Mapping those calls to device-specific operations that act on real hardware is the role of the device driver. This programming interface is such that drivers can be built separately from the rest of the kernel and “plugged in” at runtime when needed. This modularity makes Linux device drivers easy to write, to the point that there are now thousands of them available.

There are a number of reasons to be interested in the writing of Linux device drivers.

  • The rate at which new hardware becomes available (and obsolete!) alone guarantees that driver writers will be busy for the foreseeable future.

  • Individuals may need to know about drivers in order to gain access to a particular device that is of interest to them.

  • Hardware vendors, by making a Linux device driver available for their products, can add the large and growing Linux user-base to their potential markets.

The open-source nature of the Linux system means that if the driver writer wishes, the source to a driver can be quickly disseminated to millions of users.

Source -

  1. Linux Device Drivers 3rd edition

  2. Linux module programming guide

4991 questions
14
votes
3 answers

Linux kernel interrupt handler mutex protection?

Do I need to protect my interrupt handler being called many times for the same interrupt? Given the following code, I am not sure on the system calls I should make. I am getting rare, random dead-locks with this current implementation :- void…
Ian Vaughan
  • 20,211
  • 13
  • 59
  • 79
14
votes
1 answer

Mmap DMA memory uncached: "map pfn ram range req uncached-minus got write-back"

I am mapping DMA coherent memory from kernel to user space. At user level I use mmap() and in kernel driver I use dma_alloc_coherent() and afterwards remap_pfn_range() to remap the pages. This basically works as I can write data to the mapped area…
Gbo
  • 161
  • 1
  • 5
14
votes
1 answer

How to establish adb connection over USB between two PCs

Summary (What we've done, what we've tried): Basically, the aim is to establish an adb protocol via usb between two linux computers by using adb source codes. Envinronment is Ubuntu 16.0.4. There's android-tools-adbd (adb daemon) package ready for…
Burak Day
  • 907
  • 14
  • 28
14
votes
3 answers

Why do we need to call poll_wait in poll?

In LDD3, i saw such codes static unsigned int scull_p_poll(struct file *filp, poll_table *wait) { struct scull_pipe *dev = filp->private_data; unsigned int mask = 0; /* * The buffer is circular; it is considered full * if "wp"…
demonguy
  • 1,977
  • 5
  • 22
  • 34
14
votes
2 answers

What is the need of having both System.map file and /proc/kallsyms?

I just want to know the difference between System.map file and /proc/kallsyms. I am using Linux 3.16 generic kernel. I know that both are the kernel symbol table.. When I did a compare on this files, both are having the same content. So what is the…
md.jamal
  • 4,067
  • 8
  • 45
  • 108
14
votes
3 answers

What is the minimum amount of RAM required to run Linux kernel on an Embedded device?

What is the minimum amount of RAM required to run Linux kernel on an Embedded device? In Linux-0.11 for 80x86, the minimum RAM required was 2MB to load the kernel data structures and interrupt vectors. How much is the minimum needed RAM for present…
manav m-n
  • 11,136
  • 23
  • 74
  • 97
14
votes
1 answer

Detect the presence of a device when it's hot plugged in Linux

I am running the SPI code on the panda board and I want to know which function in the code is responsible for detecting the device when it's hot plugged. Can somebody with the background of embedded systems, Linux device drivers and/or spi please…
Sagar Jain
  • 7,475
  • 12
  • 47
  • 83
14
votes
3 answers

I2C Driver in Linux

I am aware of I2C in a very basic level which relies inside linux kernel, but no clue to implement a basic I2C driver. Trying to moving for a start in I2C device driver. could you please suggest any beginner tutorial with source code mapping !!
San
  • 905
  • 3
  • 16
  • 33
14
votes
2 answers

Using in user programs, or in driver module code...does it matter?

I'm developing a device driver module and associated user libraries to handle the ioctl() calls. The library takes the pertinent info and puts it into a struct, which gets passed into the driver module and unpacked there and then dealt with (I'm…
Rob
  • 801
  • 2
  • 9
  • 16
14
votes
2 answers

Difference between reading from /dev/block/mmcblk0 and /dev/block/mmcblk0p1

Reading from /dev/block/mmcblk0 returned old data while reading from /dev/block/mmcblk0p1 gave latest data. My question is does linux maintain a back up if data is written to /dev/block/mmcblk0? This is because i was able to read old contents of the…
spitfire88
  • 1,596
  • 3
  • 19
  • 31
14
votes
2 answers

Kernel module compilation and KBUILD_NOPEDANTIC

I've noticed that recent kernels (starting from 2.16.24?) don't like if CFLAGS is changed in external module Kbuild file. If CFLAGS is changed you'll be issued the following error by Linux kernel Kbuild system: scripts/Makefile.build:46: *** CFLAGS…
dimba
  • 26,717
  • 34
  • 141
  • 196
13
votes
2 answers

Accessing a serial port from a linux kernel module

Hello Linux Kernel Driver Gurus! I'm writing a v4l2 driver for a camera that uses a serial interface for configuration. I'd like the driver to configure the camera, as it keeps the client code consistent across camera models. The question is:…
13
votes
3 answers

how to solve Kernel configuration is invalid issues

I'm trying to build module. But here's some issues. ERROR: Kernel configuration is invalid. include/generated/autoconf.h or include/config/auto.conf are missing. Run 'make oldconfig && make prepare' on kernel src to fix…
Woo-Hyun
  • 131
  • 1
  • 1
  • 4
13
votes
2 answers

struct file in linux driver

I am currently learning how to write Linux device drivers and I have trouble understanding "struct file". I am using the book Linux Device Drivers 3rd edition to help me out. This is what I understood. a. struct file represents an open file thus,…
Mir
  • 670
  • 4
  • 9
  • 20
13
votes
4 answers

insmod error: inserting './hello.ko': -1 Invalid module format"

I have just made my first driver module, the hello world module following LDD3. However unfortunately encountered this error: insmod: error inserting './hello.ko': -1 Invalid module format. I am doing this on Ubuntu 11.04, and my environment: $…