How to enable Beaglebone Black CANbus interface with Yocto

Hello,

I’v got a BBB Rev.C, and wanted to learn how to use yocto with it
.
I’m starting out using poky’s beaglebone-yocto build for a core-image-minimal and flashing it onto an SD card.
Using a custom meta-layer, I apply patches to modify the device tree to enable the can0 interface, but I still don’t see the can0 interface when running ip addr on BBB.
I’ve also modified the kernel config to support CAN.

How am I modifying the device tree?
using devtool, I create patches to am335x-bone.dts and am335x-boneblack.dts just in case.
They look like this:

+
+
+&am33xx_pinmux {
+       dcan0_pins_default: dcan0-default-pins {
+               pinctrl-single,pins = <
+                       AM33XX_PADCONF(AM335X_PIN_UART1_CTSN, PIN_OUTPUT, MUX_MODE2)
+                       AM33XX_PADCONF(AM335X_PIN_UART1_RTSN, PIN_INPUT, MUX_MODE2)
+               >;
+       };
+};
+
+&dcan0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&dcan0_pins_default>;
+       status = "okay";
+};

in location: meta-bbb-custom/recipes-kernel/linux/linux-yocto
with the bbappend file:
meta-bbb/custom/recipes-kernel/linux/linux-yocto_6.6.bbappend
pointing to the patches.

Is there something I am missing?

This is a project I’m attempting to learn more about yocto, device tree and canbus, so any advice or improvements are appreciated.

I’ve continued playing with the device tree to no avail.
Instead of relying on yocto’s patches, I started manually editing the device tree for testing.
The device tree in question is : am335x-boneblack.dts from beaglebone-yocto.

I added the following, and although it shows up in the /proc/device-tree, I still don’t see a can1 interface.

&am33xx_pinmux {
        bb_dcan1_pins: pinmux_dcan1_pins {
                pinctrl-single,pins = <
                        AM33XX_PADCONF(AM335X_PIN_UART1_TXD,PIN_INPUT_PULLUP, MUX_MODE2)
                        AM33XX_PADCONF(AM335X_PIN_UART1_RXD,PIN_OUTPUT_PULLUP, MUX_MODE2)
                >;
        };
};

&dcan1 {
        compatible = "ti,am3352-d_can";
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&bb_dcan1_pins>;
};

I noticed in my first post I was using the wrong pins.

Are you actually compiling the drivers either into the kernel or as modules ?

Into the kernel. I see in dmesg | grep can

can: controller area network core
can: raw protocol
can: broadcast manager protocol
can: netlink gateway - max_hops=1
can: SAE J1939
can: isotp protocol (max_pdu_size 8300)

I’ve tried to follow the device tree in: dtb-rebuilder/src/arm/am33xx.dtsi at 4.14-ti · RobertCNelson/dtb-rebuilder · GitHub

dcan0: can@481cc000 {
			compatible = "ti,am3352-d_can";
			ti,hwmods = "d_can0";
			reg = <0x481cc000 0x2000>;
			clocks = <&dcan0_fck>;
			clock-names = "fck";
			syscon-raminit = <&scm_conf 0x644 0>;
			interrupts = <52>;
			status = "disabled";
		};

And have modified my device tree to:

&am33xx_pinmux {
        bb_dcan1_pins: pinmux_dcan1_pins {
                pinctrl-single,pins = <
                        AM33XX_PADCONF(AM335X_PIN_UART1_TXD,PIN_INPUT_PULLUP, MUX_MODE2)
                        AM33XX_PADCONF(AM335X_PIN_UART1_RXD,PIN_OUTPUT_PULLUP, MUX_MODE2)
                >;
        };
};

&ocp {
        can@481d0000 {
                compatible = "ti,am3352-d_can";
                ti,hwmods = "d_can1";
                reg = <0x481d0000 0x2000>;
                clocks = <&dcan1_fck>;
                clock-names = "fck";
                syscon-raminit = <&scm_conf 0x644 1>;
                interrupts = <55>;
                status = "okay";
                pinctrl-names = "default";
                pinctrl-0 = <&bb_dcan1_pins>;
        };
};

and now I get a platform error, so progress?

platform 481d0000.can: Cannot lookup hwmod 'd_can1'

I don’t know what this hwmod is, any ideas where to look?
I read it has to do with gpio of sorts, but don’t know how to set it up for can.

Another attempt.
This time I went down to yocto version thud to user Kernnel linux 4.18 as that seems close to the one used in the debian version.
Made sure to compile the can drivers (dmesg | grep can:

can: controller area network core (rev 20170425 abi 9)
can: raw protocol (rev 20170425)
can: broadcast manager protocol (rev 20170425 t)
can: netlink gateway (rev 20170425) max_hops=1

I modified the am335x-boneblack.dts to have:

&uart1 {
        status = "disabled";
};

&am33xx_pinmux {
        dcan1_default_pins: dcan1_pins {
                pinctrl-single,pins = <
                        AM33XX_IOPAD(0x0984, PIN_INPUT_PULLUP | MUX_MODE2)
                        AM33XX_IOPAD(0x0980, PIN_OUTPUT_PULLUP | MUX_MODE2)
                >;
        };
};

&dcan1 {
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&dcan1_default_pins>;
};

Still no can1 in ip addr.
The device tree is read as I can see status to “ready” in /proc/device-tree/to/can/status

Could there be something I am missing?