**********************************************
Kvaser linuxcan
**********************************************

Frequently Asked Questions - FAQ

(Also check ReleaseNotes for information about known problems.)


--------------------------------------------------------------------------------
Q1
    How to build and install linuxcan?

A1
    $ cd linuxcan
    $ make
    $ sudo make install

    For more information, see README.

--------------------------------------------------------------------------------
Q2
    What version of CANlib is installed?

A2
    CANlib version is printed in the listChannels example.

    $ /usr/doc/canlib/examples/listChannels

--------------------------------------------------------------------------------
Q3
    How to upgrade/reinstall linuxcan?

A3
    Close all running applications that are using CANlib. Unplug all Kvaser USB
    interfaces. Then execute:

    $ sudo make uninstall
    $ make
    $ sudo make install

--------------------------------------------------------------------------------
Q4
    When executing make you get an error like:

    make: *** /lib/modules/'4.10.0-26-generic/build': No such file or directory.
    Stop.

A4
    This probably means that the kernel source either is not installed or that
    the path to the kernel source does not match /lib/modules/`uname -r`/build.
    Make sure you have installed the kernel source. If your kernel source is
    located in a different directory, set the variable KDIR to this path. i.e.

    $ export KDIR=/home/kvaser/kernel_4.10.11

--------------------------------------------------------------------------------
Q5
    When executing make you get an error like:

    make[2]: Entering directory '/usr/src/linux-headers-4.4.38-tegra'
      CC [M]  /home/nvidia/linuxcan/linuxcan/common/VCanOsIf.o
    scripts/basic/fixdep: 1: scripts/basic/fixdep: Syntax error: "(" unexpected

A5
    This probably means that the kernel build system has to be prepared using
    the following command:

    $ cd /lib/modules/`uname -r`/build
    $ sudo make modules_prepare

--------------------------------------------------------------------------------
Q6
    Compilation succeeded but install failed. You get an error like:

    Permission denied

A6
    You need root permissions to install linuxcan. Use 'sudo' or log in as root.

--------------------------------------------------------------------------------
Q7
    I have compiled and installed everything but I still cannot get the drivers
    to work.

A7.1
    Check the kernel log for errors using 'dmesg'. For Kvaser USB interfaces you
    typically see something like this when plugged in:

    $ dmesg
    [32.09107] usb 1-2: new high-speed USB device number 4 using ehci-pci
    [32.30202] usb 1-2: New USB device found, idVendor=0bfd, idProduct=0104
    [32.30207] usb 1-2: Product: Kvaser Memorator Pro 5xHS
    [32.30212] usb 1-2: Manufacturer: Kvaser AB
    [35.42160] usbcore: registered new interface driver mhydra

A7.2
    Check the syslog for errors. On systems running systemd-journald:

    $ journalctl -b
    apr 19 15:07:54 mypc kernel: usbcore: registered new interface driver mhydra
    apr 19 15:07:54 mypc /usr/sbin/mhydra.sh[2181]: Module mhydra added
    apr 19 15:07:54 mypc /usr/sbin/mhydra.sh[2191]: Created /dev/mhydra0
    apr 19 15:07:54 mypc /usr/sbin/mhydra.sh[2193]: Created /dev/mhydra1


    Or on systems using a standard syslog daemon:

    $ cat /var/log/syslog
    Apr 19 15:07:54 mypc kernel: usbcore: registered new interface driver mhydra
    Apr 19 15:07:54 mypc /usr/sbin/mhydra.sh: Module mhydra added
    Apr 19 15:07:54 mypc /usr/sbin/mhydra.sh: Created /dev/mhydra0
    Apr 19 15:07:54 mypc /usr/sbin/mhydra.sh: Created /dev/mhydra1

A7.3
    Make sure the modules are loaded. The following command should print
    kvcommon and at least one more module:

    $ lsmod | grep 'kvcommon\|mhydra\|leaf\|usbcanII\|kvpciefd\|kvpcican\|kvpcicanII\|kvvirutalcan'
    mhydra                 53248  0
    kvcommon               45056  1 mhydra

--------------------------------------------------------------------------------
Q8
    When I execute 'sudo make install' I get a warning like this in the output
    from make:

    ***********************************************************************
    WARNING: kvcommon is already loaded! It is advised to unplug Kvaser USB
             devices and call 'sudo make uninstall' before doing a new
             installation. Or do a reboot after installation.
    ***********************************************************************

A8
    Make sure you execute 'sudo make uninstall' before you install linuxcan.

--------------------------------------------------------------------------------
Q9
    I have unplugged all Kvaser USB interfaces but the module (mhydra, leaf or
    usbcanII) is still loaded?

A9
    Usually this is caused by a running application using CANlib. Make sure you
    close all applications that are using CANlib.

--------------------------------------------------------------------------------
Q10
    I get warnings like this in the kernel log:

    [ 266.950566] mhydra: disagrees about version of symbol vCanInit
    [ 266.950570] mhydra: Unknown symbol vCanInit (err -22)
    ...

A10
    A old version of kvcommon is already loaded. You probably reinstalled
    linuxcan and the drivers, but forgot to execute 'sudo make uninstall' before
    you executed 'sudo make install'.

--------------------------------------------------------------------------------
Q11
    I get warnings like this in the kernel log:

    [ 321.875210] kvcommon: disagrees about version of symbol module_layout

