Rkddr: a rockchip ddr editor

well it is time to make this official. here is the new tool i have been working on lately. With this now it is possible to run rk3588 in ddr5-6400 speed which boosts the overall performance about 20% including gpu.

The tool is located here: https://github.com/hbiyik/rkddr

Below is the copy paste of the readme and what and how it does

rkddr

rkddr is a a DRAM configuration editor for rockchip based devices. To make use of the tool, simply run the sudo rkddr and navigate to the setting that the tui shows. When finished save the configuration, you do not have to do anything more, the tools automagically manages everything , (no need to dd it back to the block device).

TUI when working with blobk device

TUI when working with an idb file

To verify that the new settings are in place, at least for the frequency settings.

cat /sys/class/devfreq/dmc/available_frequencies

should give the new frequencies that you have configured.

working with binary types

if no specific arguments provided, rkddr automatically finds the correct location where the DDR configuration is located and shows it at the header of the tui.

if you want to edit the ddr configuration in a specific block device you can also achieve if with

sudo rkddr -d /dev/path-to-block-device (ie:sdc. or mtdblock1)

if you want to edit the ddr configuration an idblock on your filesystem (ie: u-boot artifacts)

sudo rkddr -i path-to-idblock-file

if you want to edit the ddr configuration in raw ddr blob (ie: the ddr blobs provided by rockchip at https://github.com/rockchip-linux/rkbin/tree/master/bin/rk35)

sudo rkddr -b path-to-raw-ddr-blob

whenever a change is made, a backup of your existing binary is backed up at folder ~/.rkddr/ , for future analysis or recovery

it is also beneficial to check out the help output in case of new features

sudo rkddr -h usage: PROG [options] options: -h, --help show this help message and exit -d, --device DEVICE Work on on the DDR blob inside the found IDB of the given block device -i, --idb IDB Work on on the DDR blob inside the given IDB file -b, --blob BLOB Work on on the DDR blob file given

what are TPL, IDB, DDR Blobs?

When Rockchip is booting, the chip searches a specific format called idblock or IDB for short as specific sector (64 (0x40)) each storage medium.

You can consider idblock as a zip or tar file containing 2 files. 1st is TPL (tertiary boot loader) 2nd is the SPL (secondary boot loader) .

So overall simplified boot process is as below:

`Bootrom (the chip) -> Idblock@64[First TPL -> Then SPL] -> U-boot@32768 -> Kernel and Linux/Android@partition``

In rockchip the first code executed by the CHIP inside the idblock, is TPL. And and this particular TPL is provided by rockchip as closed source, responsible of configuring the DDR memory. That TPL binary is also referred as DDR blob.

It is very beneficial to look at this page for details: https://opensource.rock-chips.com/wiki_Boot_option

Real World results

Since rockchip deals with a lot of OEMs, their blobs are not always tuned up to the spec which is solder as a DRAM chip on the board.

I have noticed that all DDR5 rk3588 boards are tuned with under-frequency, and some rk3528 board are severely capped. So be my guest on trying to find out more.

One thing to note is how dmc governor works on rockchip bsp kernel. When first DDR blob is initialized, it trains the given frequency, and 5 alternative ones.

Once it is trained with the main fequency, it passes those frequencies to kernel. At this point kernel has 2 frequency source, first is what DDR blob provides, 2nd is what is available in the dts.

What kernel does in this case is to iterate each frequency given by the blob, and fetches the voltage from from the DTS which has dts_frequency >= blob_freqency.

So dts dmc opp table is only a lookup table for the voltages. In some cases dts max frequency may not be enough for the blob frequency that the board can achieve, in this case to achieve higher frequncies maximum frequncy in the dts needs to be bumped. ie: https://github.com/hbiyik/linux/commit/c277791c584a3b53b95006f2ddb3ed06d1021f70, this is to achieve ddr5-6400 frequencies in rk3588.

Limitations

Currently only rk35xx boards are supported. It is technically possible to support earlier boards but i dont have any rk33xx so i dont want to blindly copy paste code. Any PR is weelcome int hat regard, you can refer to ddr V0 structure here: https://github.com/rockchip-linux/rkbin/blob/f43a462e7a1429a9d407ae52b4745033034a6cf9/tools/ddrbin_tool.py#L218C1-L219C20 (the part with v0_info)

Warnings

This is not a bios, and there is no clear CMOS jumper or battery. Meaning that if you do somehting wrong, your board can freeze. In such a case, you can manually write your idblock in backups using maskrom . Additionally not likely but possibly, things you enter might physically damage your hardware. You should be taking this responsibility when using this tool.

5 Likes

Like always ! Boogie for president ! :muscle:t2:Thanks !

I’ve also enabled this option for armbian rk3588 builds.
The DTS change is available as an overlay to be enabled through armbian-config. Then you can use boogie’s rkddr to set your DDR clock speed (please note that 6400MT/s == 3200MHz). Happy tinkering :slight_smile:

The related PR: https://github.com/armbian/linux-rockchip/pull/352

3 Likes

Great news, we did not had any reply from Rockchip about DDR5 vs DDR4 topic and You solved it!
How much it can gain from Rock5B (ddr4) vs Rock 5B+ (ddr5)? Any changes in temp and power consumption?
I have no DDR5 RK3588 to test :frowning:

Running at 6400MT/s I observed it consumed 0.5w more on load but it wasn’t some scientific tests I did here. Voltages weren’t changed so heat output shouldn’t be much more

Sounds good. Increased performance may save some power with faster operation.
Any real gain on DDR4 or its only usbale for DDR5?

No that is running at max speed already. Maybe some power saving possible through turning down opp table voltages according to the used modules.

though i agree with all there is always a possiblity that SCMI is just lying to us, and reporting the requested frequency as it was set, but in reality it might be running the frequency whatever the PVTPLL deems appropriate.

I guess we can never know know this unless someones hooks an oscilloscope or frequency analyzer to the board and inspect the ddr clock signal.

I don’t have this file, whole tree /sys/class/devfreq/dmc seems not available on my machine, running linux-image-rock-5b-plus kernel version 6.1.84-6.

Any hint about this?

it could be that your kernel config has not enabled dmc governor.

Looks ok to me:

# zcat /proc/config.gz | grep DMC
...
CONFIG_ARM_ROCKCHIP_DMC_DEVFREQ=y
...

?

Ok, there was something about GPU not tuned with right speed.
So thanks to changes 5B+ and 5T should perform better, anyone already got any benchmarks? difference should be visible even in geekbench.

Yes I wrote an article: https://sbcwiki.com/news/articles/tune-your-rk3588/

The Rock5-ITX models also get that performance boost. GPU 1GHz fix is merged to Armbian as of today too

It would be great for most users just to get optimised image and information what are the differences, timing and results. I don’t know how risky is to set new values for DDR5, but this still sounds not like overclocking but fix.
@tkaiser revisited his article with 6.8 kernel comparison, but he also used older 5.1 instead of BSP 6.1 (why it was skipped?). For now I briefly checked idle power consumption for bsp 6.1, mainline 6.14 and collabora release (I think it was 6.13) and still everything except bsp have +2.5W more idle power consumption. Still it’s not clear for me if Thomas fixes are already applied, is Armbian still patching only per device as mentioned in Your article and how to get that final configuration?

can You please try to make geekbenches using sbc-bench? It’s not perfect tool, but makes bunch of operation, easy to compare on web. It should clearly improve after those tweaks.

I forget about that one. Sure it also has DDR5 :slight_smile:

And this one is overclocking or optimisation? Is it also DDR5 only fix or generally for RK3588?

1 Like

So for LPDDR5 if the TRM is to believed it would be an overclock for the SoC memory controller (without modifiying voltages) as it only is optimized for LPDDR5-5500MT/s but what boogie noticed is that not only does Radxa use faster RAM modules but also that you can edit the values to make use of the actual ram modules rated speeds. In his and my testing it has been stable but we can’t say if that applies to all and since TRM says LPDDR5-5500 we’re saying that it’s rather an overclock.

GPU is a bug fix.

Is it possible to apply the same boost on Rock 5B+ running Ubuntu? And what are the practical steps to do so?