7Ji-PKGBUILDs / .meta

1 stars 0 forks source link

`linux-aarch64-7ji`: device tree overlays #16

Closed acegallagher closed 10 months ago

acegallagher commented 10 months ago

Hello there. Thank you for any and all effort you've put into this. It's very helpful. I'm currently running the most recent version of this package. I would like to boot with device tree overlays but those don't seem to be in mainline. Shouldn't building the overlays be as simple as grabbing them from the orangepi repository here and adding the build steps to the PKGBUILD to insert them into the new kernel?

https://github.com/orangepi-xunlong/linux-orangepi/tree/orange-pi-5.10-rk3588/arch/arm64/boot/dts/rockchip/overlay

I'm going to try to do that and might come with a patch. Thanks much

7Ji commented 10 months ago

They should work, and you don't even need to build them in the kernel tree. The overlays work across kernels as long as the symbols match, and here it is a problem: mainline uses different symbols from vendor, at least for some of them.

To build a overlay you need, without a kernel tree, you can refer to https://github.com/7Ji/device-trees

7Ji commented 10 months ago

Closed by https://github.com/7Ji/device-trees/commit/2290ab19a9fe64b33c468952605f6cd2161e63e3

Just clone the project, run make, and pick overlays you need and try them out.

acegallagher commented 10 months ago

Hmm. Thanks a bunch for taking the time to help me here. That's similar to what I tried to do. I made a build script and compiled all the overlays while running the "7ji" 6.7.1-2 and then put them into the boot directory and added the proper overlay to extlinux.conf and I got the following error:

Retrieving file: /dtbs/linux-aarch64-7ji/rockchip/overlay/rk3588-can1-m1.dtbo
reading /dtbs/linux-aarch64-7ji/rockchip/overlay/rk3588-can1-m1.dtbo
343 bytes read in 3 ms (111.3 KiB/s)
failed on fdt_overlay_apply(): FDT_ERR_NOTFOUND
Failed to apply overlay /dtbs/linux-aarch64-7ji/rockchip/overlay/rk3588-can1-m1.dtbo, skipping
Fdt Ramdisk skip relocation

I just compiled the sources from the github repo you've linked here and the md5sum of the resulting "dtbo" files from your Makefile match the md5sum of the files I compiled myself. Perhaps this is what you're getting at with the symbols? Do I need to modify the symbols in some dts files for the 6.7 kernel?

Sorry. I'm in over my head a little here. Thanks again.

7Ji commented 10 months ago

Perhaps this is what you're getting at with the symbols? Do I need to modify the symbols in some dts files for the 6.7 kernel?

Yeah you've got the basic idea. The FDT is a tree-like data structure, and you must declared a correct path/node that already exists in tree before you could modify the node.

/dts-v1/;
/plugin/;

/ {
        fragment@0 {
                target = <&can1>;

                __overlay__ {
                        status = "okay";
                        pinctrl-names = "default";
                        pinctrl-0 = <&can1m1_pins>;
                };
        };
};

In this case the overlay declares to modify a node with alias "can1", but it doesn't exist in the mainline DT.

7Ji commented 10 months ago

I've checked the mainline dt, it seems both "can1" and "can1m1" exist, but "can0/1/2" don't have aliases like vendor dt. So you'll need to use a full path "&{/pinctrl/can1}" like this overlay:

https://github.com/7Ji/device-trees/blob/master/overlay/meson-sys-led-default-off.dts

7Ji commented 10 months ago

This should work, but I couldn't test it as I don't have any CAN device

https://github.com/7Ji/device-trees/commit/7b16096ec12c1c0acaa9c84a98ac58ecb24f1b79

At least the overlay could be applied without error:

> fdtoverlay -i /tmp/rk3588-orangepi-5-plus.dtb rockchip-bsp5.10-rk3588-can1-m0.dtbo -o /tmp/merged.dtb

Failed to apply 'rockchip-bsp5.10-rk3588-can1-m0.dtbo': FDT_ERR_NOTFOUND
> fdtoverlay -i /tmp/rk3588-orangepi-5-plus.dtb rockchip-rk3588-can1-m1.dtbo -o /tmp/merged.dtb
acegallagher commented 10 months ago

Hello there again. Thank you for the explanation. Could you kindly link me to the "mainline DT" that I should reference to dig into this? Or examples of other dts files that would help me. I tried your modification (and some of my own) and although I was able to apply it without error the proper can device doesn't show on boot.

When the can device is properly enumerated "ifconfig -a" will show a can0 network device that you can then interact with if properly wired. So even without a device you can tell if it was properly enumerated. This works correctly in 5.10.

It's tangential, but it seems 6.7 doesn't have support for /sys/class/thermal/thermal_zone*/temp ? It has been very fun digging into your work here. Thanks for maintaining such an excellent package base and all that you do here and doubly so for helping me understand what's happening with the overlays. I'm using orangepis for processing data remotely in my research and your work has been very helpful.

7Ji commented 10 months ago

Could you kindly link me to the "mainline DT" that I should reference to dig into this?

https://github.com/7Ji/linux/blob/amlogic/arch/arm64/boot/dts/rockchip/rk3588-orangepi-5-plus.dts

You'll also need to follow all those "include" files to track down all of the nodes that would be present in the result DTB.

You can also just de-compile from a DTB to get the preprocessed DTS (in a sense like C, where #include files all included before the actual coded), but this would lack the comments and all aliases would be squashed into the /aliases node, so things would be harder to follow:

dtc -I dtb -O dts /boot/dtbs/linux-aarch64-7ji/rockchip/rk3588-orangepi-5-plus.dtb -o /tmp/5p.dts

6.7 doesn't have support for /sys/class/thermal/thermal_zone*/temp

Mainline 6.7 is far from ready for everyday use on RK3588. The -7ji kernel here is mostly mainline but with very few of my patches applied to make it work on a few of my Amlogic devices, but none of RK patches are backported here (more patches = more difficult to keep updating, especially I need to keep it updated every week). That's just one of the things missing. If you want kinda ready-to-use 6.7, use linux-joshua-git, which tracks Joshua-Riek's kernel tree, in which he actively backport A LOT of patches.

When the can device is properly enumerated "ifconfig -a" will show a can0 network device that you can then interact with if properly wired.

That's because I've not enabled the CAN driver, it's not working as the kernel lacks any CAN support:

https://github.com/7Ji-PKGBUILDs/linux-aarch64-7ji/blob/ec8a5799f9a64f583cdab0364b4ef95899cc6ead/config#L1808

I would enable that and bump the kernel later.

7Ji commented 10 months ago

https://github.com/7Ji-PKGBUILDs/linux-aarch64-7ji/commit/edfcb18a62aa551470e2b0070fba5768f4bcacd9

I've enabled all possible CAN drivers. The package was synced to the repo a few minutes ago:

https://github.com/7Ji/archrepo/releases/download/aarch64/linux-aarch64-7ji-6.7.1-3-aarch64.pkg.tar.zst