A11
    You probably built the modules against a different kernel version than what
    your system is running. Make sure your kernel source version is equal to
    what 'uname -r' reports.

--------------------------------------------------------------------------------
Q12
    I get errors like this in syslog:

    apr 19 16:05:38 mypc /usr/sbin/mhydra.sh[22789]: modprobe: ERROR: could not insert 'mhydra': Required key not available
    apr 19 16:05:38 mypc systemd-udevd[22776]: Process '/usr/sbin/mhydra.sh start' failed with exit code 1.

A12
    Your kernel is probably configured to only allow loading of validly signed
    modules. There are at least two different kernel configurations causing this
    error, CONFIG_EFI_SECURE_BOOT_SIG_ENFORCE and CONFIG_MODULE_SIG_FORCE.

    Usually this is caused by CONFIG_EFI_SECURE_BOOT_SIG_ENFORCE, on some common
    Linux distributions such as Ubuntu and Fedora. If UEFI secure boot is
    enabled on your computer, the kernel will only load validly signed modules.
    To avoid the problem either disable secure boot in UEFI or sign the compiled
    module with a trusted certificate. More information can be found at
    http://www.rodsbooks.com/efi-bootloaders/secureboot.html
    How to apply this on Kvaser linuxcan modules can be found in the
    Developer Blog section at http://www.kvaser.com

    It is also possible to get this error if the kernel was built with
    CONFIG_MODULE_SIG_FORCE set. Then you will have to sign the modules with a
    trusted certificate. More information can be found at
    https://static.lwn.net/kerneldoc/admin-guide/module-signing.html

--------------------------------------------------------------------------------
Q13
    When and how are the modules loaded/unloaded?

A13
    For Kvaser USB interfaces the corresponding module is loaded when the
    interface is plugged in. This is triggered by the udev rules in
    /etc/udev/rules.d/10-kvaser.rules. Similarly the module is unloaded when the
    last inteface using the module is unplugged.

    For PCI(E) based interfaces and virtual devices, the modules needs to be
    loaded/unloaded manually with modprobe/rmmod. Whenever a module is
    loaded/unloaded a script is executed. This is configured in
    /etc/modprobe.d/kvaser.conf. It is also possible to have the modules loaded
    at boot. To achieve this execute 'sudo make load' instead of
    'sudo make install', when you install linuxcan. This will create the file
    /etc/modules-load.d/kvaser.conf.

--------------------------------------------------------------------------------
Q14
    I have compiled and installed everything but the Kvaser interface is not
    listed when I execute '/usr/doc/canlib/examples/listChannels'.

A14
    Make sure you have connected the Kvaser interface and verify that the
    SocketCAN module does not pick up any CAN interfaces by executing 'ip -d a'.
    Here is an example of what the output could look like:
    4: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10
        link/can  promiscuity 0
        can state STOPPED restart-ms 0
        kvaser_usb: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
        clock 8000000

    This tells us that a SocketCAN module is loaded and not the linuxcan module.
    It is the result of a faulty blacklisting of the SocketCAN module. Try to
    reinstall linuxcan. If it still does not work, try rebooting the machine.

    In very rare cases the SocketCAN modules are built into the kernel,
    CONFIG_CAN_KVASER_USB=y or CONFIG_CAN_KVASER_PCI=y. If so is the case it is
    not possible to prevent the SocketCAN modules from being used. You will
    have to rebuild your kernel with these modules disabled (or as loadable
    modules).

--------------------------------------------------------------------------------
Q15
    What is SocketCAN and how can I use it?

A15
    SocketCAN is a set of open source CAN drivers and a networking stack, that
    is part of the Linux kernel. Many Kvaser CAN interfaces are supported by
    SocketCAN, including Leaf, USBcan and PCI cards. SocketCAN is not maintained
    or developed by Kvaser. To start using SocketCAN you will have to uninstall
    linuxcan by executing 'sudo make uninstall', since linuxcan will blacklist
    the SocketCAN modules. More information regarding SocketCAN can be found at
    http://elinux.org/CAN_Bus

--------------------------------------------------------------------------------
Q16
    When I execute 'make' I get warnings like these in the output from make:

    *****************************************************
    WARNING: Secure Boot is enabled on <hostname>!
             When Secure Boot is enabled, driver modules
             need to be signed with a valid private key
             in order to be loaded by the kernel.
    *****************************************************

    or

    *****************************************************
    WARNING: EFI is used on <hostname>!
             It looks like Secure Boot is enabled!
             When Secure Boot is enabled, driver modules
             need to be signed with a valid private key
             in order to be loaded by the kernel.
    *****************************************************

    or

    *****************************************************
    WARNING: EFI is used on <hostname>!
             It looks like Secure Boot is disabled.
             When Secure Boot is enabled, driver modules
             need to be signed with a valid private key
             in order to be loaded by the kernel.
    *****************************************************

    or

    *****************************************************
    WARNING: EFI is used on <hostname>!
             Not able to determine whether Secure Boot is
             enabled or disabled.
             When Secure Boot is enabled, driver modules
             need to be signed with a valid private key
             in order to be loaded by the kernel.
    *****************************************************


A16
    We try to determine if you are using EFI and if secure boot is enabled.
    See A12 in this FAQ for more details.

