Virtual CAN bus (vcan): Interface fails

Normally using vcan (a virtual CAN bus without physical CAN interface) is not a big deal. It’s contained in SocketCAN and I am used to work with both types of CAN on my BeagleBones.

Very strange, I can not manage to get vcan to work on BeaglePlay. Unfortunately the vcan driver is not contained on available BeaglePlay Images.
(beagleplay-emmc-flasher-debian-11.8-xfce-arm64-2023-10-07-10gb.img)

modprobe -v vcan
modprobe: FATAL: Module vcan not found in directory /lib/modules/5.10.168-ti-arm64-r111

Ok, I thought: Solution for this is clear → Get the corresp. Linux headers & kernel source, then compile the missing driver vcan.ko and install it at /lib/modules/5.10.168-ti-arm64-r111/kernel/drivers/net/can/

Result OK: (driver loaded)

modprobe -v vcan
insmod /lib/modules/5.10.168-ti-arm64-r113/kernel/drivers/net/can/vcan.ko

lsmod | grep can
vcan 20480 0
can_raw 28672 0
can 28672 1 can_raw

Very surprising, after creating a virtual CAN interface with:

ip link add name vcan0 type vcan
ip link set dev vcan0 up

I get a weird interface back with ??AMPR NET/ROM??

ifconfig vcan0
vcan0: flags=65<UP,RUNNING> mtu 0
netrom txqueuelen 1000 (AMPR NET/ROM)
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

And of course, CAN utils do fail:

candump vcan0
bind: No such device

I have no idea what’s wrong in here. Tried with different debian kernel versions, but no change.

Found what’s wrong:
Had a problem with building the vcan.ko driver module. Makefile issue! Although the 1st build did run through without errors, apparently the module was incomplete.

Now it works!

ifconfig vcan0
vcan0: flags=193<UP,RUNNING,NOARP> mtu 72
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (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

Better include vcan kernel module directly in one of the next Beagleplay images…

i was also facing the same issue