1

我想将IXXAT USB-to-CAN v2设备与 RPI3B+ 一起使用。问题出在驱动程序和内核中。我无法让设备在 RPI 上工作。由于这篇文章,这个设置应该可以工作。

在文章中,他们提到我需要安装SocketCAN 驱动程序。在其自述文件中,注释说:

Note:
The driver should work with most Linux distributions running a 2.6.37 or
newer, but was only tested using Debian/Ubuntu and openSUSE Linux up to
kernel version 4.4.21. If using a Raspberry Pi, refer to the Raspberry Pi
section below before starting the steps in Getting started.

树莓派部分说:

Raspberry Pi
------------------------------------
When using a Raspberry Pi with a standard kernel release, there are no kernel
or header files available.  This will require that the kernel is recompiled
and installed on the device manually to allow the SocketCAN to function.
Refer to the instructions provided at:
https://www.raspberrypi.org/documentation/linux/kernel/building.md

这将我与内核构建联系起来。

问题:

  • 在构建内核时,我需要在哪个步骤中包含 IXXAT SocketCAN 驱动程序?
  • 我需要将SocketCAN 驱动程序中的文件复制/粘贴到哪个位置?
  • 我还需要更改内核配置吗?

我还安装了 can-utils,但如果没有正确的 SocketCAN 驱动程序,我的目标 USB-to-CAN 设备将无法工作。

命令dmesg

[ 1199.673309] usb 1-1.1.2: New USB device found, idVendor=08d8, idProduct=0008, bcdDevice= 1.00
[ 1199.673321] usb 1-1.1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1199.673330] usb 1-1.1.2: Product: USB-to-CAN V2
[ 1199.673340] usb 1-1.1.2: Manufacturer: IXXAT
[ 1199.673349] usb 1-1.1.2: SerialNumber: HW******

命令lsusb

Bus 001 Device 004: ID 08d8:0008 IXXAT Automation GmbH
4

1 回答 1

1

我是编译 Linux 内核的新手。@0andriy 的回答很有帮助。我设法使系统按预期工作。我的工作版本方法如下所述。

为 SocketCAN 准备 Linux 内核

我把所有东西都设置好并准备好了,然后我运行该menuconfig实用程序并选择了所有 CAN 模块Networking support ---> CAN bus subsystem support

默认配置文件和修改后的配置文件 ( diff -u default.config can.config) 之间的差异:

--- default.config 2019-07-24 13:28:48.000000000 +0200
+++ can.config     2019-07-24 14:26:55.000000000 +0200
@@ -1409,21 +1409,26 @@
 # CAN Device Drivers
 #
 CONFIG_CAN_VCAN=m
-# CONFIG_CAN_VXCAN is not set
+CONFIG_CAN_VXCAN=m
 CONFIG_CAN_SLCAN=m
 CONFIG_CAN_DEV=m
 CONFIG_CAN_CALC_BITTIMING=y
-# CONFIG_CAN_FLEXCAN is not set
-# CONFIG_CAN_GRCAN is not set
-# CONFIG_CAN_TI_HECC is not set
-# CONFIG_CAN_C_CAN is not set
-# CONFIG_CAN_CC770 is not set
-# CONFIG_CAN_IFI_CANFD is not set
-# CONFIG_CAN_M_CAN is not set
-# CONFIG_CAN_RCAR is not set
-# CONFIG_CAN_RCAR_CANFD is not set
-# CONFIG_CAN_SJA1000 is not set
-# CONFIG_CAN_SOFTING is not set
+CONFIG_CAN_FLEXCAN=m
+CONFIG_CAN_GRCAN=m
+CONFIG_CAN_TI_HECC=m
+CONFIG_CAN_C_CAN=m
+# CONFIG_CAN_C_CAN_PLATFORM is not set
+CONFIG_CAN_CC770=m
+# CONFIG_CAN_CC770_ISA is not set
+# CONFIG_CAN_CC770_PLATFORM is not set
+CONFIG_CAN_IFI_CANFD=m
+CONFIG_CAN_M_CAN=m
+CONFIG_CAN_RCAR=m
+CONFIG_CAN_RCAR_CANFD=m
+CONFIG_CAN_SJA1000=m
+# CONFIG_CAN_SJA1000_ISA is not set
+# CONFIG_CAN_SJA1000_PLATFORM is not set
+CONFIG_CAN_SOFTING=m

