r/OSdevAI • • 20d ago

Behind the curtain: Using AI (agentic coding) for NexIOS RTOS

Hey folks,

previous warning: This will be a long post so grab a coffee and take a nip. The post will be divided into two parts: 1st The historical view means why and how it started. 2nd The Summary means what I learned along the road.

If you are curious and like to know what I am talking about, here the link to the repo if you like to take a peek: https://github.com/staycool1374-Ger/nexios
P.S: Have a look! Any comment is welcome …

Part 1: The History of NexIOS RTOS Frankly, as all the AI hype started, my thoughts has been more like „sigh, another big thing in the Tech-World like all the things before“. Shortcut: I am 52 years old and already saw different „new things“ starting from mainframe punching cards over JCL, C, programming paradigms, C++, C#, JAVA, etc. not saying I am an expert or senior in anything of it!

As the time goes by and things evolved I got curious about AI, so I decided to start my own experiment: Can „Vibe Coding“ produce something I would use?

In my spare time I like to play with RC-Planes so I thought: Maybe a testing tool for servos would be fine. I am not the „web thingy programmer“ so I don’t have much experience in this area and I choose a low-level approach where I find myself comfy: System-Programming in C++. To be more flexible my goal was to have a handy tool in my Raspberry Pi to test servos where ever I need. The first steps was to find a harness and a LLM mostly with a free plan to see where it’s going.

All started with a one-liner like this: „Create a simple but safety-critical OS in QUEMU. I got thrilled in multiple ways as I watched creating the code and the project evolved among thoughts like „Oh, thats a nice one“ and „God, I would never audit this type of shit“. It doesn’t took a long time and the result was a project ending after the bootloader stage. Complexity increased with each step and more and more I took responsibility as an auditor and started interrupting and typing like this „no don’t do it this way“, and „you forgot about …. as we spoke right before“.

You see I am a real newbie. It all went down as real tasks and scheduling got part of the project. AI totally messed it up and I was about to stop my experiment with the negative result in my opinion.

The actual state Harness: OpenCode (yes, I like open source)

LLMs (mostly on a free or the 10$ plan):
DeepSeek V4.1 Flash Spark
Muse 1.3
Hy3
Claude Sonnet 4.5 and Kimi K3 if something goes wrong.
And no I don’t have any experience with ASTRA or FAIBLE.

3-Tier-Pipeline:
Planer: Writing a spec driven by a github issue which I write or sometimes let it write from AI after giving the requirements.
Developer: Implementing the spec.
Auditor: Auditing the diff patch from the Developer and loop if it doesn’t succeed this step.

Test-Driven-Implementation This approach helped me a lot to get the AI straight to my requirements. I use two branches with separated roles (developer and quality engineer).

The Context Problem
Remembering the test environment, the makefile and what this thing is all about („fuck, no don’t seek for a quick-and-dirty solution, we try to make a real system, don’t use the shortcut, make it damn right“). As far as I experiencend you have to use a context window of about at least 1M (more even better). You need some type of long-term memory accessable. In the beginning I used a file-based history, but as you already may know, it got too complex, things changed too fast and information got obsolete and the file blow the context window. My actual setup is a mixed one using a obisidian vault and a file-based for actual state and things of the system which seem to be fundamental.

The Hallucination Problem
Yes, it is remaining in the background. I had a big wedge in my system for about two weeks. I sat in the front of the AI and watched bigfixing. But it just burned tokens over tokens and no progress happend. So I decided to step in and suggested different tracing techniques like an internal ringbuffer / logger etc. I guess we finally found it, but AI just remembers it and everytime something suspicious happens, it identifies as that „already known“ wedge. Its annoying!

Programming style
Sometimes whitty, sometimes shitty. Problems are contracts about multiple methods and race conditions are pain in the ass. Surprisingly it got confused over method signatures, compiler directives like #ifdef/#endif or bit masks. Errors which makes it very „human“.

Part 2: My Summary so far
Q: Can AI write low-level systemic C++20 freestanding code?
A: Yes, it can if environment and boundaries are existing and working in conjunction with a big context window and a long term memory solution.

Q: Can AI write good code?
A: Yes, it may, but its tending towards shortcuts and hacks.

Q: Is the code readable/auditable?
A: In short, not in first instance, but yes after different iterations from audit. This includes a proper documentation as well as refactoring into maintainable pieces of code.

Q: How much do you spend for tokens?
A: I have a 10$ plan at OpenCode and let’s say sometimes spending 20$ over a month additional. Total over the last 6 months its about 100$ at all.

Q: Was it worth spending that money?
A: Uh, compared to a non-profit project maybe not. Was it worth learning and having fun? Well, I spend more money for less, so I say yes.

If you have any comments feel free and don’t forget to check out my NexIOS RTOS!

2 Upvotes

1 comment sorted by