uranusb
Posts: 3
Joined: Tue Feb 06, 2018 3:49 am

Failed to apply overlay

Thu Apr 05, 2018 9:56 pm

Hi everyone,

I am working on a project of CAN-FD based on mcp2517fd. Currently, I have modified the driver and recompiled the kernel. However, when I tried to apply the overlay, it keeps showing "Failed to apply overlay."

Following is the code of dtbo file for mcp2517fd:

Code: Select all

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

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";
    /* disable spi-dev for spi0.0 */
    [email protected] {
        target = <&spi0>;
        __overlay__ {
            status = "okay";
            [email protected]{
                status = "disabled";
            };
        };
    };

    /* the interrupt pin of the can-controller */
    [email protected] {
        target = <&gpio>;
        __overlay__ {
            can0_pins: can0_pins {
                brcm,pins = <25>;
                brcm,function = <0>; /* input */
            };
        };
    };

    /* the clock/oscillator of the can-controller */
    [email protected] {
        target-path = "/clocks";
        __overlay__ {
            /* external oscillator of mcp2517fd on SPI0.0 */
            can0_osc: can0_osc {
                compatible = "fixed-clock";
                #clock-cells = <0>;
                clock-frequency  = <16000000>;
            };
        };
    };

    /* the spi config of the can-controller itself binding everything together */
    [email protected] {
        target = <&spi0>;
        __overlay__ {
            /* needed to avoid dtc warning */
            #address-cells = <1>;
            #size-cells = <0>;
            can0: [email protected] {
                reg = <0>;
                compatible = "microchip,mcp2517fd";
                pinctrl-names = "default";
                pinctrl-0 = <&can0_pins>;
                spi-max-frequency = <10000000>;
                interrupt-parent = <&gpio>;
                interrupts = <25 0x2>;
                clocks = <&can0_osc>;
            };
        };
    };
    __overrides__ {
        oscillator = <&can0_osc>,"clock-frequency:0";
        spimaxfrequency = <&can0>,"spi-max-frequency:0";
        interrupt = <&can0_pins>,"brcm,pins:0",<&can0>,"interrupts:0";
    };
};
Also, I checked the process with dmesg and it shows like following:

Code: Select all

OF: overlay: Failed to apply single node @/soc/[email protected]/can0_pins
OF: overlay: apply failed '@/soc/[email protected]'
Failed to create overlay (err=-22)
I have no idea where is the problem. Can anyone show me how to solve this problem?

Thank you.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1755
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Failed to apply overlay

Fri Apr 06, 2018 5:35 am

I am away from a Pi for the day but we can get started in the diagnosis.

At first sight the overlay looks OK. I see from the error messages that you are using the dtoverlay utility to load the overlay at runtime - have you tried from config.txt? If nothing else, the error reporting will be different - read the logging using "sudo vcdbg log msg".

Is it possible that a can0_pins node already exists? Look in /proc/device-tree to check, and try renaming that node in your overlay.

Return to “Device Tree”

Who is online

Users browsing this forum: No registered users and 1 guest