9 ms·
Kernel developer write a USB driver in 3h for Apple Xserve front-panel [video]
- cm2187 2y agoNot quite from scratch...
- maxlin 2y agoThis. Why use the the explicit term "from scratch" when it's not even closely true.
- deleted 2y ago[deleted]
- walterbell 2y agoDoes anyone write a new kernel driver without using reference code for the Linux kernel subsystem? The code is less interesting than the human commentary. Imagine future AI-simulated "coding commentary".
- birdiesanders 2y agoThis sounds truly dreadful.
- walterbell 2y agoIndeed. How can today's developers avoid their Twitch streams being used to train future commentary-pollution LLMs?
- Am4TIfIsER0ppos 2y agoYou mean he didn't invent the universe? (Thanks to Carl Sagan)
- dang 2y agoOk, we've scratched that bit from the title above.
- dgellow 2y agoI dreamed of that type of content since I’ve been a teenager. Thank you for sharing, it’s fantastic to see more and more programmers streaming themselves working on fairly advanced projects. That removes so much layers of magic and complexity once you can peek behind the curtain this way
- logrot 2y agoI envy kids today to be able to look up pretty much anything what they want to learn. It was not like that back in the day.
- seanthemon 2y agoAlternatively, our routes back in the day was relatively linear, whereas today kids have to wade through so much more to find their paths
- explosion-s 2y agoI just wrote out a reply to the parent comment about learning to code but forgot to reply to this one, my previous comment is here: https://news.ycombinator.com/item?id=40484956 https://news.ycombinator.com/item?id=40484956
- Unfrozen0688 2y ago[dead]
- explosion-s 2y agoI (not the programmer in the video) started programming 2 years or so during the pandemic during sophomore year of high school. I can affirm - there is a lot to wade throughm it's hard to know what's relevant, easy to learn and useful in real life. That said, despite the availability of content online I tend to only watch the videos where something is a) summarized or b) something very advanced is broken down (e.g. the micro-gpt from scratch series). Imo, the best way to learn programming is to get excited about bringing your ideas to life, and choosing ideas small enough (at the start) to accomplish. I am worried though about the rise of machine learning which may increase the barrier to entry in industry jobs and require more expertise to get ones "foot in the door". Additionally I find it hard to resist learning new technologies that are not as widely used / changing quickly do to their ease of use (Svelte, Tauri, V lang, etc). Anyways, just thought I'd chime in as a kid learning to code
- vdfs 2y agoThe most interesting thing to me is that font for a terminal/coding
- CasperH2O 2y agoAnd no color highlights either!
- deleted 2y ago[deleted]
- shaicoleman 2y agoFont is Comic Code https://tosche.net/fonts/comic-code https://tosche.net/fonts/comic-code
- penguin_booze 2y agoNo line numbers, either!
- GauntletWizard 2y agoAs much as I love this kind of video, a deep dive tutorial, "from scratch" is kind of a misnomer. "From 10 years of experience doing exactly this" doesn't have the same ring
- asadm 2y agoNot sure why everyone is stuck on "from scratch" part. This is from scratch in all practical terms to me. They would be wasting their and viewer time if not done this way.
- userbinator 2y agoBecause there are us who have actually done USB device drivers "from scratch", i.e. using the specs or gone through the RE process for an unknown device, while this is basically porting existing code to a new API. Thus it's rather clickbaity.
- asadm 2y agoSure. But writing drivers via specs is also almost also porting :) "From scratch" is not interesting or generalizable. Chatgpt can do that, infact I have used GPT to write IMU driver "from scratch" by just giving it a bunch of datasheet pdfs...
- amelius 2y agoThe USB spec is like, what, 500 pages? That is impressive.
- tedunangst 2y agoI couldn't even transcribe 500 pages in three hours.
- bartvk 2y agoYou don't need to read the nitty-gritty of the USB spec itself, having a general idea of its capabilities is enough. The kernel gives you a bunch of functions to work with. You can learn it by simply reading the code of the most simple driver that you can find in the kernel source. Then you can step up, and find a more difficult one.
- codedokode 2y agoIt would be better if you could just read doxygen docs or something like this instead of having to reverse-engineer someone's else code. Because the code is just an example of using functions and doesn't give their complete description. If you write something like Linux kernel, write doc comments.
- userbinator 2y agoAlso, much of the USB spec deals with the hardware level and device side implementation.
- pantalaimon 2y agoA good driver API will hide that all and make sure an individual USB driver does not have to care about the USB spec - that’s the job of the shared USB core code.
- seba_dos1 2y ago...and also mostly irrelevant here.
- userbinator 2y ago...after numerous more hours of understanding how things work. Not mentioned in this title is that this is a USB device driver, for a relatively simple device, with existing code available. This is essentially a code-to-code "translation" task. I can see how this looks very impressive, but IMHO it's like watching anyone else skilled at their profession.
- explosion-s 2y ago> ...after numerous more hours of understanding how things work. > > Not mentioned in this title is that this is a USB device driver, for a relatively simple device, with existing code available. This is essentially a code-to-code "translation" task. I can see how this looks very impressive, but IMHO it's like watching anyone else skilled at their profession. Yeah - the title is a little off. My apologies! I'm not super knowledgeable about the kernel myself and while I did gain some knowledge from watching the video a lot of it looked like pure magic. If a mod wants to edit the title to remove the "from scratch" and add that it's a device driver that would be great but otherwise, no worries
- dang 2y agoDone. Thanks for the interesting submission!
- stefan_ 2y agoOne that barely has a reason to exist, a front panel is probably better served being managed by some libusb application in userspace..
- debo_ 2y agoThe loud sound of fans whirring in the background is the perfect ambiance for this video!
- dcan 2y agoI wrote a USB host driver for the STM32F4 a couple months ago, and the most difficult part was the lack of good documentation - the peripheral had r/w registers mapped as read-only in the SVD, there was a bit you had to set that wasn't mentioned in the documentation, and then the whole USB bulk-only-transport pointing to a non-existent SCSI spec. I ended up finding a blog post stating that you have to basically copy what Windows does in order for USB drives to work. Luckily I had an oscilloscope that could decode USB frames to save me a whole bunch of time to understand why things weren't working. USB seems to depend on a whole lot of tribal knowledge, which makes it impressive that it is so ubiquitous and works out of the box for the most part.
- raggi 2y agoIntel USB controllers are extremely forgiving of control software bugs. Extremely
- gravescale 2y agoIn a way that makes it worse because while you might get it "working" sooner, you'll never be sure if it's because you got it right, or if you're skating across the ice of a "quirks mode" that you hope will work in the next silicon rev. Then again, if you don't need to follow the spec for your to work, maybe the spec is overly restrictive and a Vernacular Protocol is more effective.
- dayjaby 2y agoMay I ask which oscilloscope you used for USB decoding?
- londons_explore 2y agoNot OP, but for USB "full speed" devices (12 Mbps), you can use a saleae logic analyzer clone ($12) with the opensource pulseview which can decode USB frames and streams rather well. Even with faster devices, you can usually force them down to 12 Mbps with a USB 1.1 hub for analysis and bugfixing of the driver/firmware, and then have the exact same code work fast without the hub. On desktop, wireshark also has the ability to monitor USB data transfers for a software-only approach.
- jonhohle 2y agoI started contributing to a decompilation project and while I’m not the best decompiler by any stretch of the imagination I’ve thought about streaming while I’m working. Is there interest in content like this? Are people curious about tells for when assembly is affected by variable sign, struct vs array access, the bonkers things even 30 year old compilers do with control structures, register reuse, etc. and how to coax code into byte equivalent assembly from classic consoles.
- 0x303 2y agoMade an account to say yes, this would be awesome to watch. I’ve been trying to accumulate esoteric reversing knowledge like this but it’s hard to know where to even look!
- Erlangen 2y agoI am interested. I learned some basic 8086 assembly during university, read some books on reverse engineering, but never went anywhere further. BTW, are you working on a open source project?
- khazhoux 2y agoI wonder if this video is painful to watch for people who claim "10x programmers are a myth!" As an eng manager who's overseen teams at several top FAANGs, I can say without a doubt that most of those engineers would have taken 1-2 months to implement a driver.
- epcoa 2y agoThis is confusing lack of experience with a specific discipline with productivity. If you have the specialized knowledge, you’ll know that “writing a driver” is an overloaded term to start. This guy isn’t going from a blank slate “scratch” either. There is tremendous amount of boiler plate being started with (in addition to the tremendous amount of core driver and USB “library” code in the base kernel) And for those with experience in writing device drivers nothing here is super human or even not mundane. This is a well documented (existing code) hardware with a simple interface. If you’re already experienced with Linux kernel device drivers, this is not a terribly complex incremental task.
- raggi 2y agoYup, scanned through the video, I don’t think the guy authored a single function, just grabbed skel and parts from other code bases, deleted stuff he didn’t want and fixed a little glue and build code
- Rinzler89 2y agoExactly. Plus, the author is not totally new to this. According to his resume he's been writing drivers since the late 90's so this probably isn't his first rodeo. He makes it look easy.
- stavros 2y agoNo it isn't. Most programmers just don't have the experience, and don't much care to get it. I've long thought 10x programmers were a myth, until I saw how much faster some of our developers are compared to others. It's pretty close to 10x, some people will do something in a week, someone else in half a day. The person who did it in a week wrote a thousand lines of terrible code, the second person replaced it with fifty lines.
- deleted 2y ago[deleted]
- pxmpxm 2y agoWhy is this a video?
- junon 2y agoMaking an OS and have thought about streaming my sessions a few times, maybe I'll start doing that if this is indeed interesting to people.
- vagrantJin 2y agoThe fascinating thing about watching people doing hard things is peering into their thought process. Writing an OS certainly qualifies as difficult. So if you really have the time to do it, please do. I will donate to your cause.