TheLabGuy Posted August 16, 2020 Posted August 16, 2020 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?
mav Posted September 16, 2020 Posted September 16, 2020 (edited) 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 September 16, 2020 by mav
Marco F. Posted October 3, 2020 Posted October 3, 2020 (edited) 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 October 3, 2020 by Werner Add code
Marco F. Posted October 4, 2020 Posted October 4, 2020 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)
Maurício Pena Posted October 12, 2020 Posted October 12, 2020 Same error here, on an Orange Pi PC Plus, and same solution: downgrade to 5.4 kernel.
Hans Heukenkamp Posted October 23, 2020 Posted October 23, 2020 Observe the same problem on a BananaPi M1 on Linux bananapi 5.8.5-sunxi #20.08.1 SMP Wed Sep 2 08:03:45 CEST 2020 armv7l GNU/Linux.
defvar Posted December 25, 2020 Posted December 25, 2020 Any updates? Observe same issue with the Kernel 5.9.14 and the OrangePI Zero. With the Kernel 5.4.45 the interface works fine. Is this bug in 5 kernel versions or was the configuration for the can interface changed in the Version 5.5.x?
denisg2 Posted February 18, 2021 Posted February 18, 2021 Same problem. But kernel 5.4.45 is no longer available Are there any updates?
Aleksey Posted February 26, 2021 Posted February 26, 2021 (edited) At this point, about everything broke for sunxi H3 https://github.com/torvalds/linux/commit/50ec88120ea16cf8b9aabf8422c364166ce3ee17#diff-55b4d8281f6fd3fe6b7b66da9ae5e9ce818e02b8ac9b23260593fd551c22fdc1 5.4.100 mcp2515 can - work 5.5.rc1 mcp2515 can - not work If you copy the source codes of the mcp2515 driver from linux 5.4.100 to the sources on 5.10.19 and build them in Buildroot, everything will work. checked. Edited February 26, 2021 by Aleksey
Aleksey Posted February 27, 2021 Posted February 27, 2021 Platform under test NanoPi NEO with MCP2515 8Mhz module spi 0,0 linux 5.4.100 mcp2515 work Сhanges made to the MCP2515 driver led to the fact that when calling commands Цитата https://github.com/torvalds/linux/commit/50ec88120ea16cf8b9aabf8422c364166ce3ee17#diff-b31f88be5901b7ea8028d214598be14257ba8558474f66fbde12a140bcd02fd9 Цитата can: mcp251x: get rid of legacy platform data Instead of using legacy platform data, switch to use device properties. For clock frequency we are using well established clock-frequency property. Users, two for now, are also converted here. ip link set can0 up type can bitrate 500000 or ifconfig can0 up to hang the system in a terminal window Цитата If you copy the source codes of the mcp2515 driver from linux 5.4.100 to the sources on 5.10.19 and build them in Buildroot, everything will work. checked. see foto terminal.
Aleksey Posted February 27, 2021 Posted February 27, 2021 Цитата INIT_WORK(&priv->tx_work, mcp251x_tx_work_handler); INIT_WORK(&priv->restart_work, mcp251x_restart_work_handler); /*mcp251x_gpio_restore;*/ ret = mcp251x_hw_reset(spi); /* * ret = mcp251x_hw_wake(spi); * problem sunxi H3 * * */ A temporary solution to the problem Calling ret = mcp251x_hw_wake (spi); this subroutine leads to a hang in the terminal on sunxi H3 boards when entering the command ip link set can0 up type can bitrate 500000 or ifconfig can0 up return to call ret = mcp251x_hw_reset (spi); fixes this problem Linux 5.5 - 5.11.2 for sunxi H3 (example Nano Pi NEO,modul MCP2515 8mhz) mcp251x.c
Marc Kleine-Budde Posted March 1, 2021 Posted March 1, 2021 Hello, I've forwarded the discussion to the linux-can mailing list. regards, Marc
Marc Kleine-Budde Posted March 2, 2021 Posted March 2, 2021 1 hour ago, Aleksey said: Thank You) Have you enabled CONFIG_PM in your .config?
Aleksey Posted March 2, 2021 Posted March 2, 2021 Причина зависания терминала на этих платах (на примере Nanopi NEO) кроется в этой функции при попытке отключить прерывания disable_irq (spi-> irq); Если закомментировать данный вызов, зависаний не произойдет. The reason for the terminal freezing on these boards (as an example of Nanopi NEO) occurs in this function when trying to disable interrupts disable_irq(spi->irq); If you comment out this given call, the hangs do not occur. static int mcp251x_hw_wake(struct spi_device *spi) { u8 value; int ret; /* Force wakeup interrupt to wake device, but don't execute IST */ disable_irq(spi->irq); mcp251x_write_2regs(spi, CANINTE, CANINTE_WAKIE, CANINTF_WAKIF); /* Wait for oscillator startup timer after wake up */ mdelay(MCP251X_OST_DELAY_MS); /* Put device into config mode */ mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_CONF); /* Wait for the device to enter config mode */ ret = mcp251x_read_stat_poll_timeout(spi, value, value == CANCTRL_REQOP_CONF, MCP251X_OST_DELAY_MS * 1000, USEC_PER_SEC); if (ret) { dev_err(&spi->dev, "MCP251x didn't enter in config mode\n"); return ret; } /* Disable and clear pending interrupts */ mcp251x_write_2regs(spi, CANINTE, 0x00, 0x00); enable_irq(spi->irq); return 0; } Настройка платы NanoPI NEO Devicetree Setting up the NanoPI NEO board Devicetree clocks { #address-cells = <1>; #size-cells = <1>; ranges; ... can0_osc_fixed: can0_osc_fixed { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <8000000>; }; } ........................... pio: pinctrl@1c20800 { /* compatible is in per SoC .dtsi file */ reg = <0x01c20800 0x400>; interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>; clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&rtc 0>; clock-names = "apb", "hosc", "losc"; gpio-controller; #gpio-cells = <3>; interrupt-controller; #interrupt-cells = <3>; ..... can0_pin_irq: can0_pin_irq { pins = "PG8"; function = "irq"; bias-pull-up; }; } spi0: spi@1c68000 { compatible = "allwinner,sun8i-h3-spi"; reg = <0x01c68000 0x1000>; interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>; clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>; clock-names = "ahb", "mod"; dmas = <&dma 23>, <&dma 23>; dma-names = "rx", "tx"; pinctrl-names = "default"; pinctrl-0 = <&spi0_pins>; resets = <&ccu RST_BUS_SPI0>; status = "okay"; #address-cells = <1>; #size-cells = <0>; can0: can@0 { reg = <0>; compatible = "microchip,mcp2515"; pinctrl-names = "default"; pinctrl-0 = <&can0_pin_irq>; interrupt-parent = <&pio>; interrupts = <6 8 IRQ_TYPE_EDGE_FALLING>; clocks = <&can0_osc_fixed>; spi-max-frequency = <10000000>; gpio-controller; #gpio-cells = <2>; status = "okay"; }; }; Экспериментальный модуль MCP2515 с частотой 8 МГц Experimental module MCP2515 with a frequency of 8 MHz TJA1050 replaced by SN65HVD230 TJA1050 заменен на SN65HVD230 на 3,3 В
Aleksey Posted March 2, 2021 Posted March 2, 2021 10 часов назад, Marc Kleine-Budde сказал: Вы включили CONFIG_PM в своем .config?
Aleksey Posted March 3, 2021 Posted March 3, 2021 It seems that in my experiments I got lost in the wrong place) I was led astray mainly by this information. https://github.com/armbian/sunxi-DT-overlays/blob/master/examples/spi-mcp251x.dts With the default driver and with the correct parameters, everything works and the terminal does not freeze, here are the correct DT settings as an example for Nano PI NEO clocks { can0_osc_fixed: can0_osc_fixed { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <8000000>; }; } pio: pinctrl@1c20800 { /* compatible is in per SoC .dtsi file */ reg = <0x01c20800 0x400>; interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>; clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&rtc 0>; clock-names = "apb", "hosc", "losc"; gpio-controller; #gpio-cells = <3>; interrupt-controller; #interrupt-cells = <3>; ..... can0_pin_irq: can0_pin_irq { pins = "PG8"; function = "irq"; bias-pull-up; }; } spi0: spi@1c68000 { compatible = "allwinner,sun8i-h3-spi"; reg = <0x01c68000 0x1000>; interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>; clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>; clock-names = "ahb", "mod"; dmas = <&dma 23>, <&dma 23>; dma-names = "rx", "tx"; pinctrl-names = "default"; pinctrl-0 = <&spi0_pins>; resets = <&ccu RST_BUS_SPI0>; status = "okay"; #address-cells = <1>; #size-cells = <0>; can0: can@0 { reg = <0>; compatible = "microchip,mcp2515"; pinctrl-names = "default"; pinctrl-0 = <&can0_pin_irq>; interrupt-parent = <&pio>; interrupts = <6 8 IRQ_TYPE_LEVEL_LOW>; /* This is the correct meaning */ clocks = <&can0_osc_fixed>; spi-max-frequency = <10000000>; gpio-controller; #gpio-cells = <2>; status = "okay"; }; }; If someone was confused by my search for a solution to the problem, I am sorry. If you set IRQ_TYPE_EDGE_FALLING, the terminal will hang. This parameter leads to the terminal freezing when calling functions ret = mcp251x_hw_wake(spi); , and in it functions to disable interrupts disable_irq(spi->irq)
Recommended Posts