Orange Pi / MCP2515 / "ip up" freezes


Recommended Posts

I'm trying to get an MCP2515 working with an Orange Pi Zero LTS H2+.  Everything seems to go well until I try to bring up the can0 interface using the command 

ip link set can0 up type can bitrate 500000

 

Once the command is entered, it never returns.  Control+C doesn't do help.  New SSH sessions fail to start, but pinging the IP address works fine.  Trying 

ifconfig

from the serial terminal will also fail to return.

 

Trying to shutdown after the "ip link set..." command, the shutdown procedure takes a long time, and eventually sends 

 

[ 4320.026984] systemd-shutdown[1]: Waiting for process: ifdown, wpa_supplicant, NetworkManager, ip

 

The image was built using the git clone and config commands, per https://docs.armbian.com/Developer-Guide_Build-Preparation/, using a Lubuntu VM.  Image is "Current", "Ubuntu Focal".

 

The overlay was based on https://github.com/armbian/sunxi-DT-overlays/blob/master/examples/spi-mcp251x.dts, with 

target = <&spi0>;

changed to

target = <&spi1>;

 

In dmesg, the MCP2515 appears to be working

mcp251x spi1.0 can0: MCP2515 successfully initialized.

 

Any tips on how to debug?

Link to post
Share on other sites
Donate and support the project!

I have same issue.

 

cat /boot/armbianEnv.txt

verbosity=1
bootlogo=false
console=serial
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
overlays=spi-add-cs1 spi-spidev usbhost2 usbhost3
param_spidev_spi_bus=1
param_spidev_spi_cs=1
rootdev=UUID=442e3394-ebc5-4a14-82f8-235d74d6b2e5
rootfstype=ext4
user_overlays=spi-mcp251x
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

 

 

cat spi-mcp251x.dts

/dts-v1/;
/plugin/;

/ {
	compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5";

	fragment@0 {
		target-path = "/clocks";
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <1>;
			can0_osc_fixed: can0_osc_fixed {
				compatible = "fixed-clock";
				#clock-cells = <0>;
				clock-frequency  = <8000000>;
			};
		};
	};

	fragment@1 {
		target = <&pio>;
		__overlay__ {
			can0_pin_irq: can0_pin_irq {
				pins = "PA7";
				function = "irq";
				bias-pull-up;
			};
		};
	};

	fragment@2 {
		target = <&spi1>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";
			mcp2515 {
				reg = <0>;
				compatible = "microchip,mcp2515";
				pinctrl-names = "default";
				pinctrl-0 = <&can0_pin_irq>;
				spi-max-frequency = <10000000>;
				interrupt-parent = <&pio>;
				interrupts = <0 7 2>; /* PA7 IRQ_TYPE_EDGE_FALLING */
				clocks = <&can0_osc_fixed>;
				status = "okay";
			};
		};
	};
};

 

Pins:

https://forum.mysensors.org/uploads/files/1483990620622-orange-pi-zero-description.jpg

 

cat /etc/armbian-release

BOARD=orangepizero
BOARD_NAME="Orange Pi Zero"
BOARDFAMILY=sun8i
BUILD_REPOSITORY_URL=https://github.com/armbian/build
BUILD_REPOSITORY_COMMIT=e6fa811d-dirty
DISTRIBUTION_CODENAME=buster
DISTRIBUTION_STATUS=supported
VERSION=20.08.1
LINUXFAMILY=sunxi
BRANCH=current
ARCH=arm
IMAGE_TYPE=stable
BOARD_TYPE=conf
INITRD_ARCH=arm
KERNEL_IMAGE_TYPE=Image

 

ip -s -d link show can0

3: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0 minmtu 0 maxmtu 0 
    can state STOPPED restart-ms 0 
	  mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
	  clock 4000000
	  re-started bus-errors arbit-lost error-warn error-pass bus-off
	  0          0          0          0          0          0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
    RX: bytes  packets  errors  dropped overrun mcast   
    0          0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    0          0        0       0       0       0   

 

After command sudo ip link set can0 up type can bitrate 125000:

new conn to ssh - no

sudo -s  - no

netstat - no

 

but new windows in tmux - working

 

Edited by mav
Link to post
Share on other sites

I have the same issue with latest Armbian Focal and Nanopi Neo.

 

I can add that if I have many ssh sessions I can use all commands exept those regarding networking.

These are the processes and interrups I can see:

1477 ?        I      0:00 [kworker/0:0-events]
 1496 ?        I      0:00 [kworker/0:2-events]
 1497 ?        I      0:00 [kworker/3:1-events]
 1508 pts/0    D+     0:00 ifconfig can0 up
 1509 ?        D      0:00 [irq/67-spi1.0]
 1510 ?        I<     0:00 [mcp251x_wq]
 1511 ttyS0    D+     0:00 ip -s -d link show can0
 1512 ?        I      0:00 [kworker/1:0-mm_percpu_wq]
 1513 ?        I      0:00 [kworker/2:0-events]
 1516 ?        I      0:00 [kworker/0:3-events]
 1517 ?        I      0:00 [kworker/3:0-events_power_efficient]
 1522 pts/1    R+     0:00 ps -ax
