r/osdev • • 28d ago • Bravo 1

OH GOD NO

Post image

Started working on USB drivers for my hobby 64-bit OS, and oh god no little did I know what have I gotten myself into....

Wish me luck...

My OS project: https://github.com/itay-insert/64-dem.git

547 Upvotes

54 comments sorted by

33

u/Sorry_Difficulty_250 28d ago

lol Good luck! 😁😁

33

u/Individual_Feed_7743 28d ago

Love seeing people take on xHCI work! Best of luck :)

25

u/litescript 28d ago

oh baby. i’m working on drivers for a little embedded project. i feel you. have fun!

8

u/neurah 28d ago

I'm working on C++ static composition, good for drivers and OSes, have fun and good luck :D

8

u/litescript 28d ago

ha thank you! i’m doing freestanding C and assembly on x86 and also ARM for a hyper bare bones smart watch (PineTime) - fun stuff!

-7

u/No_Code9 27d ago

Just ask Claude. Done in 5 minutes

4

u/riisen 25d ago

Just dont breath and your done in 5 minutes.

3

u/litescript 26d ago

eh, the fun is in the learning and creation for me. i use AI to pose me problems and gently nudge if i get stuck, but otherwise, i like the process.

3

u/Grand_Muffin3476 26d ago

Goy

1

u/lpbale0 24d ago

? Did you mean that in the disparaging way?

2

u/Numerous_Habit269 27d ago

Need to get back to C, I have an unfinished VM project stashed somewhere

19

u/levidurfee 28d ago

Take a break and watch a movie. Maybe watch that new movie, Obsession.

7

u/Educational_Bug2558 28d ago

I wanted to program a driver, I compromised I watched obsession instead.

12

u/dacydergoth 28d ago

The spec makes my brain hurt

4

u/Individual_Feed_7743 28d ago

It's definitely tough to navigate around as it's not in any sensible or chronological order, but at least it's better than most NIC specs out there lol. You learn to appreciate intel specs with time

-1

u/No_Code9 27d ago

Ask claude

5

u/zerosign0 28d ago

Yup I can remember (at least) some horror from early usb drivers bugs hmm

3

u/bendgk 27d ago

why are you writing `interfaces[i].endpoints[j]` all over the place… this is completely unreadable.

```
auto endpoint = interfaces[i].endpoints[j];

endpoint.address = endpoint.descriptor.bEndpointAddress;
…
```

Love that you’re writing the code by hand; this is what real learning used to look like! (I’m still very pro LLMs, but love to see people do it the old way!)

1

u/Glyth63825 27d ago

I use Google's AI Overview to point out logic errors that I'm not catching. I think I have something perfect, but it's slightly off. Even then, sometimes it can't help. I'm currently working on a physical memory manager... not going well. I think I have the total memory, free memory, and addresses perfect. Now it's just a matter of populating the page tables (I think...).

1

u/_software__engineer_ 24d ago

I believe you mean to use a reference with `&` in `auto & endpoint = ...` such that you don't need to remember to copy it back into `interfaces[i].endpoints[j]`?

Performance wise, the copy will get elided by the compiler when compiled with optimization, but if you do it your way with the copy, you could run the risk forgetting to copy it back.

7

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS 28d ago

mmmhmmm I see that commit in the screenshot, "...with codex", smh go read a spec and try write it yourself

3

u/JescoInc Perdition-OS 28d ago

Where? I looked all over and couldn't find it

4

u/codeasm 28d ago

They might be revering to a previous post by OP https://www.reddit.com/r/osdev/s/9MVaD7ffKz and i think they have a healthy look on ai. The chat seems to be disabled in vscode even by settings. Seperating your "advisor" from your code editor is maybe a great way to try yourself first, no "can you do it for me?".

If we all avoid ai and do it all ourselfs, its like a carpenter without electric tools. Its novel, its cool, and learning to program by hand is awesome and a great learning tool.

But for work, i used to be allowed to read books, copy code from workmates or from the internet if licenses allowed it. Stackoverflow even, attribution required, we know this right? And after my big project and research, conclusion was "currently the software available does not answer the company question. Maybe in the future when AI is more powerful, it can do the detection and reconstruction". This was 2015. They let me go soon after 🥲

Today, i assume they incorporated ai, and tons of indian hands(the guy i contacted back then was good) to code their phone app. The backend is still made by the team in Amsterdam, and some of the guys are truly awesome devs.

Anyway, id ask ai for some pointers in the spec, or which pages to look at. Then give it my best shot myself. My own os is on hold, i got distracted by another Arch, m68k, and the hardware i got basicly gave me all the keys to run my own code... From diskette 😬

