Skip to content

mcp2515 on spi1 can0 not working #5346

Closed

Description

@martburg

Describe the bug

mcp2515 on spi1 - candump can0 not generating output

Steps to reproduce the behaviour

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

/boot/config.txt:

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";
    };
};

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 !

Device (s)

Raspberry Pi 1 Mod. B+

System

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

Logs

No response

Additional context

No response

Activity

  1. pelwell commented on Feb 6, 2023

    @pelwell
    Contributor

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

    Is that your bug report? Please explain clearly what is not working.

  2. martburg commented on Feb 6, 2023

    @martburg
    Author

    The Bug:

    candump can0 is not producing any output.

    and of course a can signal is applied to can0

    I'm not sure about the linking of spi1.1 to can 0 and spi1.0 to can1 it's an observation maybe a clue to find the bug

  3. pelwell commented on Feb 6, 2023

    @pelwell
    Contributor
    1. Does it work with just one of the overlays applied?
    2. Does /proc/interrupts show any numbers increasing (it might be labelled as something like gpio 5/6)?
    3. Does dmesg -l err,warn show anything relevant?

    Without this board and some CAN hardware my support is going to be limited.

  4. martburg commented on Feb 6, 2023

    @martburg
    Author

    will check tomorow

    thx

  5. pelwell commented on Feb 6, 2023

    @pelwell
    Contributor
    1. Is the bus properly terminated at both ends? I would hope the WaveShare board does one end.
  6. martburg commented on Feb 6, 2023

    @martburg
    Author

    Yes, the bus is terminated

    when I connect the same CAN lines to CAN1 --candump can1-- is OK

  7. martburg commented on Feb 7, 2023

    @martburg
    Author

    @pelwell
    ad 1. 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=19
    
             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
    

    with both overlays can1 is OK and can0 not OK

    ad 2. dtoverlay=t-sp1-can0,oscillator=16000000,interrupt=5

             cat /proc/interrupts ---->  
              CPU0       CPU1       CPU2       CPU3       
     50:        1592             0            0          0  ARMCTRL-level   1 Edge      3f00b880.mailbox
     51:          144             0            0          0  ARMCTRL-level   2 Edge      VCHIQ doorbell
     73:              0             0            0          0  ARMCTRL-level  48 Edge      bcm2708_fb DMA
     75:          213             0            0          0  ARMCTRL-level  50 Edge      DMA IRQ
     77:      10376             0            0          0  ARMCTRL-level  52 Edge      DMA IRQ
     78:              0             0            0          0  ARMCTRL-level  53 Edge      DMA IRQ
     81:              0             0            0          0  ARMCTRL-level  56 Edge      DMA IRQ
     86:              0             0            0          0  ARMCTRL-level  61 Edge      3f215080.spi
     89:      95250             0            0          0  ARMCTRL-level  64 Edge      dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
    111:            0              0            0          0  ARMCTRL-level  86 Edge      3f204000.spi
    113:        531              0            0          0  ARMCTRL-level  88 Edge      mmc0
    114:       4219             0            0          0  ARMCTRL-level  89 Edge      uart-pl011
    119:       3536             0            0          0  ARMCTRL-level  94 Edge      mmc1
    194:            0              0             0          0  bcm2836-timer   0 Edge      arch_timer
    195:       7536     10754      18405      11109  bcm2836-timer   1 Edge      arch_timer
    198:            0              0              0          0  bcm2836-pmu   9 Edge      arm-pmu
    FIQ:              usb_fiq
    IPI0:            0              0             0             0  CPU wakeup interrupts
    IPI1:            0              0             0              0  Timer broadcast interrupts
    IPI2:         470         484          402          463  Rescheduling interrupts
    IPI3:       8269      14516      11565       8577  Function call interrupts
    IPI4:            0               0             0              0  CPU stop interrupts
    IPI5:        248           453       1030          644  IRQ work interrupts
    IPI6:            0               0             0              0  completion interrupts
    Err:             0 
    
    dmesg-l err,warn ---->
    [    0.000000] Kernel parameter elevator= does not have any effect anymore.
                   Please use sysfs to set IO scheduler for individual devices.
    [    2.735317] Core Release: 2.80a
    [    2.735334] Setting default values for core params
    [    2.735366] Finished setting default values for core params
    [    2.935758] Using Buffer DMA mode
    [    2.935772] Periodic Transfer Interrupt Enhancement - disabled
    [    2.935784] Multiprocessor Interrupt Enhancement - disabled
    [    2.935797] OTG VER PARAM: 0, OTG VER FLAG: 0
    [    2.935825] Dedicated Tx FIFOs mode
    
    [    2.936299] WARN::dwc_otg_hcd_init:1074: FIQ DMA bounce buffers: virt = 9bd04000 dma = 0xdbd04000 len=9024
    [    2.936330] FIQ FSM acceleration enabled for :
                   Non-periodic Split Transactions
                   Periodic Split Transactions
                   High-Speed Isochronous Endpoints
                   Interrupt/Control Split Transaction hack enabled
    
    [    2.936420] WARN::hcd_init_fiq:457: FIQ on core 1
    
    [    2.936437] WARN::hcd_init_fiq:458: FIQ ASM at 807c9984 length 36
    
    [    2.936455] WARN::hcd_init_fiq:497: MPHI regs_base at a0810000
    [    2.936621] Init: Port Power? op_state=1
    [    2.936633] Init: Power Port (0)
    [    3.034603] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
    [    3.036284] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
    [    3.037965] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
    [    3.040974] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
    [    3.066357] Indeed it is in host mode hprt0 = 00021501
    [    3.193653] mmc0: host does not support reading read-only switch, assuming write-enable
    [    3.274732] Indeed it is in host mode hprt0 = 00001101
    [    5.385760] mcp25xxfd: loading out-of-tree module taints kernel.
    [    6.697899] vc_sm_cma: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.806256] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.809119] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.826432] bcm2835_v4l2: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.832909] bcm2835_codec: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.834240] bcm2835_isp: module is from the staging directory, the quality is unknown, you have been warned.
    [    7.376744] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
    [    7.613842] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
    [    7.617035] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
    [    7.617165] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available
    [    7.618130] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Oct 22 2019 01:59:28 version 7.45.98.94 (r723000 CY) FWID 01-3b33decd
    [    8.047083] mcp251x spi1.1: Cannot initialize MCP2515. Wrong wiring?
    [    8.047264] mcp251x spi1.1: Probe failed, err=19
    [   14.903746] ICMPv6: process `dhcpcd' is using deprecated sysctl (syscall) net.ipv6.neigh.eth0.retrans_time - use net.ipv6.neigh.eth0.retrans_time_ms instead
    

    ad 2. dtoverlay=t-sp1-can1,oscillator=16000000,interrupt=6

             cat /proc/interrupts ---->
              CPU0       CPU1       CPU2       CPU3       
     50:        316          0          0          0  ARMCTRL-level   1 Edge      3f00b880.mailbox
     51:         74          0          0          0  ARMCTRL-level   2 Edge      VCHIQ doorbell
     73:          0          0          0          0  ARMCTRL-level  48 Edge      bcm2708_fb DMA
     75:        213          0          0          0  ARMCTRL-level  50 Edge      DMA IRQ
     77:      10078          0          0          0  ARMCTRL-level  52 Edge      DMA IRQ
     78:          0          0          0          0  ARMCTRL-level  53 Edge      DMA IRQ
     81:          0          0          0          0  ARMCTRL-level  56 Edge      DMA IRQ
     86:          0          0          0          0  ARMCTRL-level  61 Edge      3f215080.spi
     89:      31337          0          0          0  ARMCTRL-level  64 Edge      dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
    111:          0          0          0          0  ARMCTRL-level  86 Edge      3f204000.spi
    113:        245          0          0          0  ARMCTRL-level  88 Edge      mmc0
    114:       4221          0          0          0  ARMCTRL-level  89 Edge      uart-pl011
    119:       3265          0          0          0  ARMCTRL-level  94 Edge      mmc1
    194:          0          0          0          0  bcm2836-timer   0 Edge      arch_timer
    195:       4463       5865       4251       4230  bcm2836-timer   1 Edge      arch_timer
    198:          0          0          0          0  bcm2836-pmu   9 Edge      arm-pmu
    FIQ:              usb_fiq
    IPI0:          0          0          0          0  CPU wakeup interrupts
    IPI1:          0          0          0          0  Timer broadcast interrupts
    IPI2:        283        303        329        352  Rescheduling interrupts
    IPI3:       5106       7433       8897       8871  Function call interrupts
    IPI4:          0          0          0          0  CPU stop interrupts
    IPI5:        234        166         22         48  IRQ work interrupts
    IPI6:          0          0          0          0  completion interrupts
    Err:          0
    
    dmesg|-l err,warn
    [    0.000000] Kernel parameter elevator= does not have any effect anymore.
                   Please use sysfs to set IO scheduler for individual devices.
    [    2.737806] Core Release: 2.80a
    [    2.737823] Setting default values for core params
    [    2.737855] Finished setting default values for core params
    [    2.938253] Using Buffer DMA mode
    [    2.938266] Periodic Transfer Interrupt Enhancement - disabled
    [    2.938278] Multiprocessor Interrupt Enhancement - disabled
    [    2.938291] OTG VER PARAM: 0, OTG VER FLAG: 0
    [    2.938318] Dedicated Tx FIFOs mode
    
    [    2.938797] WARN::dwc_otg_hcd_init:1074: FIQ DMA bounce buffers: virt = 9bd04000 dma = 0xdbd04000 len=9024
    [    2.938830] FIQ FSM acceleration enabled for :
                   Non-periodic Split Transactions
                   Periodic Split Transactions
                   High-Speed Isochronous Endpoints
                   Interrupt/Control Split Transaction hack enabled
    
    [    2.938911] WARN::hcd_init_fiq:457: FIQ on core 1
    
    [    2.938927] WARN::hcd_init_fiq:458: FIQ ASM at 807c9984 length 36
    
    [    2.938945] WARN::hcd_init_fiq:497: MPHI regs_base at a0810000
    [    2.939110] Init: Port Power? op_state=1
    [    2.939122] Init: Power Port (0)
    [    3.034920] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
    [    3.036605] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
    [    3.038285] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
    [    3.041295] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
    [    3.068987] Indeed it is in host mode hprt0 = 00021501
    [    3.195178] mmc0: host does not support reading read-only switch, assuming write-enable
    [    3.274740] Indeed it is in host mode hprt0 = 00001101
    [    5.328797] mcp25xxfd: loading out-of-tree module taints kernel.
    [    6.624991] vc_sm_cma: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.693200] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.693207] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.694630] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.695860] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.705363] bcm2835_v4l2: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.725878] bcm2835_isp: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.730218] bcm2835_codec: module is from the staging directory, the quality is unknown, you have been warned.
    [    7.483022] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
    [    7.725758] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
    [    7.726869] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
    [    7.727009] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available
    [    7.728053] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Oct 22 2019 01:59:28 version 7.45.98.94 (r723000 CY) FWID 01-3b33decd
    [    7.996165] mcp251x spi1.0: Cannot initialize MCP2515. Wrong wiring?
    [    7.996354] mcp251x spi1.0: Probe failed, err=19
    [   15.266635] ICMPv6: process `dhcpcd' is using deprecated sysctl (syscall) net.ipv6.neigh.eth0.retrans_time - use net.ipv6.neigh.eth0.retrans_time_ms instead
    

    ad 2. with both overlays:

            cat /proc/interrupts ---->
              CPU0       CPU1       CPU2       CPU3       
     50:        293            0          0          0  ARMCTRL-level   1 Edge      3f00b880.mailbox
     51:           81            0          0          0  ARMCTRL-level   2 Edge      VCHIQ doorbell
     73:             0            0          0          0  ARMCTRL-level  48 Edge      bcm2708_fb DMA
     75:          213            0          0          0  ARMCTRL-level  50 Edge      DMA IRQ
     77:      10142            0          0          0  ARMCTRL-level  52 Edge      DMA IRQ
     78:              0             0          0          0  ARMCTRL-level  53 Edge      DMA IRQ
     81:              0             0          0          0  ARMCTRL-level  56 Edge      DMA IRQ
     86:              0             0          0          0  ARMCTRL-level  61 Edge      3f215080.spi
     89:      36424             0          0          0  ARMCTRL-level  64 Edge      dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
    111:             0             0          0          0  ARMCTRL-level  86 Edge      3f204000.spi
    113:         318             0          0          0  ARMCTRL-level  88 Edge      mmc0
    114:       4221             0          0          0  ARMCTRL-level  89 Edge      uart-pl011
    119:       3934             0          0          0  ARMCTRL-level  94 Edge      mmc1
    194:             0             0          0          0  bcm2836-timer   0 Edge      arch_timer
    195:       4833       4901       5447       6076  bcm2836-timer   1 Edge      arch_timer
    198:             0            0          0          0  bcm2836-pmu   9 Edge      arm-pmu
    199:             0            0          0          0  pinctrl-bcm2835   6 Edge      spi1.1
    200:      60961          0          0          0  pinctrl-bcm2835   5 Edge      spi1.0
    FIQ:              usb_fiq
    IPI0:          0          0          0          0  CPU wakeup interrupts
    IPI1:          0          0          0          0  Timer broadcast interrupts
    IPI2:        296        375        357        332  Rescheduling interrupts
    IPI3:      45471      70209      54030      41473  Function call interrupts
    IPI4:          0          0          0          0  CPU stop interrupts
    IPI5:        126        200        204         91  IRQ work interrupts
    IPI6:          0          0          0          0  completion interrupts
    Err:          0
    
    dmesg -l err,warn ---->
    [    0.000000] Kernel parameter elevator= does not have any effect anymore.
                   Please use sysfs to set IO scheduler for individual devices.
    [    2.735651] Core Release: 2.80a
    [    2.735668] Setting default values for core params
    [    2.735699] Finished setting default values for core params
    [    2.936093] Using Buffer DMA mode
    [    2.936106] Periodic Transfer Interrupt Enhancement - disabled
    [    2.936118] Multiprocessor Interrupt Enhancement - disabled
    [    2.936131] OTG VER PARAM: 0, OTG VER FLAG: 0
    [    2.936159] Dedicated Tx FIFOs mode
    
    [    2.936633] WARN::dwc_otg_hcd_init:1074: FIQ DMA bounce buffers: virt = 9bd04000 dma = 0xdbd04000 len=9024
    [    2.936666] FIQ FSM acceleration enabled for :
                   Non-periodic Split Transactions
                   Periodic Split Transactions
                   High-Speed Isochronous Endpoints
                   Interrupt/Control Split Transaction hack enabled
    
    [    2.936750] WARN::hcd_init_fiq:457: FIQ on core 1
    
    [    2.936766] WARN::hcd_init_fiq:458: FIQ ASM at 807c9984 length 36
    
    [    2.936784] WARN::hcd_init_fiq:497: MPHI regs_base at a0810000
    [    2.936949] Init: Port Power? op_state=1
    [    2.936961] Init: Power Port (0)
    [    3.034826] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
    [    3.036507] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
    [    3.038187] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
    [    3.041196] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
    [    3.068911] Indeed it is in host mode hprt0 = 00021501
    [    3.196028] mmc0: host does not support reading read-only switch, assuming write-enable
    [    3.275109] Indeed it is in host mode hprt0 = 00001101
    [    5.191861] mcp25xxfd: loading out-of-tree module taints kernel.
    [    6.522456] vc_sm_cma: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.647748] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.655471] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.656613] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.663784] bcm2835_v4l2: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.690741] bcm2835_isp: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.864758] bcm2835_codec: module is from the staging directory, the quality is unknown, you have been warned.
    [    7.294801] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
    [    7.535991] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
    [    7.571407] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
    [    7.571543] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available
    [    7.572570] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Oct 22 2019 01:59:28 version 7.45.98.94 (r723000 CY) FWID 01-3b33decd
    [   14.078073] ICMPv6: process `dhcpcd' is using deprecated sysctl (syscall) net.ipv6.neigh.eth0.retrans_time - use net.ipv6.neigh.eth0.retrans_time_ms instead
    

    Strange isnt it?

    More playing around with the overlays (maybe this information helps)

    dtoverlay=t-sp1-can1,oscillator=16000000,interrupt=5
    dtoverlay=t-sp1-can0,oscillator=16000000,interrupt=6
    
    FAILED Failed to start Raise network interfaces
    dmesg|grep spi----->[    7.975624] mcp251x spi1.0 can0: MCP2515 successfully initialized.
                                     [    7.987713] mcp251x spi1.1 can1: MCP2515 successfully initialized.
                                     [    8.019905] mcp251x spi1.0 rename4: renamed from can0
    
    dtoverlay=t-sp1-can0,oscillator=16000000,interrupt=6
    dtoverlay=t-sp1-can1,oscillator=16000000,interrupt=5
    dmesg|grep spi---->[    8.062882] mcp251x spi1.1 can0: MCP2515 successfully initialized.
                                    [    8.075177] mcp251x spi1.0 can1: MCP2515 successfully initialized.
    

    but can0 and can1 not OK

  8. pelwell commented on Feb 7, 2023

    @pelwell
    Contributor

    I haven't had a chance to digest all of that information yet, but are those results repeatable?

  9. martburg commented on Feb 7, 2023

    @martburg
    Author

    Yes they are

  10. pelwell commented on Feb 7, 2023

    @pelwell
    Contributor
    1. https://www.waveshare.com/wiki/2-CH_CAN_HAT appears to be designed for SPI0. How have you changed it to use SPI1? Are you sure all the signals are connected correctly?

    2. I think these results are significant:

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

    For some reason, spi1.1 is not getting any interrupts. Does this change if you momentarily ground GPIO6/pin 29?

    1. The interrupts are declared as falling-edge (interrupt flags 2 is IRQ_TYPE_EDGE_FALLING). Are those pins reading back as high normally (raspi-gpio get 5,6)

    By the way, the overlay fragments disabling spidev0 and spidev1 are misguided - they are actually disabling spidev0.0 and spidev0.1, and by enabling SPI1 with dtoverlay=spi1-2cs,cs0_spidev=off,cs1_spidev=off you have already disabled the spidevs.

  11. martburg commented on Feb 8, 2023

    @martburg
    Author

    ad 5. using J9 on the Board
    rechecked the umptiest time
    there is another detail to add
    up until now I feed the same signal to both can chanels by connecting can0 hi to can1 hi can0 lo to can1 lo using the
    jumpers on the board
    cutting those connetctions I realised ------ wait for it ----
    physically feeding the can0 jumper with the signal candump can1 shows the input

    ad 6-7. Time to get the osziloscope: int5 (asociated with can0) gets the interupt
    verrified by running raspi-gpio get 5,6 in a loop confirms that GPIO 5 is toggeling
    wheras GPIO 6 is LOW

    I suspected that the fragments were misguided but my understanding of the dt was/is not good enough to know what I'm doing

    just for the record 1:
    candump can1 out printed
    can1 49D [6] 70 16 00 00 00 00
    can1 000 [8] FD 02 FD FF FF 7E 57 6F
    can1 12D [7] remote request
    can1 1EF9FE66 [8] remote request

    just for the record2:
    this is the dmesg|grep spi output if the spi-2s overlay is not loaded:
    [ 6.899760] spi-bcm2835aux 3f215080.spi: cs1 >= max 1
    [ 6.899805] spi_master spi1: spi_device register error /soc/spi@7e215080/mcp2515@1
    [ 6.899836] spi_master spi1: Failed to create SPI device for /soc/spi@7e215080/mcp2515@1
    [ 6.899904] spi spi1.0: Native CS is not supported - please configure cs-gpio in device-tree
    [ 8.133857] mcp251x spi1.0: Native CS is not supported - please configure cs-gpio in device-tree
    [ 9.159534] mcp251x spi1.0: MCP251x didn't enter in conf mode after reset
    [ 9.159724] mcp251x spi1.0: Probe failed, err=110
    [ 9.159808] mcp251x: probe of spi1.0 failed with error -110

  12. pelwell commented on Feb 8, 2023

    @pelwell
    Contributor

    physically feeding the can0 jumper with the signal candump can1 shows the input

    It's important to distinguish between the bus numbers on the board and the labels that Linux gives the network interfaces. To make sure I've understood you correctly, please do the following:

    1. Attach the CAN devices to the CAN0 connector, boot, and run the following:
      $ candump can0
      $ candump can1
      $ dmesg | grep "MCP2515 successfully initialized"
      $ grep spi1 /proc/interrupts
      
    2. As 8, but attach the devices to CAN1 instead.
  13. martburg commented on Feb 8, 2023

    @martburg
    Author

    ad 8. CAN on CAN0 connector

    candump can0 no output
    candump can1 output ok

    dmesg|grep spi
    [ 7.951712] mcp251x spi1.1 can0: MCP2515 successfully initialized.
    [ 7.964464] mcp251x spi1.0 can1: MCP2515 successfully initialized.

    grep spi1 /proc/interrupts
    199: 0 0 0 0 pinctrl-bcm2835 6 Edge spi1.1
    200: 121014 0 0 0 pinctrl-bcm2835 5 Edge spi1.0

    ad 9. CAN on CAN1 connector
    candump can0 no output
    candump can1 no output

    dmesg|grep spi
    [ 8.040167] mcp251x spi1.1 can0: MCP2515 successfully initialized.
    [ 8.054469] mcp251x spi1.0 can1: MCP2515 successfully initialized.

    grep spi1 /proc/interrupts
    199: 0 0 0 0 pinctrl-bcm2835 6 Edge spi1.1
    200: 16 0 0 0 pinctrl-bcm2835 5 Edge spi1.0

  14. pelwell commented on Feb 9, 2023

    @pelwell
    Contributor

    In both cases the driver can communicate with both instances of the MCP2515. If one of them was responding on both chip selects then the results would have been the same for 8 & 9, but they weren't. From that I conclude that the SPI communication is working.

    There's still a slight question mark over the status of the sp1.1 interrupt on GPIO 6. Do you ever see it high? Could a stuck interrupt line appear to show a working controller but with no devices?

    Whether the interrupt line is the cause of the problem, or whether it's just a symptom of fault on the CAN side of the MCP2515, it definitely smells like a hardware problem on the CAN board. Have you tried using it on SPI0 (with J9 moved)?

  15. martburg commented on Feb 9, 2023

    @martburg
    Author

    I repeated the whole procedure with an identical board. Same results
    I have shipped an other rpi where the mcp2515 was connected to spi0 but I'm not shure if it was the identical board but that could have been an other version.

    I'll try to move J9 to SPI0 or should I try to move int6 to another pin?

  16. pelwell commented on Feb 9, 2023

    @pelwell
    Contributor

    Either, or both - the aim is to try different combinations to help to pinpoint the problem.

  17. martburg commented on Feb 9, 2023

    @martburg
    Author

    I put our converation on stackoverflow
    https://raspberrypi.stackexchange.com/questions/141017/2-ch-can-hat-mcp2515-on-spi1-rpi-3-b
    and opened a ticket on the waveshare support

    Now I'll will head over to the lab and try some combinations.

    @pelwell : Thank you for the support!! I hope we can corner this bug.

  18. martburg commented on Feb 9, 2023

    @martburg
    Author

    connected the 2-ch-can-hat to SPI0

    INT1 --- Pin 22 GPIO 25
    INT0 --- Pin 18 GPIO 23
    CS1 ---- Pin 26 GPIO 7 (SPI0 CE1)
    CS0 ---- Pin 24 GPIO 8 (SPI0 CE0)
    SCK ---- Pin 23 GPIO 11 (SPI0 SCLK)
    MOSI -- Pin 19 GPIO 10 (SPI0 MOSI)
    MISO -- Pin 21 GPIO 9 (SPI0 MISO)
    GND --- Pin 6 GND
    5V ----- Pin 1 5V

    /boot/config.txt:
    dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=23
    dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=25

    mcp2515-can0.dtbo compiles from:

     /*
      * Device tree overlay for mcp251x/can0 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__ {
                can0_pins: can0_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 */
                    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 = <&spi0>;
            __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 8>; /* IRQ_TYPE_LEVEL_LOW */
                    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";
        };
    };`
    

    mcp2515-can1.dtbo compiles from

     /*
     * Device tree overlay for mcp251x/can1 on spi0.1 edited by petit_miner
     */
    
    /dts-v1/;
    /plugin/;
    
    / {
        compatible = "brcm,bcm2835";
        /* disable spi-dev for spi0.1 */
        fragment@0 {
            target = <&spi0>;
            __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 = "/";
            __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 = <&spi0>;
            __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 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";
        };
    };
    

    dmesg | grep spi

    [ 8.132198] mcp251x spi0.1: prop pinctrl-0 index 0 invalid phandle
    [ 8.132254] mcp251x: probe of spi0.1 failed with error -22
    [ 8.132359] mcp251x spi0.0: prop pinctrl-0 index 0 invalid phandle
    [ 8.132384] mcp251x: probe of spi0.0 failed with error -22

    So I got a fresh copy of

    mcp2515-can0.dtbo and mcp2515-can1.dtbo

    from https://github.com/raspberrypi/firmware/tree/master/boot/overlays

    and got the same

    [ 7.856228] mcp251x spi0.1: prop pinctrl-0 index 0 invalid phandle
    [ 7.856278] mcp251x: probe of spi0.1 failed with error -22
    [ 7.856354] mcp251x spi0.0: prop pinctrl-0 index 0 invalid phandle
    [ 7.856379] mcp251x: probe of spi0.0 failed with error -22

  19. pelwell commented on Feb 9, 2023

    @pelwell
    Contributor

    How old is your firmware (vcgencmd version)?

  20. martburg commented on Feb 9, 2023

    @martburg
    Author

    System

    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

  21. pelwell commented on Feb 9, 2023

    @pelwell
    Contributor

    Don't worry, I've found it - Oct 29 2021 10:49:08. I've just tried those overlays here, and although the mcp2515 driver can't find any hardware (obviously), there is no problem with the overlay application:

    ~$ dmesg | grep mcp
    [   10.963234] mcp251x spi0.1: MCP251x didn't enter in conf mode after reset
    [   10.964550] mcp251x spi0.1: Probe failed, err=110
    [   10.964577] mcp251x: probe of spi0.1 failed with error -110
    [   11.982433] mcp251x spi0.0: MCP251x didn't enter in conf mode after reset
    [   11.982626] mcp251x spi0.0: Probe failed, err=110
    [   11.982637] mcp251x: probe of spi0.0 failed with error -110
    

    Try grabbing the overlays from the same release as the firmware: https://github.com/raspberrypi/rpi-firmware/tree/d5edc6af1ef48f97b525da88ff6c510c2d4231c3/overlays

  22. martburg commented on Feb 9, 2023

    @martburg
    Author

    Grabed it loaded it ---
    pi@raspberrypi:~ $ dmesg|grep spi
    [ 7.927692] mcp251x spi0.1: prop pinctrl-0 index 0 invalid phandle
    [ 7.927738] mcp251x: probe of spi0.1 failed with error -22
    [ 7.927815] mcp251x spi0.0: prop pinctrl-0 index 0 invalid phandle
    [ 7.927837] mcp251x: probe of spi0.0 failed with error -22
    pi@raspberrypi:~ $ dmesg|grep mcp
    [ 5.271546] mcp25xxfd: loading out-of-tree module taints kernel.
    [ 7.927692] mcp251x spi0.1: prop pinctrl-0 index 0 invalid phandle
    [ 7.927738] mcp251x: probe of spi0.1 failed with error -22
    [ 7.927815] mcp251x spi0.0: prop pinctrl-0 index 0 invalid phandle
    [ 7.927837] mcp251x: probe of spi0.0 failed with error -22
    pi@raspberrypi:~ $

  23. martburg commented on Feb 10, 2023

    @martburg
    Author

    New System

    Raspberry Pi reference 2022-09-22
    Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 005a8c73b05a2cab394073150208bf4f069e861a, stage2

    Copyright (c) 2012 Broadcom
    version 102f1e848393c2112206fadffaaf86db04e98326 (clean) (release) (start)

    Linux raspberrypi 5.15.61-v8+ #1579 SMP PREEMPT Fri Aug 26 11:16:44 BST 2022 aarch64 GNU/Linux

    /boot/config.txt:

    dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=23
    dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=25

    no Board attached -->

    [ 11.540216] mcp251x spi0.1: MCP251x didn't enter in conf mode after reset
    [ 11.541770] mcp251x spi0.1: Probe failed, err=110
    [ 11.541833] mcp251x: probe of spi0.1 failed with error -110
    [ 12.566084] mcp251x spi0.0: MCP251x didn't enter in conf mode after reset
    [ 12.566333] mcp251x spi0.0: Probe failed, err=110
    [ 12.566350] mcp251x: probe of spi0.0 failed with error -110

    Board attached to spi0 -->

    [ 10.532899] mcp251x spi0.1 can0: MCP2515 successfully initialized.
    [ 10.551022] mcp251x spi0.0 can1: MCP2515 successfully initialized.

    Still the mixup CAN0 and CAN1 but both channels working on SPI0

    Next Step ---> move to SPI1

    I'll keep you posted

  24. martburg commented on Feb 10, 2023

    @martburg
    Author

    one Overlay:
    dt-overlay=t-spi1-can0,oscillator=16000000,interrupt=5

    [ 11.608247] mcp251x spi1.0: Cannot initialize MCP2515. Wrong wiring?
    [ 11.608751] mcp251x spi1.0: Probe failed, err=19

    dt-overlay=t-spi1-can1,oscillator=16000000,interrupt=6

    [ 10.718563] mcp251x spi1.1: Cannot initialize MCP2515. Wrong wiring?
    [ 10.728394] mcp251x spi1.1: Probe failed, err=19

    both Overlays
    dt-overlay=t-spi1-can0,oscillator=16000000,interrupt=5
    dt-overlay=t-spi1-can1,oscillator=16000000,interrupt=6

    [ 10.797097] mcp251x spi1.1 can0: MCP2515 successfully initialized.
    [ 10.873963] mcp251x spi1.0 can1: MCP2515 successfully initialized.

    candump can0 (asociated with spi1.1) not OK
    candump can1 (asociated with spi 1.0) OK

    cat /proc/interrupts
    184: 0 0 0 0 pinctrl-bcm2835 6 Edge spi1.1
    185: 68932 76684 71270 76552 pinctrl-bcm2835 5 Edge spi1.0

    GPIO 5 (int0) HIGH and gets Interrupts
    GPIO 6 (int1) is LOW

    looks like we are back on square one - but we verrified the board is working on spi0 (with crosover between can0 and can1)

    and the new system makes a more stable impression

  25. martburg commented on Feb 10, 2023

    @martburg
    Author

    changing the order of the loading of the overlays took care of the crosover
    both of the board beeing on spi0 or spi1

    on spi0 both channels ar working
    on spi1 only one is working

    so we could change the issue to

    mcp2515 on spi1 only one can channel working

  26. pelwell commented on Feb 10, 2023

    @pelwell
    Contributor

    I think this is a hardware problem, one that few people have encountered because most would use it on SPI0.

  27. martburg commented on Feb 10, 2023

    @martburg
    Author

    Shure?
    As I was using J9 on the waveshare board both for the connection to spi0 and spi1 for me the board looks OK.
    but as I need only can0 on spi1 for this project --- I vote for closing this issue, if somebody else or I at a later time need both channels working we already have the title for that issue.

    One last thing tomorow I'll try to change from GPIO 6 maybe this is the issue

  28. martburg commented on Feb 11, 2023

    @martburg
    Author

    Moving the interrupt vrom pin 31 (GPIO 6) to pin 33 (GPIO 13) solved the problem.

    So either it is just my rpi where GPIO 6 in this combination is faulty or ....

    Any way -- hardware

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions