Show HN: RK3588 QEMU emulator running unmodified Armbian images

55 points by petabyt 22 hours ago on hackernews | 33 comments

rolymath | 21 hours ago

Can someone explain the ramifications of this

hogehoge51 | 20 hours ago

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.

xx__yy | 18 hours ago

That is a great explanation, thank you.

I'd like to also add: - Hardware WAS hard - Software is now cheap

girvo | 14 hours ago

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 :)

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

> I gave it the leaked RK3588 TRM

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

2 year old LLM would do it.

pbkompasz | 17 hours ago

I did it when I was 15

casept | 14 hours ago

For a modern SoC with a bunch of non-trivial IP blocks?

AshamedCaptain | 14 hours ago

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...

cyberclimb | 13 hours ago

Yeah well I did it when I was 4 before I could even read so get good

[OP] petabyt | 10 hours ago

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.

clivedup | 20 hours ago

Sorry to be harsh, but the only thing worth demo'ing is getting such emulation accepted by upstream Qemu. That would be awesome!

ithkuil | 16 hours ago

Why? A fork can be useful if the alternative is not having a solution at all.

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

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.

bogantech | 8 hours ago

Most forks like this won't get as much love as Omarchy does, they won't be maintained and it'll become difficult to update as the upstream moves on

octoberfranklin | 20 hours ago

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.

mschuster91 | 17 hours ago

> 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].

[1] https://www.damninteresting.com/on-the-origin-of-circuits/

bri3d | 11 hours ago

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).

megous | 10 hours ago

rkbin blob for rk3588 doesn't deal with any ARC firmware. And RK3588 TRM has about 500 pages of documentation for the controller. ;)

octoberfranklin | 6 hours ago

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.

bri3d | 5 hours ago

Laundering - as in, it makes it clean - I suppose I was using the term too casually, but we agree :)

octoberfranklin | 7 hours ago

essentially an iteration process until something eventually produces high enough yields.

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

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...

octoberfranklin | 7 hours ago

The DDR training blob is the weirdly specific only non-open-source blob you need to run an RK3588.

[OP] petabyt | 10 hours ago

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

megous | 10 hours ago

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.

octoberfranklin | 2 hours ago

I have and use an opensource DDR training code for all rockchip SoCs I own, from RV1103/6 to RK3588.

I can haz?

davidgerard | 16 hours ago

> Mostly done by GLM5.3

cool cool, are there plans for ongoing maintenance

PhilipRoman | 15 hours ago

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?

yjftsjthsd-h | 10 hours ago

Alternatively: It's useful to keep up with a current version... which is also easy, since an AI that can implement functionality can easily rebase it.

[OP] petabyt | 9 hours ago

I've already been working on a rockchip firmware for a few years now so I probably will continue pushing on this for a while, just as a personal tool

c0deR3D | 14 hours ago

Does TI PocketBeagle 2 has any equivalent?

megous | 9 hours ago

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.