0

I am trying to setup an interface name can1 (instead of can0) on spi0.

Looking at the instructions at https://blog.stabel.family/raspberry-pi-4-device-tree/ I was able to add a new overlay file. Even though I changed all references from can0 to can1, the interface is still named can0 after reboot.

What am I missing to have linux reference the interface as can1?

Here is my overlay named mcp2515-can1-spi0-overlay.dts:

/*
 * Device tree overlay for mcp251x/can1 on spi0.0
 */

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2835";
    /* disable spi-dev for spi0.0 */
    fragment@0 {
        target = <&spi0>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@1 {
    target = <&spidev0>;
    __overlay__ {
        status = "disabled";
    };
    };

    /* the interrupt pin of the can-controller */
    fragment@2 {
        target = <&gpio>;
        __overlay__ {
            can1_pins: can1_pins {
                brcm,pins = <25>;
                brcm,function = <0>; /* input */
            };
        };
    };

    /* the clock/oscillator of the can-controller */
    fragment@3 {
        target-path = "/";
        __overlay__ {
            /* external oscillator of mcp2515 on SPI0.0 */
            can1_osc: can1_osc {
                compatible = "fixed-clock";
                #clock-cells = <0>;
                clock-frequency  = <16000000>;
            };
        };
    };

    /* the spi config of the can-controller itself binding everything together */
    fragment@4 {
        target = <&spi0>;
        __overlay__ {
            /* needed to avoid dtc warning */
            #address-cells = <1>;
            #size-cells = <0>;
            can1: mcp2515@0 {
                reg = <0>;
                compatible = "microchip,mcp2515";
                pinctrl-names = "default";
                pinctrl-0 = <&can1_pins>;
                spi-max-frequency = <10000000>;
                interrupt-parent = <&gpio>;
                interrupts = <25 8>; /* IRQ_TYPE_LEVEL_LOW */
                clocks = <&can1_osc>;
            };
        };
    };
    __overrides__ {
        oscillator = <&can1_osc>,"clock-frequency:0";
        spimaxfrequency = <&can1>,"spi-max-frequency:0";
        interrupt = <&can1_pins>,"brcm,pins:0",<&can1>,"interrupts:0";
    };
};

Here is my line in /boot/config.txt :

dtoverlay=mcp2515-can1-spi0,oscillator=12000000,interrupt=25,spimaxfrequency=2000000
0

The interface name used by the kernel is not set by the dts.

Please see the following link:

https://stackoverflow.com/questions/40399676/how-to-change-the-name-of-a-label-in-a-linux-device-tree

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.