#
# CAN SPI interfaces
#
# CONFIG_CAN_HI311X is not set
CONFIG_CAN_MCP251X=m

#
# CAN USB interfaces
#
-# CONFIG_CAN_8DEV_USB is not set
-# CONFIG_CAN_EMS_USB is not set
-# CONFIG_CAN_ESD_USB2 is not set
+CONFIG_CAN_8DEV_USB=m
+CONFIG_CAN_EMS_USB=m
+CONFIG_CAN_ESD_USB2=m
 CONFIG_CAN_GS_USB=m
-# CONFIG_CAN_KVASER_USB is not set
-# CONFIG_CAN_MCBA_USB is not set
-# CONFIG_CAN_PEAK_USB is not set
-# CONFIG_CAN_UCAN is not set
-# CONFIG_CAN_DEBUG_DEVICES is not set
+CONFIG_CAN_KVASER_USB=m
+CONFIG_CAN_MCBA_USB=m
+CONFIG_CAN_PEAK_USB=m
+CONFIG_CAN_UCAN=m
+CONFIG_CAN_DEBUG_DEVICES=y
CONFIG_BT=m
CONFIG_BT_BREDR=y
CONFIG_BT_RFCOMM=m
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_BNEP=m
CONFIG_BT_BNEP_MC_FILTER=y
CONFIG_BT_BNEP_PROTO_FILTER=y
CONFIG_BT_HIDP=m
CONFIG_BT_HS=y
CONFIG_BT_LE=y
CONFIG_BT_6LOWPAN=m
# CONFIG_BT_LEDS is not set
# CONFIG_BT_SELFTEST is not set
CONFIG_BT_DEBUGFS=y

编译内核模块:IXXAT 的 SocketCAN

在 README 文件之后,执行make命令时出现错误:

make -C /lib/modules/4.19.59-v7+/build M=/root/dev/socketcan/usb-to-can_socketcan modules
make[1]: Entering directory '/root/dev/linux'
  Building modules, stage 2.
  MODPOST 1 modules
make[1]: Leaving directory '/root/dev/linux'
make -C /lib/modules/4.19.59-v7+/build M=/root/dev/socketcan/can-ibxxx_socketcan modules
make[1]: Entering directory '/root/dev/linux'
  CC [M]  /root/dev/socketcan/can-ibxxx_socketcan/ixx_pci_core.o
/root/dev/socketcan/can-ibxxx_socketcan/ixx_pci_core.c: In function ‘ixxat_pci_probe’:
/root/dev/socketcan/can-ibxxx_socketcan/ixx_pci_core.c:849:9: error: implicit declaration of function ‘pci_disable_msi’ [-Werror=implicit-function-declaration]
         pci_disable_msi(dev);
         ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
scripts/Makefile.build:303: recipe for target '/root/dev/socketcan/can-ibxxx_socketcan/ixx_pci_core.o' failed
make[2]: *** [/root/dev/socketcan/can-ibxxx_socketcan/ixx_pci_core.o] Error 1
Makefile:1517: recipe for target '_module_/root/dev/socketcan/can-ibxxx_socketcan' failed
make[1]: *** [_module_/root/dev/socketcan/can-ibxxx_socketcan] Error 2
make[1]: Leaving directory '/root/dev/linux'
Makefile:7: recipe for target 'ixx_pci' failed
make: *** [ixx_pci] Error 2

然后我尝试使用以下命令仅编译驱动程序的 USB 部分:make ixx_usb. 这很成功,我通过键入仅安装所有 USB 内核模块sudo make install_usb

之后,我需要准备并使用输入命令启动界面:

sudo ip link set can0 type can bitrate 1000000
sudo ip link set can0 up

我使用 can-utils 和 python-can 实用程序测试了该设备:

cangen can0

python -m can.player -c can0 -i socketcan -b 1000000 logged_data.log

一切都按预期工作!


IXXAT 回应

我也向 IXXAT Support 写了同样的问题,并得到了两种可能性的答案:

  1. 尝试从带有 ARM 架构的 Raspberry Pi 上的附件中编译“SocketCAN driver for Linux for x86 architecture”的实际测试版。

  2. 使用附带的 ARM 版 Linux 测试版 ECI 而不是 SocketCAN

