how to enable CAN

Hi, I’m working with a beagleboardx15 which has an am5728 sitara processor. I am also working with yocto for developing the OS image, for that I’ve enabled CAN driver and verified that the dcan1_tx and dcan1_rx config are included in the dtsi. My problem is that i can’t seem to be able to work with can, the can0 interface doesn’t even show up. Should I configure pins? or what can I do?
When I flash the image into the bbx15 i use different commands to see all the info of can.

root@beagle-x15:/proc/device-tree/ocp/interconnect@4ae00000/segment@30000/target-module@c000/can@0# ls
clocks interrupts phandle pinctrl-1 pinctrl-names status
compatible name pinctrl-0 pinctrl-2 reg syscon-raminit
root@beagle-x15:/proc/device-tree/ocp/interconnect@4ae00000/segment@30000/target-module@c000/can@0# cd
root@beagle-x15:~# dmesg | grep -i can
[ 3.742340] omapdrm omapdrm.0: [drm] Cannot find any crtc or sizes
[ 4.777191] omapdrm omapdrm.0: [drm] Cannot find any crtc or sizes
[ 69.308868] can: controller area network core
[ 69.313476] NET: Registered PF_CAN protocol family
[ 70.047882] CAN device driver interface
[ 102.075164] can: raw protocol
root@beagle-x15:~# ifconfig -a
eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
** ether 54:45:38:e0:2d:90 txqueuelen 1000 (Ethernet)**
** 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**

eth1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
** ether 54:45:38:e0:2d:91 txqueuelen 1000 (Ethernet)**
** 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**

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
** inet 127.0.0.1 netmask 255.0.0.0**
** inet6 ::1 prefixlen 128 scopeid 0x10**
** loop txqueuelen 1000 (Local Loopback)**
** 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**

root@beagle-x15:~# ip link set can0 type can bitrate 50000
Cannot find device “can0”

Thanks in advance.

I just solved it. The problem was that i was missing some kernel modules

You should have this in your kernel config. Using bitbake -c menuconfig core-image-minimal, saving it and bitbake virtual/kernel.

CONFIG_CAN=y
CONFIG_CAN_RAW=y
CONFIG_CAN_BCM=y
CONFIG_CAN_DEV=y
CONFIG_CAN_C_CAN=y
CONFIG_CAN_C_CAN_PLATFORM=y

now I see:

root@beagle-x15:~# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
link/can
3: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
link/ether 54:45:38:e0:2d:90 brd ff:ff:ff:ff:ff:ff
4: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
link/ether 54:45:38:e0:2d:91 brd ff:ff:ff:ff:ff:ff

root@beagle-x15:~# ip link set can0 type can bitrate 50000

root@beagle-x15:~# dmesg | grep can
[ 1.268554] can: controller area network core
[ 1.268615] can: raw protocol
[ 1.268615] can: broadcast manager protocol
[ 1.391784] c_can_platform 4ae3c000.can: c_can_platform device registered (regs=(ptrval), irq=100)

root@beagle-x15:~# ifconfig -a
can0: flags=128 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 100

1 Like