0

I actually wanted to add a comment to the thread:

Device Driver thread

but I dont have the "reputation" to do it, it seems, forgive my lack of knowledge of this site. That thread although put on hold was great! great resources since I want to do what the OP wanted to do: learn to program device drivers (and I dont think the question was too general)

Anyway,I am following a lot of that great advice, including reading Linux Device Drivers, Third Edition.

But in this book it is said on page 15

Regardless of the origin of your kernel, building modules for 2.6.x requires that you have a configured and built kernel tree on your system.

and on page 16

So, if you do not yet have a suitable system with a configured and built kernel source tree on disk, now would be a good time to set that up. We’ll wait. Once that task is taken care of, you’ll be ready to start playing with kernel modules.

what does this means??! (I know it is basic, but it is the most basic what is not explained- I already understood the more complicated things)

"A configured and built kernel tree"??

I mean I have a debian system. and I have the source code of the kernel. Which I put on some directory (after untar it) . Do I have to compile this? And even if I compile it, that will produce a "image file" right?? Is that what they mean a "configured and built kernel"?? Isnt it enough my original kernel on which I am working on??

Do I have to recompile the entire kernel when I build my driver? I guess not right?

And what happens if I want to crosscompile (which is my final situation now, but I think I ll keep it to later) , meaning I am developing on a debian system but want to produce the drivers for an embedded ARM uCLinus system? Of course so far I have been able to get the kernel and userland sources, crosscompile them (after configuring them) and write them on the micro but if I want to write a device driver what the "configured and built system" stands for? (and an arm image wont run on a PC right?)

Anyway, lot of questions but I guess it can be summarized on only ONE simple question:

what do I have to do to be able to build the simplest, do nothing example of a driver that all books and tutorials talk about?

thanks a lot for the help

Community
  • 1
  • 1
  • Traditionally, you did need to build the kernel first. But if you have exactly matching headers - such as for a desktop distro where those are distributed as a package - then you can build a driver "out of tree" against those. For an embedded system you should probably first build the kernel from source **and check that this build actually works** - unless you can get a set of sources and configuration *specifically intended* to support building drivers *against the installed kernel* in a manner similar to what desktop distros provide. – Chris Stratton Oct 07 '14 at 04:30
  • Thank you very much for your helpful and quick response. I guess what you are saying is: 1) If I want to write a driver for my debian system, it will suffice to try and compile the driver program? without the kernel source file compiled again? 2) if I want to do it for my uCLinux embedded system I have to build the image file first ( they work since I already tried that many times) I didnt understand the last "installed kernel" thing. by that you mean my PC debian? – Hitoruna Oct 07 '14 at 05:26
  • What's stopping you from just working through those examples and seeing what you need? – skrrgwasme Oct 10 '14 at 16:50
  • I didnt know what exactly do they mean by "A configured and built kernel tree". It may sound so obvious to everyone, but it is not. Anyway, in the end I downloaded the kernel source files, put it somewhere in my tree and configured it and built it. Later I took the first example and built it. My problem is now that the kernel versions are different (the running one is 3.2.0-4-686-pae and I used 3.16.4 to build a module) so I got invalid module format error. Do I have to download exactly the same kernel as my running one?? – Hitoruna Oct 14 '14 at 01:03

0 Answers0