I'm giving this agentic coding another try. I can give Claude Sonnet 4.5 the HTML versions of the reference manuals and the CMSIS headers and it'll actually use them. And it understands Jinja2 templates. And it's actually fairly accurate. This is getting uncomfortably useful?
Arguably you could just translate the STM32 LL HAL though, and I'm sure they trained on it, cos it sometimes regurgitates that. So I wonder how much of this is actually using the HTML and how much is just in it's training data. Maybe giving it access to the LL headers would make it even better?
Hm, it's not great at logic problems like finding out which registers are available on which devices. But at least it can write helper tools that are *almost* correct (see the CRGR3). I need to clean this up and scale it to all STM32 devices and put it online.
To be clear: I still have to review and fix the code for *hours* because the coding agents simply do not understand the logic part of generating C++ HAL code using Jinja2 templates. I would have to provide them tooling to query the differences and find short filters, but if I have these tools, I might as well write the code myself again. So we are again mainly limited by tooling for hard problems.
However, what this thing is really good at: rage baiting me into reviewing the generated code. It unblocks me by just *starting* the task, even if it's shitty. I often am unmotivated to refactor because of the mind-numbing amount of just… pushing code around. The coding agents make that much less painful, even if it's imperfect. I just kinda wish it were available locally.
Another takeaway from this experiment is that none of these datasheet AI companies have any moat. I can dump in my HTML versions of the PDF reference manual and ask it questions, and the answers are very, very accurate. There were several parts that I didn't fully understand in the RM, and the LLM just gave me code that I was able to walk through with the RM for better understanding. All these companies are just one prompt extraction away from bankruptcy.
I wrote a small tool for Copilot to check for register existance and it works great at generating valid Jinja2 filters. Of course the tool could be smarter, here the conditional could be `target.name[1] in "23"`, but that kind of pattern matching was hard to implement for me, thus I'm doing it manually during the review.
@salkinium do you publish these extracted register description data somewhere? I have my register access codegen tools, but STM32 SVD files are, you know... not that great 😅
@xorly Here's a Gist with my current state. I wanted to polish this and put into modm-data repo and the publish the generated HTML somewhere on data.modm.io with a search function. I won't have time to do that in the short term tho.
https://gist.github.com/salkinium/f379bfd426ee13d1aa2ff8b234777846
Some hacky vibe coded scripts to read CMSIS Header files and check for differences in CPP definitions

Some hacky vibe coded scripts to read CMSIS Header files and check for differences in CPP definitions - compare_registers.html.in

Gist
@xorly The "proper" way to do this is to compile the header files to resolve their numeric values and then reconstruct the register hierarchy from the naming conventions. I need to finish this work, cos then you can convert the header files into CMSIS-SVD files properly.
https://github.com/modm-io/modm-data/blob/a8568e4d6d27262f817739a338e559cbe28e7054/src/modm_data/cubehal/header.py
modm-data/src/modm_data/cubehal/header.py at a8568e4d6d27262f817739a338e559cbe28e7054 · modm-io/modm-data

Hardware Description from Technical Documentation. Contribute to modm-io/modm-data development by creating an account on GitHub.

GitHub
@salkinium
We implemented C++ Refactoring tooling between 2006 and 2019 when I left HSR Rapperswil. unfortunately project went extinct.
@PeterSommerlad Unfortunately most parts of the C++ modm HAL are heavily templated with Jinja2 statements, so you cannot use any tools that operate deterministically. I even have to turn off syntax highlighting for some files, since it just generates colourful garbage. So I kinda dug myself into a hole there… 😒