[Letux-kernel] x1600: how RAM size is determined

H. Nikolaus Schaller hns at goldelico.com
Sat Mar 2 18:35:17 CET 2024

I think I have understood how RAM size is made known to the kernel and which knob to turn for making the x1600e RAM available to the kernel.

1. makesd

When burning an µSD for booting the LX16 board with x1600 processor we can use the tool "makesd lx16".

This downloads the SPL und U-Boot binaries and copies them to the µSD (outside the rootfs).


The binaries stored on the download server have been patched at address 0x4480 and 0x4488 with the RAM id value 0x1b mentioned below before uploading.

2. SPL

The first stage loader reads a code at fixed offset 128 of the SPL_TEXT_BASE (and a copy at offset 130 must be identical):


Next it loops over an array of potential RAM chips:


until it finds a matching id.

The table of the known RAM chips and ID codes is in a file called include/generated/ddr_reg_values.h
Unfortunately (?) it is hidden by .gitignore. So I assume that this list is generated on demand by some tool from other information.
The tool and the main table is here (just a different format):


The raw definition of such a chip is for example here:


The chip type is logged to the console by SPL.

For the x1600 (not x1600e) case this contains a record with .h.id = 0x0000001b for some 32 MB RAM.

Then, ram_size is calculated in


This ram_size is passed to U-Boot (by some mechanism I haven't analysed) where it is translated and appended as a new kernel parameter:


This becomes e.g. "mem=32M at 0x0".

3. kernel

Kernel takes the kernel parameter mem= and assumes it works.

So we just have to find the right .id to patch into the SPL. This should be possible by running the vendor cloner tool to bake µSD cards in circuit with booting over USB. And then reading out the config bytes.


More information about the Letux-kernel mailing list