他们还向我发送了两个附件:SocketCAN-Driver-USB2CANv2.tar.gz (13.17 KB)ECI_Driver_1.10.2640.2_BETA_20150910_Linux_arm.zip (5.17 MB).

1.选项

我删除了已安装的 SocketCAN 驱动程序并安装了附加的SocketCAN-Driver-USB2CANv2.tar.gz (13.17 KB)驱动程序。

一切都按预期工作!

有关此驱动程序测试版的事实:

  • 为了让驱动程序为 Linux 主线内核做好准备,它被完全重写。
  • 文件名和驱动程序名称本身都发生了变化。

2.选项

我只安装了 ECI 驱动程序的一部分并开始了演示。

root@rpi:~/dev/ECI_Driver_1.10.2640.2_BETA_20150910_Linux_arm/EciLinux_arm/bin/release# ./LinuxEciDemo
>> Linux ECI API Demo program <<
...

>> ECI Demo for USB-to-CAN V2 <<
ECI113_Initialize...succeeded.
ECI113_GetInfo...failed with errorcode: 0xE0FE000E. The device or resource could not be found.
-> Returning from ECI Demo for USB-to-CAN V2 <-
-> Closing Linux ECI API Demo program <-

输出级别为 6 的设备管理员:

root@rpi:~/dev/ECI_Driver_1.10.2640.2_BETA_20150910_Linux_arm/EciLinux_arm/bin/release# ./LinuxEciDeviceAdmin -o 6
===========================================================================
ECI Device Admin    : Command line parameter info
---------------------------------------------------------------------------
Show Help           : "No"
Show Version        : "No"
Output Level        : "6"
Show Only           : "No"
Auto Update         : "Disabled"
Simulate Write      : "Disabled"
Force Update        : "No"
Force Verify        : "No"
DevAdminRun -> Enter
Opening board 0 of type "PC-I 04/PCI" failed with error code 0xE0FE000E
Opening board 0 of type "PC-I 04/104" failed with error code 0xE0FE000E
Opening board 0 of type "CAN-IB1x0/PCIe (Mini), (104)" failed with error code 0xE0FE000E
Opening board 0 of type "iPC-I 320/PCI" failed with error code 0xE0FE000E
Opening board 0 of type "iPC-I 320/ISA (104)" failed with error code 0xE0FE000E
Opening board 0 of type "iPC-I XC16/PCI (PMC)" failed with error code 0xE0FE000E
Opening board 0 of type "USB-to-CAN compact" failed with error code 0xE0FE000E
Opening board 0 of type "USB-to-CAN II" failed with error code 0xE0FE000E
Opening board 0 of type "iPC-I XC16/PCIe" failed with error code 0xE0FE000E
Opening board 0 of type "CAN-IB2x0/PCIe (104)" failed with error code 0xE0FE000E

===========================================================================
ECI Hardware Name   : "USB-TO-CAN V2"
ECI Driver Type     : 0x0113
ECI Hardware Class  : undefined
---------------------------------------------------------------------------
ECI Rel. Board Index: 0
Time elapsed        : 11 ms for opening board
Hardware Type       : "USB-to-CAN_V2"
Hardware Version    : 00.00.00.00
Hardware Serial No. : "HW509705"
Boot Manager ID     : "n/a"
Boot Manager Version: 00.00.00.00
HW Version Check    : Ver1 = 0x00000000, Ver2 = 0x00010000, Result = -1
BM Version Check    : Ver1 = 0x00000000, Ver2 = 0x00010504, Result = -1
Device Update       : available
+++++++++++++++++++++
Perform Update?     : Flash HW Ver:00.01.00.00, BM Ver:00.01.05.04 [y/n] n
Update aborted      : Update was aborted upon user request
+++++++++++++++++++++
Time elapsed        : 10 ms for downloading and starting ECI firmware
Controller Count    : 0
Opening board 1 of type "USB-TO-CAN V2" failed with error code 0xE0FE000E
DevAdminRun -> Exited with error code 0xE0FE001A

第二个选项仍然不起作用。等待 IXXAT 的反馈。

于 2019-07-26T07:49:28.140 回答