Easiest driver for a Linux Device Driver newbie - linux

I am new in Linux Device Driver Field. Can anybody tell which driver will be easier for me to understand among Audio drivers, Video Drivers, Camera Drivers, Power Management Drivers or Boot-loders? Please suggest me the driver which will be easy for a newbie. If you can suggest any good source for the same (not book...any online material if available) it would be great. :)

You should start by studying the basics of Loadable Kernel Modules.
First few chapters of LKMPG by Salzman will be a good start
And the easiest driver, IMHO, is a simpleton driver that uses memory as a device and reads/write to it. One such driver is beautifully explained in third chapter of LDD3e.
You would also need to increase your knowledge of the Linux Kernel itself in order to advance towards relatively hard drivers. The better you understand Kernel's subsystems the easier it will be for you to develop device drivers around them.

Related

Yocto Project usb sensor access

I've never worked with the Yocto Project, and barely knows what it is. But I'm investigating the possibility to use a Simatic 2040 as a gateway between an USB hall sensor and industrial PLC network.
The sensor that we want to use is this one. It's designed to use with an Windows desktop PC, connected via USB.
Now my main question is, would it be possible to write software in the Yocto device to capture the sensors data, and share this information with an industrial PLC network.
The industrial PLC network is also Siemens based, so I don't see much problems around that because we can make use of the Node-Red Profinet or Modbus library's.
The question is stated in very general terms, so I will have to answer in very general terms.
Overall the answer to your question is yes, but there are a number of details to sort out (some of them might be show stoppers).
Yocto is a system to generate embedded Linux images and also SDKs (cross compiler toolchain + sysroot).
You might be fine to take an existing Yocto Image for the SIMATIC 2040 and just add your own application to it. For this a matching SDK has to exist. This approach works fine as long as your application has not too many dependencies and you don't need to many modifications off the existing image.
If this is not the case you might be better off generating a custom image as well as an SDK (based on the existing SIMATIC 2040 configuration).
Considering your USB device. The linked data sheet states windows support. Your options?
Talk to the vendor? Does he provide a driver, but doesn't advertise it? Is he willing to hand out a detailed datasheet?
Check if there is a community driver in the mainline kernel?
Reverse engineering the existing Windows driver?
Pick an alternative device with an existing Linux driver (preferably in the mainline kernel).
The right solution depends on the time and effort you are willing and able to put into this.

what is the difference between chanctx based drivers and non-chanctx based drivers?

I am a newbie to linux device drivers. I have been writing driver for a WLAN device. While registering callbacks with mac80211, I found a few callbacks (OPTIONAL ones) regarding channel contexts. I just dont understand how they work?
Please go through this link to understand the significance of those structures.

Linux user space PCI driver

I'm trying to write a PCI device driver that runs in user space. Not my idea, what the client wants. Target is an embedded Linux board that will never have more than a single user. I'm an experienced C programmer and know Linux, just not familiar with Linux driver development.
Is this really a device driver or just a library? Do I need to use the typical calls pci_register_driver, etc. or can I just access the device using fopen, and using mmap and ioperm to get to it?
Interrupts will be done using the MSI model. Also need to handle DMA transfers. The device will be streaming lots of data to the user.
There's not much info out there on this subject, LDD3 only devotes a couple of pages to it, and there's nothing else that I could find here on SO.
Thanks in advance!
If there is no driver handling the PCI card it would be possible to access it using ioperm (or iopl - depending on the address) if only port accesses are required.
Using DMA and interrupts is definitely impossible without a kernel-mode driver.
By googleing I found some text about something like a "generic kernel-mode driver" that allows writing user-mode drivers (including DMA and interrupts).
You should ask your customer which kind of kernel-mode drivers for accessing PCI cards is installed on the Linux board.
There is now a proper way to do high performance userspace PCI drivers, called vfio. There is not much documentation, but see the kernel docs http://lxr.free-electrons.com/source/Documentation/vfio.txt and the header file /usr/include/linux.vfio.h. It is available since Linux 3.6.

PCI/PCIe card with DMA capability for device driver training

I trying to learn DMA for device drivers with PCI/PCIe devices, and my platform is linux/bsd. I have found quite a few simple PCI boards for training (such as simple digital I/O boards), but none have hardware complex enough to handle DMA. Is anyone on Stackoverflow aware of a PCI/PCIe card with some sort of microprocessor or mcirocontroller that I could program with open-source tools like gcc (e.g. PowerPC, 68HC11, Atmel, 8051, etc.)??
Of course the kicker is low cost...sub USD 300.00 if possible.
I DO NOT WANT an FPGA-based board, because that requires a Windows workstation (usually) for programming the FPGA, as well as all of the time required for creating and working with a PCI/PCIe IP core in the FPGA. Basically, I don't want to spend my time working on the FPGA; I want to work on the device driver! This may be my only option though...
If you don't want to use FPGA, then you have to find a board that has enough info for you to be able to communicate with the PCIe interface of it. Not that many boards come with HW interface document, but if you want or can do this without documentation, you can use one of these boards:
Alibaba 4 Channel MIDI GAME port 3D
Same board on E-bay Alternative 2 on e-bay
You can also get a bit more advanced board like this one, but then you need to know how to communicate with their chipset.
Alibaba 4CH PCIe HDMI Video Capture Card here
If you change your mind for the FPGA, I would really recommend the Altera PCIe board that comes with a reference design and the bit file already per-programmed on the board. It is much more expensive than those, but the biggest benefit is that you have full documentation of the PCIe interface:
Altera Cyclone IV GX Transceiver Starter Kit
Here is the info about their reference design:
Altera PCIe reference design
Hope you find what you are looking for here.

Audio / Camera Driver - FriendlyARM Mini2440 - s3c2440

I am a newbie to embedded linux and am keen on learning to write device drivers. I have got a FriendlyARM Mini2440 board with me.
Please suggest which device driver would be easier to start learning - Audio or Camera or something else?
Need suggestions from experts.
Thanks a lot!
Between those 2, I would say that a camera driver would be simpler. Audio drivers in Linux are more complex than most other drivers, and there seems to not be very much documentation on writing them.
Have you read Linux Device Drivers by Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman? That is probably the best way to start.
I'd recommend starting with serial, flash, or ethernet drivers, in that order. Those are common, the code is straightforward, and there's good documentation and examples for them.

Resources