Live data from Hacker News

Writing device drivers in Linux: A brief tutorial (2006)

freesoftwaremagazine.com

21–30 of 36 posts

Re: Writing device drivers in Linux: A brief tutorial (2006)

#21

Earlier quoted context omitted.

While not straightforward or easy (for an average chap), it's quite possible, and very useful. Although I wouldn't call it most people's programming language of choice, knowing, and being able to grapple with how C pushes memory management to user-code will definitely change the way you think about programming. TLDR : Pick up any of the hundreds of books on it and start learning! If you're having trouble motivating y…

Someone needs to write "c for ruby programmers"

> "c for ruby programmers"

Most, if not all, of this book would be "How To Use Pointers" with large sections on how to structure your code around correctly allocating and freeing memory.

A (fairly brief) appendix would be "Weird Stuff C Programmers Actually Do", for the 'dark corners' stuff that's actually used outside obfuscated code competitions. It might be hard for someone who's actually a C programmer to write this; things stop looking weird after a while.

Re: Writing device drivers in Linux: A brief tutorial (2006)

#22
I remember, this was my tutorial when my lead had told me to practice writing some dummy device drivers as our team was supposed to merge into kernel team. Well, the merge didn't happen and this was my first and last device driver.

I liked the clarity and ease it offered to a first timer. I was somehow miffed about moving to kernel team from Java(app dev) but after this tut and some more articles I was disappointed when finally I didn't. This was one of the articles that changed my leaning towards learning C in a positive way. C is now my interview language :-).

Re: Writing device drivers in Linux: A brief tutorial (2006)

#24
I worked as a linux kernel programmer for a time. All I really did was work slowly on bugs. It seems that there are always neat features that need implementing but the number of engineers with the now specialized skills required is relatively small compared to the general population of embedded engineers. It seems rare to find someone willing to cultivate an embedded engineer into a kernel developer. They're not hard and fast separations, but still, this division remains.

So, if you can, try to connect with actual kernel engineers, do an interesting project in school for a professor doing hardware work, etc.

One project that might help out is to re-write the 8150 USB network adapter project. The devices that have this chipset are easy and cheap to find and the data sheet is easily available. There's a PCI version of this chip, the 8139, too.

Re: Writing device drivers in Linux: A brief tutorial (2006)

#25
post #6

Does anyone have any suggestions for books/learning materials related to the pre requisites mentioned in the article, specifically Microprocessor programming? I've tried to find some in the past but having no prior EE experience I find even some of the basics challenging. I have experience with C, but don't really know where to start with the lower level stuff. I'm thinking I should start with a simple book like Elec…

You can probably do just fine with what you know.

One project that might help out is to re-write the 8150 USB network adapter project. The devices that have this chipset are easy and cheap to find and the data sheet is easily available. There's a PCI version of this chip, the 8139, too. The USB project would be easier since you're passing URBs back and forth. The LDD3 book and the data sheet is more or less all you need.

Re: Writing device drivers in Linux: A brief tutorial (2006)

#28
post #11

Why wasn't I aware of this guide last week when I had to write a kernel driver for my OS class?! One thing that's surprised me with Linux development is how nice the APIs are to work with. Things like the file_operations struct, and the linked list stuff are very well thought out and easy to use (as easy as they could be for C programming). My only complaint is that a lot of the written documentation is out of date a…

This is why kernel hackers tend to say "Use the Source, Luke!" instead of pointing you at documentation. The one exception is documentation that talks about the high-level design of a feature (e.g. Documentation/pi-futex.txt), which is usually updated whenever there's a complete rewrite or major design change.

Re: Writing device drivers in Linux: A brief tutorial (2006)

#29
post #7

Earlier quoted context omitted.

Very exciting and empowering article. Makes me want to learn c, or at least believe that c is possible, straightforward easy and useful.

While not straightforward or easy (for an average chap), it's quite possible, and very useful. Although I wouldn't call it most people's programming language of choice, knowing, and being able to grapple with how C pushes memory management to user-code will definitely change the way you think about programming. TLDR : Pick up any of the hundreds of books on it and start learning! If you're having trouble motivating y…

K&R was the first and only book about C that actually worked for me. Everything else was verbose, confusing, and left me with no more than the ability to do basic character apps. I read dozens of the "hundreds of books on it", and they all left me incompetent at C. K&R allowed me to become useful in the C language, including hacking on kernel modules.

I'm sure there are other good books on C. But, I never found one. They were all too long, and hid understanding behind verbosity.

K&R also made C fun for me, revealing it's nature as a well-crafted tool. Reading a lot of real C code also helped...I finally really learned C soon after migrating to Linux, where code for everything was available.

Post reply on HN