cohen

cohen

A man who want to make the world better.

How to enable CAN communication in ubuntu-rockchip based on orange Pi 5 MAX (RK3588)?

Environment Configuration#

Operation Steps and Instructions#

  1. Open the /etc/default/u-boot file with administrator privileges. This file is the loading file for u-boot, and our goal is to modify the device tree file that needs to be loaded during device startup.

    sudo vim /etc/default/u-boot
    
  2. Modify the file content to:

	## /etc/default/u-boot - configuration file for u-boot-update(8)
	#U_BOOT_UPDATE="true"
	
	#U_BOOT_ALTERNATIVES="default recovery"
	#U_BOOT_DEFAULT="l0"
	#U_BOOT_PROMPT="1"
	#U_BOOT_ENTRIES="all"
	#U_BOOT_MENU_LABEL="Debian GNU/Linux"
	#U_BOOT_PARAMETERS="ro earlycon"
	#U_BOOT_ROOT=""
	#U_BOOT_TIMEOUT="50"
	U_BOOT_FDT="/usr/lib/firmware/5.10.0-1012-rockchip/device-tree/rockchip/rk3588-orangepi-5-max.dtb"
	#U_BOOT_FDT_DIR="/lib/firmware/"
	U_BOOT_FDT_OVERLAYS="rk3588-can0-m0.dtbo rk3588-can1-m0.dtbo"
	U_BOOT_FDT_OVERLAYS_DIR="/usr/lib/firmware/5.10.0-1012-rockchip/device-tree/rockchip/overlay"
	#U_BOOT_SYNC_DTBS="false"

When opened for the first time, by default, each line in this file starts with #, indicating that it is commented out. We need to uncomment two lines: U_BOOT_FDT and U_BOOT_FDT_OVERLAYS. The subsequent two XXX_DIRs are only used to simplify the writing of these two lines, so absolute paths do not need to be written; only the file names are sufficient.

Fill in the dtb file corresponding to the orange pi model after U_BOOT_FDT; the path may vary. It is important to note that the content filled in after U_BOOT_FDT_OVERLAYS may come with multiple different rk3588-can*-m*.dtbo files, and the file to be selected needs to be determined based on the orange pi motherboard control manual.

For example, in my version of the system, search for

sudo find / -type f -name "*3588*can*.dtbo" 2>/dev/null

## the search result:
/usr/lib/firmware/5.10.0-1012-rockchip/device-tree/rockchip/overlay/rk3588-can2-m1.dtbo
/usr/lib/firmware/5.10.0-1012-rockchip/device-tree/rockchip/overlay/rk3588-can1-m0.dtbo
/usr/lib/firmware/5.10.0-1012-rockchip/device-tree/rockchip/overlay/rk3588-can1-m1.dtbo
/usr/lib/firmware/5.10.0-1012-rockchip/device-tree/rockchip/overlay/rk3588-can0-m0.dtbo

According to the documentation for orange pi 5 MAX, there are only can0-m0 and can1-m0, with no can0-m1, can1-m1, or can2-m1.

Therefore, in the aforementioned u-boot file, we fill in rk3588-can0-m0.dtbo and rk3588-can1-m0.dtbo as shown in the document interface for U_BOOT_FDT_OVERLAYS.

  1. Then use the u-boot-update command to update the u-boot configuration file and reboot. The command is as follows:
sudo u-boot-update

sudo reboot
  1. After rebooting, use ifconfig -a to check if CAN0 and CAN1 ports appear.
can0: flags=128<NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 104

can1: flags=128<NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 105
  1. Connect the CAN transceiver to the CAN analyzer (or other configured CAN devices).

  2. Use candump and cansend to test whether the CAN channel communication is normal.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.