Hi, please help me to send and recv data over mcp2515 module on Jetson Nano
Here are my steps:
-
write system image into microSD card (Jetpack 4.5, download from https://developer.nvidia.com/jetson-nano-sd-card-image)
-
Connect mcp2515 module to SPI_1
INT – pin 31
MOSI – pin 19
MISO – pin 21
SCK – pin 23
CS – pin 24
GND – pin 6
VCC – pin 1(3.3V) or pin (2 5.0V)
(I have to mcp2515 can module, one oscillator is 8MHz, another is 11.0592MHz, I use the 11.0592MHz controller to descpribe the problem follow) -
Use jetson-IO tool to select mcp device(/opt/nvidia/jetson-io/jetson-io.py–>select “MCP251x CAN Controller”)
-
reboot
-
generate dts file from “kernel_tegra210-p3448-0000-p3449-0000-b00-mcp251x-can-controller.dtb”
-
modify dts file:
a: modify frequency for can_clock
clocks {can_clock { phandle = <0x136>; linux,phandle = <0x136>; clock-accuracy = <0x64>; clock-frequency = <0xA8C000>; // or double <0x1518000> #clock-cells = <0x0>; compatible = "fixed-clock"; };
};
b: modify spi@7000d400 part(spi-max-frequency):
spi@0 {
interrupts = <0xc8 0x1>;
interrupt-parent = <0x5b>;
clocks = <0x136>;
nvidia,rx-clk-tap-delay = <0x7>;
nvidia,enable-hw-based-cs;
compatible = “microchip,mcp2515”;
reg = <0x0>;
spi-max-frequency = <0x546000>; // or double <0xA8C000>controller-data { nvidia,tx-clk-tap-delay = <0x0>; nvidia,cs-hold-clk-count = <0x1e>; nvidia,cs-setup-clk-count = <0x1e>; nvidia,enable-hw-based-cs; nvidia,rx-clk-tap-delay = <0x1f>; }; };
-
generate to “kernel_tegra210-p3448-0000-p3449-0000-b00-mcp251x-can-controller.dtb” for my dts file
-
reboot
-
load can driver:
modprobe can
modprobe can-raw
modprobe can-bcm
modprobe can-gw
modprobe can-dev
modprobe mttcan -
set up can0:
ip link set can0 type can bitrate 100000
ip link set up can0 -
use candump and cansend to test on can0