Live data from Hacker News

Writing a basic Linux device driver when you know nothing about Linux drivers

crescentro.se

51–60 of 72 posts

Re: Writing a basic Linux device driver when you know nothing about Linux drivers

#51

I want to run FreeBSD on my laptop, but they don't have a [complete] driver for my wifi card. I've thought about diving into AI coding-assistant agents just to see if I could use one to finish throwing together a working driver... but figuring out the AI agents is frictiony enough that I'm leaving it be. (I'm not a VSCode user)

My understanding is that FreeBSD lacks the support for modern WiFi standards in any of its drivers, so it would be a significant effort of understanding the WiFi protocol in addition to understanding your specific device. That said, FreeBSD would be much easier to use on laptops if someone were to put in this effort

Re: Writing a basic Linux device driver when you know nothing about Linux drivers

#52

Earlier quoted context omitted.

I had the same reaction. Nano leaf is extremely cool for that.

This has to put them in the top 0.01% of companies that make consumer electronics. I can think of only a few companies that bother to publish any details... And most of them are focused on industrial customers where it isn't unreasonable to need certain protocol details for integration or even just compliance with certain regulatory systems. Maybe things are changing? I have noticed that some of the LED light control…

It really makes me wonder why it's not more common. They literally don't have to write any firmware, just use one of the thousands already available provided that the license allows for it

Re: Writing a basic Linux device driver when you know nothing about Linux drivers

#53

Earlier quoted context omitted.

I sometimes think about this, starting from scratch with a computer hardware and software stack that disallowed all of the layers of abstraction that have built up over the decades. Yeah many of the abstractions help with performance but maybe there's value giving up much of that performance in exchange for simplicity.

For toy tinkering, to replicate something like the old ability to just write a byte to an IO memory location and have it appear on the pins of a parallel port, you could design a simple USB peripheral that did similar. Give it a set of DIP switches to pick a number (4 for 0-f, more would probably be overkill but feel free) and have the driver present something like /proc/simpleio/device /in and /proc/simpleio/device…

USB parallel ports, data acquisition peripherals, or modern boards that run linux and have GPIO pins are already a thing and don't need to be created.

What I'm talking about is a whole computer system + systems programming language + OS which is as simple to understand and program as computers were in the 80s. With modern speedups, without modern layers of abstraction.

Re: Writing a basic Linux device driver when you know nothing about Linux drivers

#55

Earlier quoted context omitted.

I sometimes think about this, starting from scratch with a computer hardware and software stack that disallowed all of the layers of abstraction that have built up over the decades. Yeah many of the abstractions help with performance but maybe there's value giving up much of that performance in exchange for simplicity.

For toy tinkering, to replicate something like the old ability to just write a byte to an IO memory location and have it appear on the pins of a parallel port, you could design a simple USB peripheral that did similar. Give it a set of DIP switches to pick a number (4 for 0-f, more would probably be overkill but feel free) and have the driver present something like /proc/simpleio/device /in and /proc/simpleio/device…

Thanks for the info!

I actually bought a real parallel port card years ago that plugs into a PCI port on my motherboard. Incidentally it also provides 4 serial ports.

Only tried it on Windows, but it works great. If I recall there was some kind of library I have to use in modern Windows versions due to a permissions or kernel isolation thing.

Re: Writing a basic Linux device driver when you know nothing about Linux drivers

#56

> I also thought I’d message the vendor and ask them if they could share any specifications or docs regarding their protocol. To my surprise, Nanoleaf tech support responded to me within 4 hours, with a full description of the protocol that’s used both by the Desk Dock as well as their RGB strips. How cool is that? Too many vendors still think that they have valuable intellectual property in such relative trivialitie…

I have a solar inveter from a company, aparticular German brand. I wanted to use home assistant with it so I needed rs232 data.. tried the support and they asked me to sign an NDA. Okay, cool. I did with a fake name, address and everything and they sent a file.. Turns out the file is available online. Facepalm pro Max. So my question is, what kind of "IP" is in a data sheet that needs protection ? And this isnt even…

Germans germaning!

Re: Writing a basic Linux device driver when you know nothing about Linux drivers

#59

This is awesome! But it also makes me a little bit sad. The original parallel port and even ISA interface seemed so simple by comparison, with less layers of abstraction. Just run a wire, and write to a port. I remember when I was a kid, I found a breakout board in an electronics store's random clearance parts bin, with an ISA header on an edge. On a whim I took it home and wire-wrapped a 7-segment LED onto it. Power…

Serial ports still exist today. Even in desktop computers (though usually in weird underpowered ones designed for industrial applications and such). Even the most GAMING of motherboards have headers ready for one or even more serial ports to mess with. All you need is a cable and a card to slot into a PCIe bracket!

USB itself, at least the 1.1 protocol that's still used for some devices today, isn't all that complicated in itself: https://youtu.be/wdgULBpRoXk

Many if the complicated parts here, like device identifiers, are the things you'd need to manually configure if you were to use a serial port. Those hundreds of pages are similar to the hundreds of device types, vendors, and models that Windows would list when you clicked "add new hardware" back in Windows 98. When push comes to shove, you're just sending energy pulses down wires, there's just a chip in there that helps collect pulses so you don't need to manage the timing manually.

Re: Writing a basic Linux device driver when you know nothing about Linux drivers

#60
post #38

> I also thought I’d message the vendor and ask them if they could share any specifications or docs regarding their protocol. To my surprise, Nanoleaf tech support responded to me within 4 hours, with a full description of the protocol that’s used both by the Desk Dock as well as their RGB strips. How cool is that? Too many vendors still think that they have valuable intellectual property in such relative trivialitie…

I wish more vendors would put "Linux support" on the package. Or maybe "Unofficially supported in Linux" or "Linux community support" if they don't want to get their fingers burned. Maybe this kind of thing should be enforced in the GPL (as many devices use Linux under the hood).

IME, Linux support is often mentioned on the package these days. But you still need to look it up anyway because it's often a vendor source dump for a particular kernel version. Such drivers are often not that good. Notable exception: my Brother printer-scanner-copier has been working fine with its vendor-provided user space driver for ~10 years now. I think it has not been updated for most of that time. It contains 32 bit binaries!
Post reply on HN