cmd: dtc -O dtbo -b 0 -o spi2-mcp2515-can0-overlay.dtbo spi2-mcp2515-can0-overlay.dts
resp:
spi2-mcp2515-can0-overlay.dtbo: Warning (unit_address_vs_reg): Node /fragment@0 has a unit name, but no reg property
spi2-mcp2515-can0-overlay.dtbo: Warning (unit_address_vs_reg): Node /fragment@1 has a unit name, but no reg property
spi2-mcp2515-can0-overlay.dtbo: Warning (unit_address_vs_reg): Node /fragment@2 has a unit name, but no reg property
spi2-mcp2515-can0-overlay.dtbo: Warning (unit_address_vs_reg): Node /fragment@3 has a unit name, but no reg property
dtc: livetree.c:521: get_node_by_phandle: Assertion `(phandle != 0) && (phandle != -1)ā failed.
Aborted
I am stucked here. If you can help please give it a try.
Disclaimer : please take note that iām a beginner with Rockpi S and linux kernels / overlays , but I must say that the RockPi documentation regarding recompiling the kernel is solid , and I had no issues with that .
Ok , because the canbus drivers are not by default enabled in my rockpi debian images , it required me to download the 4.4 kernel source for rockpi s , along with a compiler binary package. I then enabled the relevant canbus resources via menuconfig and also created a default mcp2515-can overlay.
Iām using a debian buster virtual machine on my win10 laptop in order to compile the kernel. I addition I use MobaXterm on windows as an SSH client .
I would recommend that you download the stock kernel source and compile it , without making any modifications to the source. Then transfer the resultant deb install packages to your rockpi and install the new kernel via dpkg. The source and instructions are at rockpi_s_kernel_source_and instructions
Note that compiling kernel is a lot of code , and compile time can take some time.
Before updating the kernel binaries on your target , please make an SD backup of your current image.
Let me know if you encounter problems relating to the recompile process.
the compiler will also also generate a debug version of the kernel image , this file you do not need to install . That leaves us with the firware deb file , the headers deb file and the images deb file (non-debug), that needs to be installed.
Note that here I have overlayed the interrupt pin to bind to GPIO2_A7 (gpio header 1 pin 22) .
In order for the compiler to compile the new dts file , I added mcp2515-can.dtbo in the makefile in the same folder.
Note : make sure you match exactly the mcp2515 clock frequency (not the spi frequency) . In my case the waveshare can hat has a 12Mhz crystal , therefore my value is 120000 (can-mcp2515-osc fragment).
of course , if you need to make new changes to mcp2515-can.dts you can merely copy the dts to the target and recompile the overlay file there , then copy the mcp2515-can.dtbo binary to /boot/dtbs/4.4.143-999-rockchip-g01bbbc5d1312/rockchip/overlay/ folder .
Nice you got it to work! Can you please help me getting mine up and running as well? We want to use the RockPi to log data from the can bus and upload it to a server. And later connect a camera and depending on the location of a QR code drive motors to align the vehicle with an object.
Iām using the RockPi 4A. Output of uname -a Linux 31683225848 4.4.154-115-rockchip-g00fccd37c63c #1 SMP Wed Sep 15 15:04:24 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
Output of dmesg | grep mcp
[ 5.776629] rockchip-pinctrl pinctrl: unable to find group for node mcp2515_int_pin
[ 5.777617] mcp251x spi32766.0: Looking up vdd-supply from device tree
[ 5.777851] mcp251x spi32766.0: Looking up xceiver-supply from device tree
[ 5.788241] mcp251x spi32766.0: CANCTRL 0x87
[ 863.762038] mcp251x spi32766.0: CNF: 0x00 0x92 0x02
The device is there in ifconfig, but after doing:
ip link set can0 type can bitrate 1000000
ip link set up can0
ifconfig can0 up
But candump can0 gives nothing. (And Iām sure I have my wiring correct because with my former Raspberry Pi I do get output with candump).
I downloaded the kernel source, adjusted the clock-frequency to 20 MHz in the dts file, compiled just that and moved the file to boot. It does start up but I probably donāt have my pins set right. And I donāt understand the numbers used in the dts file. I tried to correlate with https://wiki.radxa.com/Rockpi4/hardware/gpio but can you please explain?
I have tried lot of things, dmesg | grep mcp25 doesnāt show anything.
Did you make any changes to kernel build? I mean menuconfig or different make command to build deb packages?
Would you share your uEnv.txt?
My rk3308.dtsi changes works:
ls /sys/firmware/devicetree/base/pinctrl/can0-pins/
mcp2515-pins name
rock@rockpis:/boot/dtbs/4.4.143-1000-rockchip-g01bbbc5d1312/rockchip/overlay$ ls -l
total 74
-rwxr-xr-x 1 root root 4629 Feb 11 12:46 README.rockchip-overlays
-rwxr-xr-x 1 root root 1290 Feb 11 12:46 i2c1-hym8563.dtbo
-rwxr-xr-x 1 root root 1543 Feb 11 12:46 mcp2515-can.dtbo
-rwxr-xr-x 1 root root 546 Feb 11 12:46 rk3308-console-on-uart0.dtbo
-rwxr-xr-x 1 root root 788 Feb 11 12:46 rk3308-console-on-uart1.dtbo
-rwxr-xr-x 1 root root 669 Feb 11 12:46 rk3308-console-on-uart2.dtbo
-rwxr-xr-x 1 root root 505 Feb 11 12:46 rk3308-i2c0.dtbo
-rwxr-xr-x 1 root root 262 Feb 11 12:46 rk3308-i2c1.dtbo
-rwxr-xr-x 1 root root 383 Feb 11 12:46 rk3308-i2c2.dtbo
-rwxr-xr-x 1 root root 624 Feb 11 12:46 rk3308-i2c3-m0.dtbo
-rwxr-xr-x 1 root root 624 Feb 11 12:46 rk3308-i2c3-m1.dtbo
-rwxr-xr-x 1 root root 504 Feb 11 12:46 rk3308-i2c3.dtbo
-rwxr-xr-x 1 root root 262 Feb 11 12:46 rk3308-pwm1.dtbo
-rwxr-xr-x 1 root root 383 Feb 11 12:46 rk3308-pwm2.dtbo
-rwxr-xr-x 1 root root 383 Feb 11 12:46 rk3308-pwm3.dtbo
-rwxr-xr-x 1 root root 881 Feb 11 12:46 rk3308-spi-spidev.dtbo
-rwxr-xr-x 1 root root 382 Feb 11 12:46 rk3308-uart0.dtbo
-rwxr-xr-x 1 root root 624 Feb 11 12:46 rk3308-uart1.dtbo
-rwxr-xr-x 1 root root 384 Feb 11 12:46 rk3308-uart2.dtbo
-rwxr-xr-x 1 root root 624 Feb 11 12:46 rk3308-uart3.dtbo
-rwxr-xr-x 1 root root 295 Feb 11 12:46 rk3308-usb20-host.dtbo
-rwxr-xr-x 1 root root 491 Feb 11 12:46 rk3308-w1-gpio.dtbo
-rwxr-xr-x 1 root root 1814 Feb 11 12:46 rockchip-fixup.scr
-rwxr-xr-x 1 root root 2358 Feb 11 12:46 rockpis-dmic-8ch-pdm.dtbo
-rwxr-xr-x 1 root root 963 Feb 11 12:46 rockpis-i2s-out.dtbo
-rwxr-xr-x 1 root root 966 Feb 11 12:46 rockpis-spdif-out.dtbo
-rwxr-xr-x 1 root root 2480 Feb 11 12:46 rockpis-v11-spi2-waveshare35b-v2.dtbo
-rwxr-xr-x 1 root root 2512 Feb 11 12:46 rockpis-v11-spi2-waveshare35c.dtbo
-rwxr-xr-x 1 root root 2480 Feb 11 12:46 rockpis-v12-spi2-waveshare35b-v2.dtbo
-rwxr-xr-x 1 root root 2512 Feb 11 12:46 rockpis-v12-spi2-waveshare35c.dtbo
In my case can bitrate 100k.
I got the same output when I add wrong bitrate.
Try to use can-utils ā candump and cangen
Rock PI 4 mcp2515(spi1) dtoverlay:
Thank you so much for everything you tried! Actually about an hour before you sent your last message I got it working. I checked again with my RaspPi but found out that worked only with a different (custom) shield. So there was a problem in the hand soldering of one of the chips. After that candump can0 on the RockPi started bursting with packages.
Iām not sure yet which of the adjustments were needed now, I guess recompiling the spi1-mcp2515-can0 overlay mentioned by @Stephen (and like you reference to github) with the right bitrate was enough. But Iāll have to double check that by starting from scratch.
Since Iām using the RockPi 4 I altered rk3399.dtsi instead to add the default pin like you recommended. But I donāt know now wether this is actually needed.
I did change some things in menuconfig, but I didnāt succeed in building a kernel. So just running the kernel as provided in the image.
On Monday Iāll have access to the machine again. Then I can try all these things and provide the uEnv.txt equivalent for the RockPi 4. I did disable the uart that share the same pins.
Once again, thank you for the effort and replies! Hardware wise this is a beautiful Single Board PC, but community support is very much needed! Letās make this board more and more accessible!
$ cat /boot/hw_intfc.conf
intfc:pwm0=off
intfc:pwm1=off
intfc:uart2=on
intfc:uart4=off
intfc:spi1=on
intfc:spi2=off
intfc:i2c2=off
intfc:i2c6=off
intfc:i2c7=on
# can function of waveshare rs485 can hat on SPI1. Need set: intfc:uart4=off intfc:spi1=on
intfc:dtoverlay=spi1-mcp2515-can0
And I can confirm that this is the only dts that I built and compiled: arch/arm64/boot/dts/rockchip/overlays-rockpi4/spi1-mcp2515-can0-overlay.dts
$ dmesg | grep mcp
[ 6.031579] rockchip-pinctrl pinctrl: unable to find group for node mcp2515-pins
[ 6.032562] mcp251x spi1.0: Looking up vdd-supply from device tree
[ 6.032839] mcp251x spi1.0: Looking up xceiver-supply from device tree
[ 6.043643] mcp251x spi1.0: CANCTRL 0x87
Thank you for this thread, it is really interesting how to create the overlay file.
I tried this on the rock PI E and it doesnt work. After loading my overlay file i got an error and the kernel stops.
I know how to configure existing overlayfiles, but creating or changing overlays file are far away from me at the moment.
if anybody have a suggestion, i would be happy.