Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduced RAM in X96 Max+ A100 -- dtb mistake #602

Closed
taras-filatov opened this issue Jun 9, 2024 · 13 comments
Closed

reduced RAM in X96 Max+ A100 -- dtb mistake #602

taras-filatov opened this issue Jun 9, 2024 · 13 comments
Labels
documentation Improvements or additions to documentation support This need is supported

Comments

@taras-filatov
Copy link

Device Information | 设备信息

  • SOC: S095x3
  • Model: X96 Max+ A100 (4G RAM, 64G flash, 100Mb ethernet)

Issue about corresponding dtb.
From model_database.conf:
my model: 505 :X96-Max+_A100
my SoC: s905x3
my fdt file: meson-sm1-sei610.dtb

I noticed, that in openwrt/armbian with that dtb (meson-sm1-sei610.dtb) all running good, but available ram less than 1GB.
Hardware -- 4GB

in meson-sm1-sei610.dtb decompiled memory description:

        #address-cells = <0x02>;
        #size-cells = <0x02>;
        memory@0 {
                device_type = "memory";
                reg = <0x00 0x00 0x00 0x40000000>;
        };

thus limiting ram to 1073741824 bytes, 1G.

I extract and decompile dtb from firmware. There are 3 dtb's in one, Amlogic multi dtb. Bootloader make desision while boot and select variant 2 (from 0-1-2):

      Amlogic multi-dtb tool
      GZIP format, decompress...
      Multi dtb detected
      Multi dtb tool version: v2 .
      Support 3 dtbs.
        aml_dt soc: sm1 platform: ac213 variant: 4g
        dtb 0 soc: g12a   plat: u212   vari: 4g
        dtb 1 soc: sm1   plat: ac213   vari: 2g
        dtb 2 soc: sm1   plat: ac213   vari: 4g
      Find match dtb: 2

In that variant:

        model = "Amlogic";
        amlogic-dt-id = "sm1_ac213_4g";
        compatible = "amlogic, g12a";
        interrupt-parent = <0x01>;
        #address-cells = <0x01>;
        #size-cells = <0x01>;
...
        memory@00000000 {
                device_type = "memory";
                linux,usable-memory = <0x100000 0xf0800000>;
        };
...

Same way of memory description is in other dtb's in this bundle, and in dtb's from official armbian, LibreELEC, CoreELEC: defined only linux,usable_memory (memory reservation for kernel recovery purposes, afaik)

And only in device tree from running Android system (not extracted from blob, but from runnning /proc filesystem)
we see info about ram size:

        memory@00000000 {
                device_type = "memory";
                linux,usable-memory = <0x100000 0xf0800000>;
                reg = <0x00 0xd8000000>;
        };

It looks lite there is no need to hardcode RAM size in dtb -- system add it for application usage. All difference withing dtb's now is linux,usable-memory. in meson-sm1-sei610.dtb it equals to my orig dtb. But actually it can be ommited as I see no realisation of kernel recovery....

I propose corrected dtb -- without limit of RAM (reg record), hope you add it to build.

meson-sm1-sei610-fullram.dtb.gz
meson-sm1-sei610-fullram.dts.gz

@ophub
Copy link
Owner

ophub commented Jun 9, 2024

https://github.com/unifreq/linux-6.1.y/blob/main/arch/arm64/boot/dts/amlogic/meson-sm1-sei610.dts

https://github.com/unifreq/linux-6.1.y/blob/main/arch/arm64/boot/dts/amlogic/meson-sm1-x96-max-plus-q2.dts

The meson-sm1-sei610.dts is a generic file provided by the kernel source, and it is used by many DTS applications. It is not recommended to modify it directly. Instead, you can generate a new DTS file based on this one. For example, as shown in meson-sm1-x96-max-plus-q2.dts, you can include an existing file and rewrite the sections that differ to create a new DTS file with a different name. It is recommended to create a new file in this manner, perhaps naming it meson-sm1-x96-max-plus-a100.dts

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)

/dts-v1/;

#include "meson-sm1-sei610.dts"

/ {
	compatible = "x96-max-a100", "amlogic,sm1";
	model = "X96 MAX+ A100";

	memory@0 {
		device_type = "memory";
		// reg = <0x0 0x0 0x0 0x40000000>;
		linux,usable-memory = <0x0 0x100000 0x0 0xf0800000>;
	};
};

@ophub
Copy link
Owner

