This post was finally edited by expertup at 2025-1-21 19:25
Hello :-) I need to add CAN-BUS transmission to the Orange Pi CM4. I found an MCP2515 module and connected it to the Orange Pi. I also found the DTB file configuration to enable the MCP2515 module. The MCP2515 has an 8MHz crystal. The transmission seems to be working, but I don't have data transfer between the second device, an RP2040-Zero with an MCP2515. I have a logic level analyzer, and the transmission seems fine. The RP2040 sends data to the Orange Pi: - When I had set a 12MHz crystal for the MCP2515 in the DTB (wrong configuration), the RP2040 sent frames nonstop on the main line. However, when I set it to 8MHz, the RP2040 sent only one frame.
- A single frame is sent, which suggests that the MCP2515 on the Orange Pi is acknowledging the received packet. However, I don’t see any data in candump can0
The Orange Pi sends data to the RP2040: - When I send data to the RP2040 using cansend can0 030#1122334455667788, I can see the received data on the RP2040. However, after sending a second frame with cansend can0 030#1122334455667788, I don’t receive anything. After many attempts, I get an error indicating that the buffer is full.
This suggests that the Orange Pi isn’t receiving a confirmation of the data from the RP2040. I have the rk356x-mcp2515-overlay-v2.dts file in /boot/dtb/rockchip/overlay, compiled to a dtbo. In /boot/orangepiEnv.txt, I have added overlays=watchdog mcp2515-overlay-v2. Where is the problem? My rk356x-mcp2515-overlay-v2.dts source: - /dts-v1/;
- /{
- metadata {
- title = "Enable MCP2515 SPI3M0 to CAN";
- compatible = "rockchip,rk3566\0rockchip,rk3568";
- category = "misc";
- description = "Enable MCP2515 SPI3M0 to CAN With 8M Crystal Oscillator.";
- };
- fragment@0 {
- target = <0xffffffff>;
- __overlay__ {
- mcp2515_int_pin {
- mcp2515_int_pin {
- rockchip,pins = <0x03 0x1d 0x00 0xffffffff>;
- phandle = <0x02>;
- };
- };
- };
- };
- fragment@1 {
- target-path = [2f 00];
- __overlay__ {
- can-mcp2515-osc {
- compatible = "fixed-clock";
- clock-frequency = <0x7A1200>;
- #clock-cells = <0x00>;
- phandle = <0x01>;
- };
- };
- };
- fragment@2 {
- target = <0xffffffff>;
- __overlay__ {
- status = "okay";
- max-freq = <0x7735940>;
- #address-cells = <0x01>;
- #size-cells = <0x00>;
- pinctrl-0 = <0xffffffff 0xffffffff>;
- pinctrl-1 = <0xffffffff 0xffffffff>;
- can-mcp2515@0 {
- status = "okay";
- compatible = "microchip,mcp2515";
- reg = <0x00>;
- interrupt-parent = <0xffffffff>;
- interrupts = <0 132 2>;//<0x10 0x08>;
- spi-max-frequency = <0x989680>;
- clocks = <0x01>;
- vdd-supply = <0xffffffff>;
- xceiver-supply = <0xffffffff>;
- pinctrl-names = "default";
- pinctrl-0 = <0x02>;
- phandle = <0x03>;
- };
- };
- };
- __symbols__ {
- mcp2515_int_pin = "/fragment@0/__overlay__/mcp2515_int_pin/mcp2515_int_pin";
- can_mcp2515_osc = "/fragment@1/__overlay__/can-mcp2515-osc";
- can_mcp2515 = "/fragment@2/__overlay__/can-mcp2515@0";
- };
- __fixups__ {
- pinctrl = "/fragment@0:target:0";
- pcfg_pull_none = "/fragment@0/__overlay__/mcp2515_int_pin/mcp2515_int_pin:rockchip,pins:12";
- spi3 = "/fragment@2:target:0";
- spi3m0_cs0 = "/fragment@2/__overlay__:pinctrl-0:0\0/fragment@2/__overlay__:pinctrl-1:0";
- spi3m0_pins = "/fragment@2/__overlay__:pinctrl-0:4";
- spi3m0_pins_hs = "/fragment@2/__overlay__:pinctrl-1:4";
- gpio4 = "/fragment@2/__overlay__/can-mcp2515@0:interrupt-parent:0";
- vcc3v3_sys = "/fragment@2/__overlay__/can-mcp2515@0:vdd-supply:0\0/fragment@2/__overlay__/can-mcp2515@0:xceiver-supply:0";
- };
- __local_fixups__ {
- fragment@2 {
- __overlay__ {
- can-mcp2515@0 {
- clocks = <0x00>;
- pinctrl-0 = <0x00>;
- };
- };
- };
- };
- };
Copy codeWiring:
OrangePi CM4 Pin | MCP2515 Pin | TJA1050 Pin | 1 (3.3V) | VCC | - | 2, 4 (5V) | - | VCC | 9 (GND) | GND | GND | 19 (GPIO138 - SPI3_MOSI_M0) | SI | - | 21 (GPIO136 - SPI3_MISO_M0) | SO | - | 22 (GPIO132 - GPIO4_A4) | INT | - | 23 (GPIO139 - SPI3_CLK_M0) | SCK | - | 24 (GPIO134 - SPI3_CS0_M0) | CS | - |
|