In Linux device drivers what is the difference between mmc, mtd? - linux-device-driver

MTD memory technology devices is driver part dealing with flash kind of memory.
MMC is also flash memory in it's driver core it also has functions to deal with configuring boot partition. What is the difference between these two in their features and functionality and when to use which driver apis
I am a newbie to linux device driver.
If my customized embedded system hosts embedded linux in the SD/MMC card, do I have to look for and modify the files present in kernel source in the path /drivers/mtd or /drivers/mmc or both to adopt my hardware for functionalities like partitioning the card,formatting the card to required filesystem etc,..? If /drivers/mmc is needed to look for, then inside it /drivers/mmc/host or /drivers/mmc/core is needed for the functionalities related to hosting the OS with my above said needs.
Please anybody clarify my doubt.
This my doubt and not related to any of my experiments

Related

How would I go about making device drivers for my own kernel?

I am making my own operating system for fun. I'm reading and learning a lot from the Intel's 64bit and IA-32 architecture manual which is helpful for developing an operating system.
But one thing that I just can't find anywhere is how to make device drivers. The only posts I can find about device drivers on the internet are about making Linux or Windows drivers. But it's different from making drivers for my own kernel.
Can someone experienced please point me into the right direction, enlighten me where I can learn making my own device drivers for my own operating system?
For a start, simple keyboard or mouse drivers are enough, but I will appreciate anything, be it simple keyboard drivers, or complex network drivers
TL;DR: I need a solid source explaining how to make device drivers for my own kernel. I can't find any and hope that someone have stumbled upon one
(I'm not asking "how to make drivers?", but rather asking "can I have links to books/posts about making drivers?")
All a kernel-mode device driver is, is code executing under the kernel, which is not treated as the "main" kernel image itself - consider it as an "extension" to the main kernel image. On Windows for example, kernel-mode device drivers (which tend to use the *.sys file extension, which is also belonging to the Portable Executable (PE) Format) are treated as modules to ntoskrnl.exe (which is the main kernel image on Windows).
The idea is that your kernel-mode device drivers will have access to routines exported by your main kernel image (e.g. if you want to implement mechanisms like kernel-mode callbacks). You could start by making your own simple format for your kernel to understand, and then you can start implementing export support appropriate for your own file format (for the main kernel image) and import support (for the other kernel-mode software to make use of the APIs which it should have access to, provided by the main kernel image).
You'll have a lot of work to do if you want a good design implementation.

porting PCIe driver from Linux to OracleSolaris

I need to port a PCIe Linux driver to Oracle Solaris 11.2 (previously OpenSolaris). Before the driver was tested under kernel 2.6.32-36.
Fortunately, the driver was implemented in such a way that one portion is OS/platform specific (PCI registration, memory allocation etc.) and the other half was written in OS independent way, i.e. that part should be relatively easy to port.
My question is about Linux-specific portion, written according to steps in https://www.kernel.org/doc/Documentation/PCI/pci.txt, so I'm assuming Solaris might have similar approach? What should I pay attention to when porting to Solaris, what device driver parts are completely different in Solaris and nedd to be re-implemented then ported?
UPDATE
After reading several materials about Solaris driver model, I still don't understand the purpose and applicability of STREAMS framework, is it extension for character devices or for the network devices, eg. Ethernet cards?
Solaris 11.2 driver documentation is here.
Here are some links that might also be useful:
http://docs.oracle.com/cd/E19253-01/817-5789/
http://www.oracle.com/technetwork/systems/articles/write-dev-driver-jsp-140901.html
http://www.bolthole.com/solaris/drivers/TIPS.html
http://blog.csdn.net/hotsolaris/article/details/1763716

Linux kernel device driver programming [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to learn linux kernel device driver programming. So can anyone please post good tutorials pages or links here. I am new to linux kernel environment. I have searched for it but I don't know how to start and which one to read for easy understanding basics. Thanks in advance.
Depends on your current skills. If you're really new to Linux, perhaps you should start with user space system programming with Advanced Linux Programming. You'll get good knowledge of Unix system calls and other concepts such as signals, processes/threads and so on with this free resource. This is a must (understanding the user space API) if you're developing on the kernel side since the role of a kernel is providing services to users in a secure way.
Otherwise one often cited book is Linux Device Drivers, Third Edition (LDD3). Keep in mind that this edition was written at the time of Linux 2.6.10 and some things changed since then. This article shows the differences as 2.6 evolved (until 2.6.31, that is, so not very useful). I should mention martinezjavier/ldd3, which contains example drivers of LDD3 updated for more recent kernels (thanks to 42n4 for pointing that out).
Another interesting book that's not as often cited is Essential Linux Device Drivers. You won't find a free version of this one, but it still features an interesting approach. What I like about this one is it covers lots of different device types and is up-to-date as of 2.6.24, which is a bit better than LDD.
Finally, one great book about the kernel itself (not specifically for drivers) is Understanding the Linux Kernel, 3rd Edition. This covers in-depth kernel facilities and internal mechanisms. It's up-to-date as of 2.6.11.
As for online tutorials, I found this post on Pete's Blog is a really great example. Not only does it show how to create a character device (the most easy kernel driver type, i.e. the one you should start with), it uses modern Linux kernel features in an easy to understand fashion, including:
use of udev
use of a kernel data structure (FIFO)
use of kernel synchronization (mutex)
use of Sysfs with custom attributes
module options for insmod
Plus: it's aimed at Linux 3.0, which means it's more up-to-date compared to other resources.
You might also like this post about how to create Sysfs entries manually, although the Linux device model will take care of registering your device as a Sysfs entry if you don't need additional nodes or attributes.
Edit: I should add that the best way to learn real Linux device driver programming is to look at actual drivers. There are thousands of drivers in drivers. Start reading and understanding the concept of simple ones like drivers/leds and you will see how rewarding this is.
The site with very important links:
http://elinux.org/Device_drivers
Great tutorial with real examples (ends with an usbpen formatted with our own file system - search for author further articles):
http://www.linuxforu.com/tag/linux-device-drivers-series/
http://sysplay.in/index.php?pagefile=lfy_articles
Source code of famous LDD3 book ported to newest kernels:
https://github.com/martinezjavier/ldd3/
Videos:
https://www.youtube.com/playlist?list=PL16941B715F5507C5
Maybe other cources:
http://www.skilledup.com/courses?keyword=linux+kernel&price_filter=0..0
Some examples:
http://www.staerk.de/thorsten/index.php/My_Tutorials/Writing_Linux_kernel_modules
http://www.freesoftwaremagazine.com/articles/drivers_linux
http://techblog.aasisvinayak.com/kernel-module-programming-tutorial/
http://www.linuxforu.com/2009/05/a-voyage-to-the-kernel-day-11/
Books (without mentioned in this thread LDD3):
http://www.coopj.com/ with an updated source code http://www.coopj.com/LPD/
KernelHacking:
http://kernelnewbies.org/KernelHacking
Visual map of the linux kernel: http://www.makelinux.net/kernel_map/
Linux and kernel books for beginners:
http://www.kroah.com/lkn/
http://swift.siphos.be/linux_sea/
You might be interested in the newly released Linux Driver Templates. As the name suggests, it provides templates and demonstrates frequently used Linux facilities to get started quickly.
I understand it is a delayed response !!
You can pick any book, those are really great books suggested above.
But you need to really work practically. Try to be involved into Kernel as much as possible.
Mostly you need to look into kernel source code itself.
And the most interesting document you can find in Documentation folder under Kernel tree.
best book for learning device driver programming is
"LDD"
Professional Linux Kernel Architecture is a good read also.
The best source is the linux man pages but they are somewhat critical to understand for a beginner, Directly programming device drivers is not a easy task. I recommend you to go through pointers and structures through following books
Basic C Books 1. Programming C - Byron gottfried 2. The C Programming Language - Dennis Ritchie
Intermediate Books 1. Pointers on C Kenneth Reek 2. Expert C Programming Deep Secrets - Linden
Coming to device Drivers I have uploaded the Kernel Source documentation in pdf format https://drive.google.com/folderview?id=0B7iRyndFhHldR3hjOHpOZTdKTjA&usp=sharing Youcan download from this link.
Device Drivers Basics (User mode Programming)
Linux Programming interface - Michael Kerrisk
Beginning Linux Programming Wrox Publishers
Device Drivers (Kernel Deleopment) 1. Linux Kernel Development - Robert Love 2. Linux Kernel Internals - m beck
Device Drivers (Driver Programming) 1. Linux Device Drivers - Third Edition (Free Download is available for 2.6 Kernel) 2. Essential Linux Device Drivers - Venkateswaran
For Basic Driver Knowledge Follow this site http://www.tldp.org/LDP/khg/HyperNews/get/devices/devices.html
My Experience is First of all we must gain a sound knowledge on C Programming, mainly Structures and Pointers before going through Driver Programming otherwise it will be bit cumbersome to understand driver programming.
Comming to Startup :-
User space programming
Basics of gcc generating proprocessed, assembler and object files using gcc commands analysis of object files using different object tools, Basic programming in linux, threads(locks, synchronization techniques), signals, processes(fork, exec), timers(Posix). This will help you lot in understanding kernel concepts.
Kernel Programming
Understanding the kernel source tree, different branches and their importance, using ctags and cscope to browse kernel source code, this will help you in kernel source browsing.
Driver Programming
First of all Learn different driver classes, char, block etc.,
Next learn the device protocols, transmission and reception, the product manual is the best source for going through this.
Then start writing the simple char driver for example RTC (a port mapped device), IOAPIC (A memory mapped device), then go to USB, PCI, Network, I2C, SPI etc., if you want the help you can find the skeleton code for all this in kernel source tree.

Accessing the Installed Drivers

I am fairly new .. I want to ask
If i can get the installed system drivers of any device/interface card in my Pc and use it in my own applications.
If i can then .. Can anyone tell me if i can use the sematic s7 installed MPI drivers for communication with the Siemens plc with my own application..
I want to use this with c#.net in windows environment
The first question needs more work: the drivers, once installed are already there. There is no concept of "getting" them. You can open a handle to installed drivers to perform various operations, if you know how, and the means to do so differs greatly between different types of drivers.
As for the second question: unless you either have source code or documentation of the driver in question, I doubt it would be possible. Of course, the simplest alternative is to obtain a library from the vendor to access the PLC from an application. The library will hide all the tricky parts of using the driver.

What is the difference between an OS and a Framework?

I recently posted a question about Azure... is it really an OS? I understand the technical details, and I got a lot of fuzzy answers... I really want to know... what do you think is the difference between an OS and a Framework?
Just for reference, Azure will be built on top of Hyper-V servers and the virtual machines will be running vanilla Windows Server 2008. It will run services that creates a cloud on top of the many virtual machines which is called Azure. Windows is calling Azure an OS.
I am trying to understand how to define the difference between an OS and a framework.
Operating System: The infrastructure software component of a computer system
Framework: A re-usable design for a software system (or subsystem).
By these definitions it seems to me, that an operating system can be built using a framework, and a framework can be built to interact with an operating system.
Singularity is an example of an experimental OS that is built using managed code.
Framework is a very broad term, it can be used to describe many types of subsystems. It could even describe an operating system.
Operating System is more specific, it implies facilitation of interaction with a computers or group of computers hardware layer, through the use of human user interfaces. I think Azure fits this description.
It's up to marketing - I don't think the terms have a definite meaning any more.
Is a JVM a framework?
What if it's running on a raw uC or even an FPGA - is it an OS?
An OS is the thing that directly interfaces with the machine, be it virtual or real. It has to expose syscalls that handle input devices, output devices, sound, networking, and all the other things that we take for granted these days. It also often provides some kind of UI which uses these services to make it easy to use/useful for an end-user. It needs to have device drivers to work with video cards, sound cards, etc. (Once again, these can be virtualized).
A framework is... something built on top of the OS. It, too, exposes an API, but they are often not so low-level as the one the OS exposes.
frameworks provide api contracts that oses usually don't - meaning they sit atop the os, hide and manage the differences, and consequently give you that platform independence goodness that can broaden our target audience
A framework thought to be as a development environment,a helping platform for further developments and you can work additively to create some other application using components of framework, while OS is system software is an environment to operate a system.