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 = &lt;&amp;spidev0&gt;;
__overlay__ {
    status = &quot;disabled&quot;;
};
};

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

/* the clock/oscillator of the can-controller */
fragment@3 {
    target-path = &quot;/clocks&quot;;
    __overlay__ {
        /* external oscillator of mcp2515 on SPI0.0 */
        can0_osc: can0_osc {
            compatible = &quot;fixed-clock&quot;;
            #clock-cells = &lt;0&gt;;
            clock-frequency  = &lt;16000000&gt;;
        };
    };
};

/* the spi config of the can-controller itself binding everything together */
fragment@4 {
    target = &lt;&amp;spi1&gt;;
    __overlay__ {
        /* needed to avoid dtc warning */
        #address-cells = &lt;1&gt;;
        #size-cells = &lt;0&gt;;
        can0: mcp2515@0 {
            reg = &lt;0&gt;;
            compatible = &quot;microchip,mcp2515&quot;;
            pinctrl-names = &quot;default&quot;;
            pinctrl-0 = &lt;&amp;can0_pins&gt;;
            spi-max-frequency = &lt;10000000&gt;;
            interrupt-parent = &lt;&amp;gpio&gt;;
            interrupts = &lt;25 0x2&gt;;
            clocks = &lt;&amp;can0_osc&gt;;
        };
    };
};
__overrides__ {
    oscillator = &lt;&amp;can0_osc&gt;,&quot;clock-frequency:0&quot;;
    spimaxfrequency = &lt;&amp;can0&gt;,&quot;spi-max-frequency:0&quot;;
    interrupt = &lt;&amp;can0_pins&gt;,&quot;brcm,pins:0&quot;,&lt;&amp;can0&gt;,&quot;interrupts:0&quot;;
};

};

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 = &lt;&amp;spidev1&gt;;    __overlay__ {
    status = &quot;disabled&quot;;    };
};

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

/* the clock/oscillator of the can-controller */
fragment@3 {
    target-path = &quot;/clocks&quot;;
    __overlay__ {
        /* external oscillator of mcp2515 on spi0.1 */
        can1_osc: can1_osc {
            compatible = &quot;fixed-clock&quot;;
            #clock-cells = &lt;0&gt;;
            clock-frequency  = &lt;16000000&gt;;
        };
    };
};

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

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

martburg
  • 121
  • 1

1 Answers1

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

martburg
  • 121
  • 1