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

https://git.goldelico.com/?p=letux-makesd.git;a=blob;f=makesd;h=b9e61470eab7fec96de4c358a721d420efb76311;hb=HEAD#l192

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

https://git.goldelico.com/?p=letux-uboot.git;a=blob;f=arch/mips/cpu/xburst/ddr_innophy_x1600.c;h=3987ecbc5ed3839b7ed73f24f55ae6bb62058d86;hb=refs/heads/ingenic-x1600#l589

Next it loops over an array of potential RAM chips:

https://git.goldelico.com/?p=letux-uboot.git;a=blob;f=arch/mips/cpu/xburst/ddr_innophy_x1600.c;h=3987ecbc5ed3839b7ed73f24f55ae6bb62058d86;hb=refs/heads/ingenic-x1600#l597

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

https://git.goldelico.com/?p=letux-uboot.git;a=blob;f=tools/ingenic-tools/ddr_creator_x1600/supported_ddr_chips.c;h=597d520310e2c7632d523218ffc2f2f064a5bf73;hb=refs/heads/ingenic-x1600

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

https://git.goldelico.com/?p=letux-uboot.git;a=blob;f=include/ddr/chips-v2/LPDDR2_SCB4BL256160AFL19GI.h;h=66a9fd00d4b21202a200fb54c5d5f323977aba1a;hb=refs/heads/ingenic-x1600

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

https://git.goldelico.com/?p=letux-uboot.git;a=blob;f=arch/mips/cpu/xburst/ddr_innophy_x1600.c;h=3987ecbc5ed3839b7ed73f24f55ae6bb62058d86;hb=refs/heads/ingenic-x1600#l709

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:

https://git.goldelico.com/?p=letux-uboot.git;a=blob;f=arch/mips/lib/bootm.c;h=78bd6992b49eeb2729632ef326a4c79bbb1a9e8b;hb=refs/heads/ingenic-x1600#l192

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.

BR,
Nikolaus



More information about the Letux-kernel mailing list