martinayotte 674 Posted September 22, 2019 Share Posted September 22, 2019 5 hours ago, BertHav said: The overlay does not load because the device tree path does not contain the necessary path for the OPi3 and OPLite2 Try it without the "clocks" subpath : target-path = "/"; 0 Quote Link to post Share on other sites
BertHav 1 Posted September 22, 2019 Share Posted September 22, 2019 (edited) On 9/22/2019 at 3:53 PM, martinayotte said: Try it without the "clocks" subpath : Thank for replying. That was exactly the adjustment I made that successfully loaded the overlay. This modification ensures that can0 is created with some duplicate error. pi@orangepi3:~$ dmesg | grep spi||mcp [ 2.332200] sun6i-spi 5011000.spi: chipselect 0 already in use [ 2.332207] spi_master spi1: spi_device register error /soc/spi@5011000/spidev@0 [ 2.332216] spi_master spi1: Failed to create SPI device for /soc/spi@5011000/spidev@0 [ 6.059773] mcp251x spi1.0 can0: MCP2515 successfully initialized. [ 263.483858] mcp251x spi1.0: failed to acquire irq 0 The last log line is created with the command below: pi@orangepi3:~$ sudo ip link set can0 up type can bitrate 250000 replies with error message RTNETLINK answers: Invalid argument My armbianEnv.txt verbosity=1 console=both overlay_prefix=sun50i-h6 rootdev=UUID=31a66c72-3b09-4222-a0f2-0f02de01b719 rootfstype=ext4 overlays=spi-spidev1 user_overlays=spi-mcp2515 usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u My overlay: /dts-v1/; /plugin/; / { compatible = "allwinner,sun50i-h6"; fragment@0 { target-path = "/"; __overlay__ { 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 = "PD21"; function = "irq"; bias-pull-up; }; }; }; fragment@2 { target = <&spi1>; __overlay__ { status = "okay"; #address-cells = <1>; #size-cells = <0>; can0:mcp2515@0 { reg = <0>; compatible = "microchip,mcp2515"; pinctrl-names = "default"; pinctrl-0 = <&can0_pin_irq>; spi-max-frequency = <10000000>; interrupt-parent = <&pio>; interrupts = <3 21 2>; /* PD21 -> 0 7 2 = PA7 IRQ_TYPE_EDGE_FALLING */ clocks = <&can0_osc_fixed>; status = "okay"; }; }; }; }; Update: For Opi3 read: Edited October 1, 2019 by BertHav pointer to solution added 0 Quote Link to post Share on other sites
HW_guy 0 Posted September 24, 2019 Share Posted September 24, 2019 Thanks for the tip @martinayotte! This also helped me to deploy successfully the mcp25xxfd CAN_FD driver on the oPi R1. If anyone else decides to move from CAN "classic" to CAN FD, look at: 0 Quote Link to post Share on other sites
ism 0 Posted November 13, 2019 Share Posted November 13, 2019 (edited) Orange pi zero H2 + MCP2515 Connections: MCP2515 Opi Zero H2 INT PA2 SCK PA14 SI PA15 SO PA16 CS PA13 GND GND VCC 3.3v and for TJA1050 5v OPi pinouts: Spoiler My overlay: Spoiler /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 = "PA2"; 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 2 2>; /* PA7 IRQ_TYPE_EDGE_FALLING */ clocks = <&can0_osc_fixed>; status = "okay"; }; }; }; }; dmesg: Spoiler [ 9.660689] mcp251x spi1.0: Cannot initialize MCP2515. Wrong wiring? [ 9.661233] mcp251x spi1.0: Probe failed, err=19 Please, help. What's wrong? Edited November 13, 2019 by ism Opi Pinouts 0 Quote Link to post Share on other sites
svd93 0 Posted April 8, 2020 Share Posted April 8, 2020 Hi to all. I have Orange Pi PC+ and trying to use MCP2515. It worked well before, but some colleagues use my Orange and now I have "cannot find device can0" error Board and bootenv: Spoiler 78814 BOARD=orangepipcplus 78815 BOARD_NAME="Orange Pi PC +" 78816 BOARDFAMILY=sun8i 78817 VERSION=5.73 78818 LINUXFAMILY=sunxi 78819 BRANCH=next 78820 ARCH=arm 78821 IMAGE_TYPE=stable 78822 BOARD_TYPE=conf 78823 INITRD_ARCH=arm 78824 KERNEL_IMAGE_TYPE=zImage 78826 ### boot environment: 78827 78828 verbosity=0 78829 logo=/boot/boot.bmp 78830 console=custom 78831 stdout=both 78832 disp_mode=1920x1080p60 78833 overlay_prefix=sun8i-h3 78834 rootdev=UUID=b674c5a6-e4bc-49c7-a23c-9ae6c54f55e0 78835 rootfstype=ext4 78836 overlays=spi0-mcp2515 spi-spidev 78837 rootfstype=ext4 78838 extraargs=vt.global_cursor_default=0 quiet splash plymouth.ignore-serial-consoles 78839 usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u I found that there is no sun8i-h3-spi0-mcp2515.dtbo file in overlay folders. I tried to compile this file from https://github.com/armbian/sunxi-DT-overlays but I am receiving this error sudo armbian-add-overlay spi-mcp251x.dts Compiling the overlay dtc: livetree.c:521: get_node_by_phandle: Assertion `(phandle != 0) && (phandle != -1)' failed. /usr/sbin/armbian-add-overlay: line 81: 2323 Aborted dtc -@ -q -I dts -O dtb -o ${temp_dir}/${fname}.dtbo $1 Error compiling the overlay Sadly I am noob in this, what does it mean? 0 Quote Link to post Share on other sites
johnc 0 Posted October 7, 2020 Share Posted October 7, 2020 The H20 orange pi boards have on 40 pins GPIO PIN 18 CAN_RX signal. Why do you play with SPI to CAN adapter instead of use built in internal CAN peripheral. Only can transmitter is needed. Why do you involve SPI to convert it later to CAN? By the way usually CAN pins are named as CAN_L and CAN_H why did they called it as CAN_RX? If this was typo were is CAN_TX pin? 0 Quote Link to post Share on other sites
Vadzim Yatskevich 0 Posted January 17 Share Posted January 17 Can anyone explain strange driver behavior, actual CAN module connection: MCP2515 Opi Zero H2 INT PA7 SCK PA14 SI PA15 SO PA16 CS PA13 GND GND 5V 5V Either I write in overlay pins = "PA2"; or pins = "PA7"; mcp2515 is successfully initialized dasio@orangepizero:~$ dmesg | grep mcp [ 11.495643] mcp251x spi0.0 can0: MCP2515 successfully initialized. But in case of pins = "PA7"; command "sudo ip link set up can0 type can bitrate 500000" leads system to hang When in overlay pins = "PA2"; (that does not correspond to physical connection) CAN bus became functional Скрытый текст /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 = "PA2"; 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"; }; }; }; }; 0 Quote Link to post Share on other sites
Vadzim Yatskevich 0 Posted March 3 Share Posted March 3 17.01.2021 в 19:09, Vadzim Yatskevich сказал: Can anyone explain strange driver behavior, actual CAN module connection: MCP2515 Opi Zero H2 INT PA7 SCK PA14 SI PA15 SO PA16 CS PA13 GND GND 5V 5V Either I write in overlay pins = "PA2"; or pins = "PA7"; mcp2515 is successfully initialized dasio@orangepizero:~$ dmesg | grep mcp [ 11.495643] mcp251x spi0.0 can0: MCP2515 successfully initialized. But in case of pins = "PA7"; command "sudo ip link set up can0 type can bitrate 500000" leads system to hang When in overlay pins = "PA2"; (that does not correspond to physical connection) CAN bus became functional Показать содержимое /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 = "PA2"; 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"; }; }; }; }; So finally I found a dirty solution to have CAN bus on Orange pi Zero and Orange pi Zero plus 2. Downgrade to kernel version Linux 5.4.x (Linux 5.4.58-sunxi in my case) makes interrupt pins behavior completely adequate. Possible to use PA7 (for Orange pi Zero) and PA2 (Orange pi Zero plus 2). 0 Quote Link to post Share on other sites
Aleksey 1 Posted March 5 Share Posted March 5 Just instead of interrupts = <0 7 2>; /* PA7 IRQ_TYPE_EDGE_FALLING */ put the correct value interrupts = <0 7 IRQ_TYPE_LEVEL_LOW>; And everything will work for you including Linux 5.11 Just a Linux 5.5 driver, uses sleep functions in the MCP2515, and the IRQ_TYPE_EDGE_FALLING interrupt cannot be handled. 0 Quote Link to post Share on other sites
Vadzim Yatskevich 0 Posted March 6 Share Posted March 6 20 часов назад, Aleksey сказал: Just instead of interrupts = <0 7 2>; /* PA7 IRQ_TYPE_EDGE_FALLING */ put the correct value interrupts = <0 7 IRQ_TYPE_LEVEL_LOW>; And everything will work for you including Linux 5.11 Just a Linux 5.5 driver, uses sleep functions in the MCP2515, and the IRQ_TYPE_EDGE_FALLING interrupt cannot be handled. Getting compilation error with "interrupts = <0 2 IRQ_TYPE_LEVEL_LOW>;" But when using " interrupts = <0 2 8>; /* PA2 IRQ_TYPE_LEVEL_LOW */ " (is that what Aleksey meant?) compilation is successfull and CAN interface is fully functional on Linux 5.10.16-sunxi 0 Quote Link to post Share on other sites
Aleksey 1 Posted March 9 Share Posted March 9 It’s strange that your definition didn’t fit , this value is defined https://elixir.bootlin.com/linux/latest/source/include/dt-bindings/interrupt-controller/irq.h#L18 Цитата /* * This header provides constants for most IRQ bindings. * * Most IRQ bindings include a flags cell as part of the IRQ specifier. * In most cases, the format of the flags cell uses the standard values * defined in this header. */ #ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_IRQ_H #define _DT_BINDINGS_INTERRUPT_CONTROLLER_IRQ_H #define IRQ_TYPE_NONE 0 #define IRQ_TYPE_EDGE_RISING 1 #define IRQ_TYPE_EDGE_FALLING 2 #define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING) #define IRQ_TYPE_LEVEL_HIGH 4 #define IRQ_TYPE_LEVEL_LOW 8 #endif and here https://elixir.bootlin.com/linux/latest/source/include/linux/irq.h#L82 But you can do that)) 0 Quote Link to post Share on other sites
Recommended Posts
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.