-
Linux kernel > 2.6.25
ls -l /lib/modules/$(uname -r)/kernel/net/can -rw-r--r-- 1 root root 29673 Sep 4 23:11 can-bcm.ko -rw-r--r-- 1 root root 21321 Sep 4 23:11 can-gw.ko -rw-r--r-- 1 root root 36417 Sep 4 23:11 can.ko -rw-r--r-- 1 root root 18297 Sep 4 23:11 can-raw.ko
-
Load the CAN modules
modprobe can modprobe can-dev modprobe can-raw modprobe vcan
-
Configure a virtual CAN interface
ip link add dev vcan0 type vcan ip link set up vcan0 ip link show vcan0
-
bitbake -c menuconfig virtual/kernel
-
turn on CAN related features, see here http://www.armadeus.org/wiki/index.php?title=CAN_bus_Linux_driver and here https://lists.yoctoproject.org/pipermail/yocto/2017-September/038159.html
TODO: Set the required kernel configuration options from the meta-updater recipe
The QEMU version that is installed on Ubuntu by default does not support CAN related functionality.
msul@bagger:~$ qemu-system-x86_64 --version
QEMU emulator version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.18)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
The QEMU version that includes this commit https://github.com/qemu/qemu/commit/321af2f5b8285d547468c505fc8ed66b9c1b1907 is required. It means any version >= v2.12.0-rc0 should do the trick
TODO: update QEMU on CI machines as well as each developer should update it too
Run QEMU VM with following additional options that turns 'CAN' stuff
-object can-bus,id=canbus0 -object can-host-socketcan,id=canhost0,if=vcan0,canbus=canbus0 -device kvaser_pci,canbus=canbus0
Or in case of meta-updater add the following into scripts/qemucommand.py::command_line()
cmdline += ["-object", "can-bus,id=canbus0", "-object", "can-host-socketcan,id=canhost0,if=vcan0,canbus=canbus0", "-device", "kvaser_pci,canbus=canbus0"]
TODO: update scripts/qemucommand.py to support the CAN stuff
ip link set can0 type can bitrate 1000000
ip link set can0 up
TODO: Update meta-updater recipe to automate the socketcan interface configuration
In order to debug & troubleshoot applications that communicates via CAN/SocketCAN as well as CAN interface itself it’s highly recommended to install can-utils and kernel-modules
IMAGE_INSTALL_append += " can-utils kernel-modules "
TODO: update meta-updater recipe to include these tools