我是编译 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
在 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 写了同样的问题,并得到了两种可能性的答案:
尝试从带有 ARM 架构的 Raspberry Pi 上的附件中编译“SocketCAN driver for Linux for x86 architecture”的实际测试版。
使用附带的 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 的反馈。