2

On a Raspberry Pi 1 Mod. B+

Raspberry Pi reference 2021-01-11
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 21090519d85bdaa1615d5d5057d37b09368ea5d2, stage2

Oct 29 2021 10:49:08
Copyright (c) 2012 Broadcom
version b8a114e5a9877e91ca8f26d1a5ce904b2ad3cf13 (clean) (release) (start)

Linux raspberrypi 5.10.63-v7+ #1459 SMP Wed Oct 6 16:41:10 BST 2021 armv7l GNU/Linux

A CAN signal physicaly connected to CAN0 produces output on candump can1.

What can be the reason and what to do to eliminate the bug?

A waveshare 2-ch-can-hat connected to raspberry B3+

INT1 --- Pin 29 GPIO 5

INT0 --- Pin 31 GPIO 6

CS1 ---- Pin 11 GPIO 17 (SPI1 CE1)

CS2 ---- Pin 12 GPIO 18 (SPI1 CE0)

SCK ---- Pin 40 GPIO21 (SPI1 SCLK)

MOSI -- Pin 38 GPIO20 (SPI1 MOSI)

MISO -- Pin 35 GPIO19 (SPI1 MISO)

GND --- Pin 6 GND

5V ----- Pin 1 5V

with a /boot/config.txt loading dt overlays:

dtoverlay=spi1-2cs,cs0_spidev=off,cs1_spidev=off

dtoverlay=t-sp1-can0,oscillator=16000000,interrupt=5

dtoverlay=t-sp1-can1,oscillator=16000000,interrupt=6

t-sp1-can0.dtbo compiles from:

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

/dts-v1/;
/plugin/;

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

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

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

    /* the clock/oscillator of the can-controller */
    fragment@3 {
        target-path = "/clocks";
        __overlay__ {
            /* external oscillator of mcp2515 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 */
    fragment@4 {
        target = <&spi1>;
        __overlay__ {
            /* needed to avoid dtc warning */
            #address-cells = <1>;
            #size-cells = <0>;
            can0: mcp2515@0 {
                reg = <0>;
                compatible = "microchip,mcp2515";
                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";
    };
};

t-sp1-can1.dtbo compiles from:

/*  * Device tree overlay for mcp251x/can1 on spi1.1 edited by petit_miner  */

/dts-v1/; /plugin/;

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

    fragment@1 {    target = <&spidev1>;    __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 = "/clocks";
        __overlay__ {
            /* external oscillator of mcp2515 on spi0.1 */
            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 = <&spi1>;
        __overlay__ {
            /* needed to avoid dtc warning */
            #address-cells = <1>;
            #size-cells = <0>;
            can1: mcp2515@1 {
                reg = <1>;
                compatible = "microchip,mcp2515";
                pinctrl-names = "default";
                pinctrl-0 = <&can1_pins>;
                spi-max-frequency = <10000000>;
                interrupt-parent = <&gpio>;
                interrupts = <25 0x2>;
                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";
    }; };

after booting dmesg | grep spi

[ 8.232885] mcp251x spi1.1 can0: MCP2515 successfully initialized. [ 8.245989] mcp251x spi1.0 can1: MCP2515 successfully initialized.

spi1.1 linked to can0 ! spi1.0 linked to can1 !

loading just one overlay results in the following errors:

dtoverlay=t-sp1-can0,oscillator=16000000,interrupt=5

 dmesg|grep spi ----> 
[    8.109524] mcp251x spi1.0: Cannot initialize MCP2515. Wrong wiring?
[    8.109766] mcp251x spi1.0: Probe failed, err=1



dtoverlay=t-sp1-can1,oscillator=16000000,interrupt=6

 dmesg|grep spi ----> 
[    8.109524] mcp251x spi1.1: Cannot initialize MCP2515. Wrong wiring?
[    8.109766] mcp251x spi1.1: Probe failed, err=19

and while loading only one overlay

cat /proc/interrupts shows no additional interupts

loading both overlays adds two interrupts

199:        0       0       0       0  pinctrl-bcm2835   6 Edge      spi1.1
200:    60961       0       0       0  pinctrl-bcm2835   5 Edge      spi1.0

hooking up an osciloscope :

GPIO5 -- int5(asociated with can0) is high and gets an interrupt

GPIO6 -- int6(asociated with can1) stays low

running

raspi-gpio get 5,6

in a loop confirms this reading

some other gory details can be found at https://github.com/raspberrypi/linux/issues/5346

1 Answer 1

0

After more testing -Hardware Error on GPIO 6 moved the Intrruped to GPIO 13 everything fine -- exept for the question just my board or a wider problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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