Hello Devs,
I am creating this topic for people out there looking for how to setup CAN in BeagleBone AI-64. I had a long discussion with @benedict.hewson and @SunWukong (here) and they helped me to go through this. Same scheme can be followed to integrate other overlays in BB AI-64.
Image used: bbai64-debian-11.6-xfce-edgeai-arm64-2023-01-02-10gb.img.xz
Steps to setup DTS overlay for CAN in BeagleBone AI-64
Note: Apply updates from here before proceeding
- Goto
/opt/source/dtb-5.10-ti
$ cd /opt/source/dtb-5.10-ti/
- Create new CAN0 overlay file BONE-CAN0.dts in
src/arm64/overlays/
/dts-v1/;
/plugin/;
/*
* Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
*/
&{/chosen} {
overlays {
BONE-CAN0.kernel = __TIMESTAMP__;
};
};
/* Change pinmux*/
&main_mcan0 {
pinctrl-names = "default";
pinctrl-0 = <
&P9_19_can_pin /* mcan0_rxd */
&P9_20_can_pin /* mcan0_txd */
>;
symlink = "bone/can/1";
status = "okay";
};
- Compile and install from parent directory
dtb-5.10-ti
.
$ make
$ sudo make install
- After compilation edit
/boot/firmware/extlinux/extlinux.conf
by replacing
#fdtoverlays /overlays/<file>.dtbo
with
fdtoverlays /overlays/BONE-CAN0.dtbo
$ sudo vi /boot/firmware/extlinux/extlinux.conf
- Reboot
$ sudo reboot
- Test if CAN interface is loaded
$ sudo beagle-version | grep UBOOT
UBOOT: Booted Device-Tree:[k3-j721e-beagleboneai64.dts]
UBOOT: Loaded Overlay:[BONE-CAN0.kernel]
- Check for CAN interface in ip link
$ ip link
can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
link/can
It shows can0
is DOWN. To make it available run:
$ sudo ip link set can0 up type can bitrate 1000000
$ ip link
can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can
- Increase
txqueulen
$ sudo ifconfig can0 txqueuelen 100
- Representative diagram showing how to connect CAN transceivers with two BeagleBone AI-64.
Note: In order for CAN to work, you need atleast 2 nodes
- Use
cansend
andcandump
to send and receive CAN signals from one BBAI-64 to other
BB AI-64 2
candump can0
BB AI-64 1
cansend can0 435#4D.99.73.21.79.89.D4.73
I hope this helps
Thank you
Best
Shubham