The developer used an agent to write code to emulate a fairly cheap commodity SoC. Generally no one bothers to do this as the cost of writing an emulator can be high, but the hardware is cheap and readily available so most people just use the hardware. That cost gone now you can throw an agent at it.
You could use such an emulator for CI/CD pipelines, or simulating distributed systems made up of lots of SoCs, or reverse engineering products based on the SoC.
As an example of a similar thing: “I’ve” been building a bare metal HAL/SDK generator for the STM32L4 in pure Nim with a really lovely zero runtime overhead set of abstractions.
I’ve wanted to do this for a few years and knew it was possible, just fiddly. Now the fiddly bit gets done for me, so the fun firmware writing bit can be left to me :)
Heh, not even reverse engineered. OP had the TRM. Writing an emulator while having a TRM is a simple job for a persistent 16 year old (source: i did things like that when i was 16)
Sorry dmitrygr, most if not all of your previously glorious coding achievements worth of HN frontpage can now be done by a guy in his pajamas in a dozen minutes. Go enjoy your mandatory retirement.
One can only hope that at some point readers will realize that if anyone can do it, then what is the point of showing it...
To be fair you don't even need the TRM to do emulation like this. The hardest part (security setup, clocks, PHY drivers) can basically just be a no-op. For the difficult parts (PCI, VOP), you can just reference the kernel drivers.
You're not harsh, you're just so far behind the times that your comment is irrelevant.
I run an Omarchy M2 Macbook Pro laptop (kernel not upstreamed) with a bunch of forked software (not upstreamer) that fits my workflow and my needs. Requiring things be upstreamed in order to be useful is a dead concept.
Yeah but can it run the DDR training blobs? Do that and I'll really be impressed.
edit
> Get the proprietary DDR image working
Wow, shit did you really do this? Or are you simply ignoring the DDR image's writes and feeding it plausible-enough values that it believes "the DDR is trained" and proceeds to the next stage?
Actually emulating the DDR controller would be impressive.
The DDR controller is from Synopsys; most of their DDR controllers are in fact a tiny ARC core (different instruction set). Are you emulating that thing too?
edit
> The current test proves that the image returns success with synthetic controller and PHY responses, not that real DDR training is emulated
Ah, so it's just feeding the DDR training blob whatever values it has to in order to get it to move on to the next step. Too bad. Having a real model of the DDR controller would make it straightforward to write one that's open source... making rk3588 the newest blobless CPU by a large margin.
> Having a real model of the DDR controller would make it straightforward to write one that's open source
With all the link training stuff you leave the easy-to-emulate sphere and go into the RF black magic sphere where digital logic meets physical and legal (EMI compliance) limits. And on top of that you'll have to deal with physical effects relating to the specific manufacture process of both the chip, the packaging and the board layouts.
AI will not be a help for this for a long time to come, a lot of this stuff can't even be simulated accurately but is essentially an iteration process until something eventually produces high enough yields. And no, just pointing an algorithm at a chip and telling it to "make it work, make no mistakes" isn't sufficient - there's a significant chance the algorithm will just make something uniquely tuned to the very specific instance of the chip and its surroundings like that research team in 2007 [1].
There's a middle ground that I think the parent poster is suggesting, where someone could LLM-launder the proprietary blob and documentation; basically, feed the imem/dmem images for the ARC core along with any "obtained" documentation into an LLM and have it write a fudged emulator for the various physical-layer peripherals which the ARC core manipulates to perform training. Then, use that laundered emulator as an oracle to write an "open-source" (for some definition) version of the ARC firmware. That is to say: you don't need to emulate the actual PHYs and RF stuff, you just need to emulate the register states that appear as results in various training states.
I believe this has been done for Tegra and a few other SoCs even pre-LLM using "traditional" RE, both "cleaned" and "dirty" (ie - some where one person read the disassembly for training and re-implemented it, and others where someone produced documentation in the middle).
where someone could LLM-launder the proprietary blob and documentation
To be clear, it's not laundering if you have one LLM look at the binary and write a spec, and the other LLM works only with the spec, and the spec isn't code.
There is decades of court precedent and an entire industry (PCs) behind this.
seems like weirdly specific complaint. You'd only need that if you wanted to develop your own DDR training routine and for that you can just get a board with the chip and try it there...
I tried to get frontier LLMs to do a more faithful DDR training emulation but they really struggled. I'd be interested in trying to push on it harder to create some extended DRAM controller docs and possibly hand write an open source training image
I have and use an opensource DDR training code for all rockchip SoCs I own, from RV1103/6 to RK3588.
Rockchip uses various third party, often Synopsis controllers combined with third party PHYs, often times from Innosilicon, and on some SoCs their own PHY designs (or some modified third-party design). RK3399 used Denali controller from Cadence.
Anyway, emulating the controller is not needed, since QEMU is not emulating DDR bus access when guest is accessing memory. :) If you want to boot from boot rom image, through ddrbin, etc, all you need is to emulate enough to not end up locked in some wait loop in the ddrbin blob.
What significant maintenance are you thinking of that couldn't be done the same way? For a project like this, you're mostly going to stick it in a testbed and forget about it. What's the point of updating unless there is a specific bug?
Yes, LLM are pretty nice for writing machine emulators in qemu. So far I have gotten them to do a mips32 based payment terminal emulation, mips32 voip phone, arm voip phones, etc. You get a working machine up in about 2-3 hours usually.
If you work with embedded HW, this is very nice for testing.
rolymath | 21 hours ago
hogehoge51 | 20 hours ago
xx__yy | 18 hours ago
I'd like to also add: - Hardware WAS hard - Software is now cheap
girvo | 14 hours ago
I’ve wanted to do this for a few years and knew it was possible, just fiddly. Now the fiddly bit gets done for me, so the fun firmware writing bit can be left to me :)
https://git.jgirvin.com/girvo/stm32l4-hal-nim
Very much not complete yet, but man it’s been fun to see a dream I’ve had play out!
dmitrygr | 20 hours ago
Heh, not even reverse engineered. OP had the TRM. Writing an emulator while having a TRM is a simple job for a persistent 16 year old (source: i did things like that when i was 16)
varispeed | 19 hours ago
pbkompasz | 17 hours ago
casept | 14 hours ago
AshamedCaptain | 14 hours ago
One can only hope that at some point readers will realize that if anyone can do it, then what is the point of showing it...
cyberclimb | 13 hours ago
[OP] petabyt | 10 hours ago
clivedup | 20 hours ago
ithkuil | 16 hours ago
Of course it would be better to have it upstream but maintaining an up to date fork is a bit easier nowadays
KetoManx64 | 8 hours ago
I run an Omarchy M2 Macbook Pro laptop (kernel not upstreamed) with a bunch of forked software (not upstreamer) that fits my workflow and my needs. Requiring things be upstreamed in order to be useful is a dead concept.
bogantech | 8 hours ago
octoberfranklin | 20 hours ago
edit
> Get the proprietary DDR image working
Wow, shit did you really do this? Or are you simply ignoring the DDR image's writes and feeding it plausible-enough values that it believes "the DDR is trained" and proceeds to the next stage?
Actually emulating the DDR controller would be impressive.
The DDR controller is from Synopsys; most of their DDR controllers are in fact a tiny ARC core (different instruction set). Are you emulating that thing too?
edit
> The current test proves that the image returns success with synthetic controller and PHY responses, not that real DDR training is emulated
Ah, so it's just feeding the DDR training blob whatever values it has to in order to get it to move on to the next step. Too bad. Having a real model of the DDR controller would make it straightforward to write one that's open source... making rk3588 the newest blobless CPU by a large margin.
mschuster91 | 17 hours ago
With all the link training stuff you leave the easy-to-emulate sphere and go into the RF black magic sphere where digital logic meets physical and legal (EMI compliance) limits. And on top of that you'll have to deal with physical effects relating to the specific manufacture process of both the chip, the packaging and the board layouts.
AI will not be a help for this for a long time to come, a lot of this stuff can't even be simulated accurately but is essentially an iteration process until something eventually produces high enough yields. And no, just pointing an algorithm at a chip and telling it to "make it work, make no mistakes" isn't sufficient - there's a significant chance the algorithm will just make something uniquely tuned to the very specific instance of the chip and its surroundings like that research team in 2007 [1].
[1] https://www.damninteresting.com/on-the-origin-of-circuits/
bri3d | 11 hours ago
I believe this has been done for Tegra and a few other SoCs even pre-LLM using "traditional" RE, both "cleaned" and "dirty" (ie - some where one person read the disassembly for training and re-implemented it, and others where someone produced documentation in the middle).
megous | 10 hours ago
octoberfranklin | 6 hours ago
To be clear, it's not laundering if you have one LLM look at the binary and write a spec, and the other LLM works only with the spec, and the spec isn't code.
There is decades of court precedent and an entire industry (PCs) behind this.
bri3d | 5 hours ago
octoberfranklin | 7 hours ago
AI can definitely help with that.
Yes, you need to provide it a large testfarm of boards.
Maybe one a few with an oscilloscope hooked up to a clock and DQ pin. And remote access to the scope of course.
But it's great at banging its head against the wall until it works.
InsidiousWombat | 15 hours ago
octoberfranklin | 7 hours ago
[OP] petabyt | 10 hours ago
megous | 10 hours ago
Rockchip uses various third party, often Synopsis controllers combined with third party PHYs, often times from Innosilicon, and on some SoCs their own PHY designs (or some modified third-party design). RK3399 used Denali controller from Cadence.
Anyway, emulating the controller is not needed, since QEMU is not emulating DDR bus access when guest is accessing memory. :) If you want to boot from boot rom image, through ddrbin, etc, all you need is to emulate enough to not end up locked in some wait loop in the ddrbin blob.
octoberfranklin | 2 hours ago
I can haz?
davidgerard | 16 hours ago
cool cool, are there plans for ongoing maintenance
PhilipRoman | 15 hours ago
yjftsjthsd-h | 10 hours ago
[OP] petabyt | 9 hours ago
c0deR3D | 14 hours ago
megous | 9 hours ago
If you work with embedded HW, this is very nice for testing.