root@nanopineo:~# cat /proc/interrupts
           CPU0       CPU1       CPU2       CPU3
 17:          0          0          0          0     GICv2  50 Level     timer@1c20c00
 18:          0          0          0          0     GICv2  29 Level     arch_timer
 19:      10173       5154       5328      13484     GICv2  30 Level     arch_timer
 22:          0          0          0          0     GICv2  82 Level     1c02000.dma-controller
 24:       7436          0          0          0     GICv2  92 Level     sunxi-mmc
 25:        819          0          0          0     GICv2  94 Level     sunxi-mmc
 27:          1          0          0          0     GICv2 103 Level     musb-hdrc.2.auto
 28:          0          0          0          0     GICv2 104 Level     ehci_hcd:usb1
 29:          0          0          0          0     GICv2 105 Level     ohci_hcd:usb2
 30:          0          0          0          0     GICv2 106 Level     ehci_hcd:usb3
 31:          0          0          0          0     GICv2 107 Level     ohci_hcd:usb6
 32:          0          0          0          0     GICv2 108 Level     ehci_hcd:usb4
 33:          0          0          0          0     GICv2 109 Level     ohci_hcd:usb7
 34:        167          0          0          0     GICv2 110 Level     ehci_hcd:usb5
 35:          0          0          0          0     GICv2 111 Level     ohci_hcd:usb8
 39:        494          0          0          0     GICv2 114 Level     eth0
 40:         13          0          0          0     GICv2  98 Level     sun6i-spi
 42:       2288          0          0          0     GICv2  32 Level     ttyS0
 43:          0          0          0          0  sun6i-r-intc   8 Level     1f00000.rtc
 46:          0          0          0          0     GICv2 125 Level     1400000.deinterlace
 47:          0          0          0          0     GICv2  90 Level     1c0e000.video-codec
 48:          0          0          0          0     GICv2 126 Level     sun8i-ce-ns
 56:       4245          0          0          0     GICv2  63 Level     ths
 57:          0          0          0          0     GICv2 152 Level     arm-pmu
 58:          0          0          0          0     GICv2 153 Level     arm-pmu
 59:          0          0          0          0     GICv2 154 Level     arm-pmu
 60:          0          0          0          0     GICv2 155 Level     arm-pmu
 67:          1          0          0          0  sunxi_pio_edge   6 Edge      spi1.0
105:          1          0          0          0  sunxi_pio_edge  44 Edge      usb0-id-det
128:          1          0          0          0  sunxi_pio_edge   3 Edge      k1
IPI0:          0          0          0          0  CPU wakeup interrupts
IPI1:          0          0          0          0  Timer broadcast interrupts
IPI2:       2044       4286       3803       3567  Rescheduling interrupts
IPI3:        650        719        542        718  Function call interrupts
IPI4:          0          0          0          0  CPU stop interrupts
IPI5:       3193        113        233       1245  IRQ work interrupts
IPI6:          0          0          0          0  completion interrupts
Err:          0

 

 

Any help?

Thanks.

 

 

Edited by Werner
Add code
Link to post
Share on other sites

Update: 

if I use a previous kernel version everything works:

 

root@nanopineo:~# hostnamectl
   Static hostname: nanopineo
         Icon name: computer
        Machine ID: 6f25fe73523b462c903f2c486e612f38
           Boot ID: a687cc17d9d6443c9c091c01fbabece0
  Operating System: Ubuntu 20.04 LTS
            Kernel: Linux 5.4.45-sunxi
      Architecture: arm

 

root@nanopineo:~# ip link set can0 type can bitrate 12500
root@nanopineo:~# ip link set can0 up
root@nanopineo:~# candump can0 &
[1] 1839
root@nanopineo:~# cansend can0 AAA#11223344

root@nanopineo:~# cat /proc/net/can/stats

        3 transmitted frames (TXF)
        0 received frames (RXF)
        0 matched frames (RXMF)

        0 % total match ratio (RXMR)
        0 frames/s total tx rate (TXR)
        0 frames/s total rx rate (RXR)

        0 % current match ratio (CRXMR)
        0 frames/s current tx rate (CTXR)
        0 frames/s current rx rate (CRXR)

        0 % max match ratio (MRXMR)
        1 frames/s max tx rate (MTXR)
        0 frames/s max rx rate (MRXR)

        1 current receive list entries (CRCV)
        1 maximum receive list entries (MRCV)

        1 statistic resets (STR)

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...