|
From: | wojciech . st |
Subject: | Re: QEMU CAN emulation (Kvaser PCI, SJA1000) - how to setup and run |
Date: | Thu, 12 Nov 2020 09:24:30 +0100 (CET) |
Hi
I would like to run QEMU with CAN emulation and check how does it work.
I focused on the following scenario:
Host Ubuntu 16.04 with vcan0 sends messages to QEMU x86_64 with Linux or vice versa.But I always get the same error while setting up the can0 on guest:
# ip link set can0 type can bitrate 1000000
ip: either "dev" is duplicate, or "type" is garbageI build guest Linux with Buildroot and I tried multiple versions of kernel and QEMU to see if any works.
Since with the new Buildroot and QEMU I did not succeed I go as fare as Buildroot from 2016 to get kernel 3.9 (based on info from QEMU 5.1 docs/can.txt example) and 3.8 and see it it works but still get the same result.So I come into conclusion that I am missing some crucial part or information to start this example.
I use the following setup:
In Buildroot to the default configuration qemu_x86_64_defconfig I usually add only the CAN drivers as modules in kernel configuration:
- <M> CAN bus subsystem support
- <M> Raw CAN Protocol (raw access with CAN-ID filtering)
- <M> Broadcast Manager CAN Protocol (with contest filtering)
- <M> CAN Gateway/Router (with netlink configuration)
- <M> Platform CAN drivers with Netlink support
- CAN bit-timing calculation
- <M> Philips/NXP SJA1000 devices
- <M> Kvaser PCIcanx and Kvaser PCIcan PCI Cards
- CAN devices debugging messagesor small twaks to strt on particular qemu version or configuration.
Right now I focus on the following QEMU configration:
qemu-2.12.1/x86_64-softmmu/qemu-system-x86_64-M pc -m 4096M
-kernel buildroot-2016.11.3/output/images/bzImage
-drive file=buildroot-2016.11.3/output/images/rootfs.ext2,if=virtio,format=raw
-object can-host-socketcan,id=canhost0,if=can0,canbus=canbus0
-device kvaser_pci,canbus=canbus0
-nographic
-append "rootwait root=/dev/vda console=tty1 console=ttyS0"On the host side (Ubuntu 16.04 VirtualBox and Native installation):
sudo ip link add dev can0 type vcan
sudo ip link set can0 upOn the QEMU guest side:
modprobe can-raw
modprobe kvaser-pci
ip link set can0 typ can bitrate 1000000On the guest side after modprobing the drivers I see the can0 interface and no errors in dmesg but the setting up the interface with ip tool up ends with error.
I would be grateful for any comment or suggestions as I already run out of ideas.
Regards,
Wojciech
--Sent with Tutanota, the secure & ad-free mailbox:https://tutanota.com
[Prev in Thread] | Current Thread | [Next in Thread] |