Commit abf82013 authored by Henrik Brix Andersen's avatar Henrik Brix Andersen Committed by Christopher Friedt
Browse files

drivers: can: add support for configuring CAN emulation in QEMU



Add support for configuring CAN emulation support in QEMU. For now, the
only supported CAN controller is the single-channel Kvaser PCIcan PCI card.

Signed-off-by: default avatarHenrik Brix Andersen <henrik@brixandersen.dk>
parent 58e12726
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -269,6 +269,22 @@ elseif(QEMU_NET_STACK)
  endif()
endif(QEMU_PIPE_STACK)

if(CONFIG_CAN)
  # Add CAN bus 0
  list(APPEND QEMU_FLAGS -object can-bus,id=canbus0)

  if(NOT "${CONFIG_CAN_QEMU_IFACE_NAME}" STREQUAL "")
    # Connect CAN bus 0 to host SocketCAN interface
    list(APPEND QEMU_FLAGS
      -object can-host-socketcan,id=canhost0,if=${CONFIG_CAN_QEMU_IFACE_NAME},canbus=canbus0)
  endif()

  if(CONFIG_CAN_KVASER_PCI)
    # Emulate a single-channel Kvaser PCIcan card connected to CAN bus 0
    list(APPEND QEMU_FLAGS -device kvaser_pci,canbus=canbus0)
  endif()
endif()

if(CONFIG_X86_64 AND NOT CONFIG_QEMU_UEFI_BOOT)
  # QEMU doesn't like 64-bit ELF files. Since we don't use any >4GB
  # addresses, converting it to 32-bit is safe enough for emulation.
+9 −0
Original line number Diff line number Diff line
@@ -89,6 +89,15 @@ config CAN_AUTO_BUS_OFF_RECOVERY
	  recessive bits). When this option is enabled, the recovery API is not
	  available.

config CAN_QEMU_IFACE_NAME
	string "SocketCAN interface name for QEMU"
	default ""
	depends on QEMU_TARGET
	help
	  The SocketCAN interface name for QEMU. This value, if set, is given as "if" parameter to
	  the "-object can-host-socketcan" qemu command line option. The CAN interface must be
	  configured before starting QEMU.

source "drivers/can/Kconfig.sam"
source "drivers/can/Kconfig.stm32"
source "drivers/can/Kconfig.stm32fd"