Austin Dubes Posted October 21, 2022 Posted October 21, 2022 Hello all, I am trying to interface with the MCP2515 on SPI2 of the RockPi4B on Armbian 22.08.6 Bullseye with Linux 5.15.74-rockchip64 and encountering some issues. The rockpi4B pins that I am using to connect to the MCP2515 INT - GPIO2_A7 MOSI - GPIO2_B2 MISO - GPIO2_B1 CLK - GPIO2_B3 CS - GPIO2_B4 When using the overlay file that I have shown below, the output for "dmesg | grep mcp": [ 6.662536] rockchip-pinctrl pinctrl: unable to find group for node mcp2515_int_pin I have been able to get the MCP2515 to initialize successfully, but only if I comment out the pinctrl-0 reference to the mcp2515_int_pin in the overlay. Doing this I can bring up the device but I am only able to send/receive a few messages before candump shows it's not transmitting any messages until I bring down and up the can0 device where it will do the same thing. The interesting thing is, when the device doesn't communicate I can still see that the can0 device is still in the "Error-Active" mode, so theoretically I should still be able to interface with it. So, I am led to believe the issue I am encountering is due to that comment line to pinctrl-0 in the overlay. Just not sure of the solution to this. I have looked about just about every forum that makes reference to the MCP2515 and have not found any promising solutions. I have tried changing the target on fragment@0 to <&gpio>, <&gpio2>, etc. Here is a look at the DTS overlay I am using for the MCP2515: //This devicetree overlay is used for RS485 CAN HAT. /dts-v1/; /plugin/; / { compatible = "rockchip,rockpi","rockchip,rk3399", "rockchip,rk3399-pinctrl"; fragment@0 { target = <&pinctrl>; __overlay__ { mcp2515_int_pin: mcp2515_int_pin { rockchip,pins = <2 7 0 &pcfg_pull_none>; }; }; }; fragment@1 { target-path = "/"; __overlay__ { can_mcp2515_osc: can-mcp2515-osc { compatible = "fixed-clock"; clock-frequency = <16000000>; #clock-cells = <0>; }; }; }; fragment@2 { target = <&spi2>; __overlay__ { status = "okay"; max-freq = <10000000>; #address-cells = <1>; #size-cells = <0>; can_mcp2515: can-mcp2515@0 { status = "okay"; compatible = "microchip,mcp2515"; reg = <0>; interrupt-parent = <&gpio2>; interrupts = <7 2 8>; spi-max-frequency = <10000000>; clocks = <&can_mcp2515_osc>; vdd-supply = <&vcc3v3_sys>; xceiver-supply = <&vcc3v3_sys>; pinctrl-names = "default"; pinctrl-0 = <&mcp2515_int_pin>; }; }; }; }; And my armbianEnv.txt: verbosity=1 bootlogo=false overlay_prefix=rockchip fdtfile=rockchip/rk3399-rock-pi-4b.dtb rootdev=UUID=fa2cbc7c-56d1-448b-9ab3-fe864e21fbc5 rootfstype=ext4 overlays=spi-spidev param_spidev_spi_bus=1 user_overlays=spi1-mcp2515-can0-overlay usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u Here's a link to my armbianmonitor -u: https://paste.armbian.com/azameworos I would like to mention I not very skilled with Linux based devices so please bear with me. Any help would be greatly appreciated! Best, Austin 0 Quote
Anneress Posted April 6, 2023 Posted April 6, 2023 (edited) Hi @Austin Dubes, did you find any solution? Thanks Edited April 6, 2023 by Anneress 0 Quote
csirke Posted June 8, 2023 Posted June 8, 2023 I have the same issue. After I added an additional label in fragment@0 (I am using different pins): fragment@0 { target = <&pinctrl>; __overlay__ { mcp2515 { mcp2515_int_pin: mcp2515_int_pin { rockchip,pins = <4 29 0 &pcfg_pull_none>; }; }; }; }; it can boot without problem. But the behaviour is still the same, only a few CAN messages can be send. 0 Quote
csirke Posted June 9, 2023 Posted June 9, 2023 My problem was solved, when I decreased the max spi frequency to 1000000. So my final dts is here: What this will cause on transfer speed, I don't know. //This devicetree overlay is used for mcp2515 CAN HAT. /dts-v1/; /plugin/; / { compatible = "rockchip,rockpi","rockchip,rk3399"; fragment@0 { target = <&pinctrl>; __overlay__ { mcp2515_pins { mcp2515_int_pin: mcp2515_int_pin { rockchip,pins = <4 29 0 &pcfg_pull_none>; }; }; }; }; fragment@1 { target-path = "/"; __overlay__ { can_mcp2515_osc: can-mcp2515-osc { compatible = "fixed-clock"; clock-frequency = <16000000>; #clock-cells = <0>; }; }; }; fragment@2 { target = <&spi1>; __overlay__ { status = "okay"; max-freq = <1000000>; #address-cells = <1>; #size-cells = <0>; can_mcp2515: can-mcp2515@0 { status = "okay"; compatible = "microchip,mcp2515"; reg = <0>; interrupt-parent = <&gpio4>; interrupts = <29 2>; spi-max-frequency = <1000000>; clocks = <&can_mcp2515_osc>; vdd-supply = <&vcc3v3_sys>; xceiver-supply = <&vcc3v3_sys>; pinctrl-names = "default"; pinctrl-0 = <&mcp2515_int_pin>; }; }; }; }; spi1-mcp2515-can0-overlay.dts 1 Quote
sns1313 Posted October 17, 2023 Posted October 17, 2023 Hi. Somebody share working image. In my case can0 don't create. $ dmesg | grep spi [ 2.359503] rockchip-spi ff1d0000.spi: registered master spi1 [ 2.359902] spi spi1.0: setup mode 0, 8 bits/w, 10000000 Hz max --> 0 [ 2.360579] rockchip-spi ff1d0000.spi: registered child spi1.0 [ 2.360635] rockchip-spi ff1d0000.spi: chipselect 0 already in use [ 2.360650] spi_master spi1: spi_device register error /spi@ff1d0000/spidev [ 2.360696] spi_master spi1: Failed to create SPI device for /spi@ff1d0000/spidev lsmod | grep mcp mcp251x 28672 0 can_dev 45056 1 mcp251x 0 Quote
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.