How to load devicetree file to allow driver to attach?

Hi-

I’m trying to load a driver built as a module and get it to attach to particular gpios via a devicetree file, but I must be missing some critical piece of info.

The driver in question is the hx711 driver, and I can build the .ko file fine, and load it with insmod, but the probe function is never called, I assume because there’s no “compatible” in the DTB file which is loaded at boot. I put together this dts overlay:

/dts-v1/;
/plugin/;

/ {
        compatible = "nvidia,p3542-0000+p3448-0003", "nvidia,jetson-nano-2gb", "nvidia,jetson-nano", "nvidia,tegra2
10";
        fragment@0 {
                target-path="/";
                __overlay__ {
                        hx711: hx711 {
                                compatible = "avia,hx711";
                                sck-gpios = <&gpio 14 0>; // 0 == GPIO_ACTIVE_HIGH
                                dout-gpios = <&gpio 50 0>;
                                status = "okay";
                        };
                };
        };
};

…which I’m intending to attach GPIO50 (pin 11 of the 40-pin header) to the dout function and GPIO14 (pin 13 of the header) to the sclk function. I compiled it with dtc -@ -I dts -O dtb -o hx711.dtbo hx711.dts, then put hx711.dtbo in /boot… how can I tell for sure if it’s being loaded? What am I doing wrong, here?

I have some debugging in the hx711_probe() function which should logged to /var/log/kern.log when the device is probed, but it never gets called - so I assume the .dtbo isn’t being loaded. Advice welcome.

Thanks,
+j

Hi,

you can run the command dtc -I fs -O dts /sys/firmware/devicetree/base on the jetson to check the currently loaded device tree. Hope that can point you in the right direction.

That definitely helps: I can see that it is not being loaded - is there some way to load a .dtbo besides sticking in in /boot and rebooting? (Something akin to insmod but for devicetree)

I’m not entirely sure honestly, I think there is something weird with how the dtb, dtsi, dtbo, etc files are being put together on the jetson, but I’m probably not going to have time to figure it out. I solved my SPI problems by directly modifying the dtb that is loaded with the ./flash.sh command, and not bothering with overlays.

1 Like

You can check /boot/extlinux/extlinux.conf and a a FDT field inside it so that you can assign the bootloader to read the dtb from file system. If no such setting in extlinux.conf, by default the bootloader will read dtb from the partition. That is how flash.sh installed the dtb.

If you don’t know how to add, search “FDT” on the forum and you shall find many similar posts.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.