4

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS 28d ago

I'm kind of copying my other comment but no I'm referring to the screenshot. Look in the terminal underneath the code, it says "finished get_config and usb_send_packed with codex" as the commit name. Also no programming by hand is neither novel nor cool it is just the default lol.

0

u/JescoInc Perdition-OS 28d ago

But that is assuming that finished get_config and usb_send_packet with codex is referencing that they used codex to generate the code. Whereas codex will usually attempt to create a commit itself.

1

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS 28d ago

Huh wdym? They literally created a commit saying they created it with codex? If your clanker is trying to commit your code on your behalf when you didn't make it then that a whole different issue in itself.

0

u/JescoInc Perdition-OS 28d ago

That is assuming that Codex is referencing an LLM and not something else.
And no, Codex defaults to wanting a git repository and any change to code it makes, it wants to create a commit and push.
It was one of the main reasons why I didn't install Codex on my machine. If I use an LLM, I want it to be on my terms and those terms are usually review or investigation oriented.

1

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS 27d ago

what else would codex refer to lol that is by far its common meaning. this feels like a weird way to say they're not using an llm in the most convoluted way possible. but yes you literally said, it wants to commit and push any code it creates, thus it was clankered.

0

u/JescoInc Perdition-OS 27d ago

I'm not saying that they definitively aren't. I am saying that there is a possibility that they aren't. That sentence alone doesn't say that they did or did not use an LLM.

We also don't know what the actual usage level is. Like, was it used simply for checking for obvious mistakes in code he wrote, was it used for research, or did it write all of the code for him? None of that can be gleamed from that comment at all.

2

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS 28d ago

Look in the terminal underneath the code, it says "finished get_config and usb_send_packed with codex" as the commit name

2

u/codeasm 28d ago

Could mean they asked codex for advice and wanted to make note of this in the commit. OP could tell us what codex involment was in this context. As others said, atleast Claude would use their own account to push their commits, and so you can review their commit/request and when you push those, you can sort pushes by author. Unless OP uses another method of incorporating their ai help

2

u/MasterOfAutomation 28d ago

That's the stuff dreams are made of!

2

u/Even-Tooth4840 25d ago

Maybe you'll learn how screenshots work along the way

2

u/4dr14n31t0r 18d ago

You remembered me back in the day when I was young and bold. I managed to detect the USB when I'd plug it in the port. I did it using NASM because I didn't want to bother learning how to use C when doing OSDev. Then I hit a wall trying to read or write anything: I couldn't make the damn ring structures work no matter what. Then I realized if I really wanted to make progress I'll have to reverse engineer a xHCI driver that works and compare it with my code to see what's wrong with it. And what's the best place to find the source code of almost any driver? The Linux kernel ofc.

That was years ago. Studying the source code of the Linux kernel seemed a task so daunting that I decided to pospone it until I felt ready. It won't be easy but I will any day now. I want to learn Android development for now first.

1

u/Sqydev 28d ago

🤩

1

u/sethkills 27d ago

What’s the matter, son, too many magic numbers?!

1

u/doscore 27d ago

Welcome to the stack from hell lol

1

u/Randum_Gouy 27d ago

:)

Best of luck!

1

u/No_Code9 27d ago

Just ask claude

1

u/Maui-The-Magificent 27d ago

Mmmm.... yes, I have built an XHIC interface. If you want to make it easier for yourself, enumerate the device and then map the device yourself in the kernel... please for the love of god don't do a proper job and be dynamic...

1

u/CircuitBreakerChip 26d ago

One of my favourites interfacing

1

u/lattice_defect 26d ago

gross windows

1

u/belbel-dev-1124 26d ago

É qual licença? Permissão para usar?

1

u/hartmanbrah 26d ago

Yep, I recall wanting to do that a few years back. I pride myself on enjoying the fall down the rabbit hole, but I took one look at that spec... NOPE!

1

u/idontlikegudeg 26d ago

Ambitious! Thumbs up!

1

u/Immediate_Form7831 25d ago

Scariest part is the "push directly to master" IMHO

1

u/SaCorv 25d ago edited 25d ago

Whats the point of if (max_length - offset < 2)?
Your next if statement already covers it
It even would be more readable to have first if as
length < 2
And second as
max_length - offset < length

Tbh its better to avoid complex if statements all together

1

u/wrillo 24d ago

memcpy. I wonder which is greater, the number of vulnerabilities that AI will introduce or the number of vulnerabilities it finds in old hand code.

1

u/BlackHat-Maxwain 21d ago

Okay this is off topic but I have the same speakers as you, is one of them way quieter than the other for you too??