ophub commented Jun 9, 2024

meson-sm1-x96-max-plus-a100.zip

Snip20240609_2

I tested the compilation, and it works fine. You can extract the files and upload the DTB file to the /boot/dtb/amlogic/ directory of the Armbian system. Then, modify the DTB name in /boot/uEnv.txt to meson-sm1-x96-max-plus-a100.dtb, and try rebooting.

@ophub ophub added the documentation Improvements or additions to documentation label Jun 9, 2024
@taras-filatov
Copy link
Author

taras-filatov commented Jun 9, 2024

yep... "#include" is good idea, when working in large source tree, like openwrt. I do so there while building for modded tplinks.
But, I see, you added new model, thanks!
Vanilla dtc (from my debian, or maked by me now from git.kernel.org source) cannot cope with #include directive in any way...

Oh, I find it, dts with #include should be preprocessed first with cpp (hope, you know it, I had not)

cpp -nostdinc -I include -I arch  -undef -x assembler-with-cpp meson-sm1-x96-max-plus-a100.dts meson-sm1-x96-max-plus-a100.dts.preprocessed
dtc -I dts -O dtb -o meson-sm1-x96-max-plus-a100.dtb meson-sm1-x96-max-plus-a100.dts.preprocessed

And in any case file you send (dtb) still has limit to 1G.
And it's because that in order to vanish reg parameter from memory@0 clause original clause (memory@0) shold be deleted first with /delete-node/. So we have:

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2024 taras-filatov, unifreq.
 */

/dts-v1/;

#include "meson-sm1-sei610.dts"

/ {
        compatible = "x96-max-a100", "amlogic,sm1";
        model = "X96 MAX+ A100";


/delete-node/ memory@0;

        memory@0 {
                device_type = "memory";
                // reg = <0x0 0x0 0x0 0x40000000>;
                linux,usable-memory = <0x0 0x100000 0x0 0xf0800000>;
        };
};

meson-sm1-x96-max-plus-a100-corrected.zip

@ophub
Copy link
Owner

ophub commented Jun 10, 2024

a100.zip

try again.

@taras-filatov
Copy link
Author

all fine now. Thank you!

@ophub
Copy link
Owner

ophub commented Jun 11, 2024

Take a screenshot of the terminal information page where the correctly recognized memory size can be seen.

Take photos of the box, both front and back, and share them.

Does your A100 have an Android system? If so, please provide a download link, and I will save a copy.

@ophub
Copy link
Owner

ophub commented Jun 11, 2024

Thank you for sharing, the file has been added to the upstream kernel repository.

https://github.com/unifreq

@ophub ophub added the support This need is supported label Jun 11, 2024
@taras-filatov
Copy link
Author

taras-filatov commented Jun 11, 2024

Photos... Actually my model is "X96Max+ A100", and really corrrespond to described in mode_database.inf, and looks like on photos here ophub/amlogic-s9xxx-armbian#779
but ok...
box bottom no mac
box top
plate bottom no mac
plate top

@taras-filatov
Copy link
Author

Screenshots -- harder, my hdmi is burned out, and I still do not know, how to fire up cvbs on armbian/openwrt. I hope you're really do not want them, but info from device. So I attach logs with android boot and with openwrt boot.
android.log
openwrt.log

@taras-filatov
Copy link
Author

taras-filatov commented Jun 11, 2024

Android --- yes, present. Now is mod by Slimboxtv.ru" based on original fw (only one variant of original i know, available there too).
this is "X96Max Plus" page https://slimboxtv.ru/x96max-plus/
here (russian) -- info about detection of modification/variant https://4pda.to/forum/index.php?showtopic=1013103&st=40#entry102780026/
so my var is A100...
official fw https://disk.yandex.ru/d/rWmujBT9io2wag/
current slimboxtv 9 fw ATV/AOSP https://disk.yandex.ru/d/lr_HyGGilnzDzw/

@taras-filatov
Copy link
Author

don't close thread, I'll check one issue...

@taras-filatov
Copy link
Author

Oh! I see, source dtb (meson-sm1-sei610.dtb) is changed. In compare with mine, from your pre-latest release. The main issue is ok -- memory limit removed.
But now besides other things, changed paths to wifi devices.... But warnings of dts while decompilng is reduced too.

@taras-filatov
Copy link
Author

So that's all, problem solved. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation support This need is supported
Projects
None yet
Development

No branches or pull requests

2 participants