PCAN-USB cannot be recognized as can0

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
huihuili
Posts: 6
Joined: Fri 13. Jul 2018, 19:25

PCAN-USB cannot be recognized as can0

Post by huihuili » Sat 14. Jul 2018, 04:00

I was trying to set up the PCAN-USB adapter in my Ubuntu machine. I am plan to use SocketCAN. I was told that I dont need to install the driver because Linux comes with the driver for it. But when I plugged the PCAN-USB adapter to Linux machine. I cannot see it listed in /dev/*.

Then I tried to install the driver (peak-linux-driver-8.5.1). I was able to build the binaries, but failed to install the package.

Here is my Linux information:
$uname -r
4.9.0-6-amd64

Below are my detailed commands and errors:

Code: Select all

$make clean
make[1]: Entering directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver'
rm -f src/*o src/*~ src/.*cmd *o *ko *~ .*cmd  pcan.mod.c Module.symvers modules.order
make[1]: Leaving directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver'
make[1]: Entering directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/lib'
rm -f src/*~
rm -rf obj lib obj32 lib32
make[1]: Leaving directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/lib'
make[1]: Entering directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/test'
rm -f src/*~ src/*.o *~ receivetest transmitest bitratetest filtertest pcanfdtst pcan-settings
make[1]: Leaving directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/test'

Code: Select all

$make -C driver NET=NETDEV_SUPPORT
make: Entering directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver'
Makefile:310: /usr/src/source/include/linux/can/dev.h not found: netdev mode might fail to compile
***
*** Host machine kernel version=4.9.0-6-amd64
*** Driver kernel version=4.9.0-6-amd64 (4.9.0)
*** Path to kernel sources=/usr/src/linux-headers-4.9.0-6-amd64
*** use KBUILD=yes
*** cc version=7
***
make -C /usr/src/linux-headers-4.9.0-6-amd64  SUBDIRS=/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver        EXTRA_CFLAGS="-I/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver        -DNO_DEBUG -DMODVERSIONS -DPARPORT_SUBSYSTEM -DUSB_SUPPORT -DPCI_SUPPORT -DPCIEC_SUPPORT -DISA_SUPPORT -DDONGLE_SUPPORT -DPCCARD_SUPPORT -DNETDEV_SUPPORT -DNO_RT  -Wno-date-time" V=0 modules
make[1]: Entering directory '/usr/src/linux-headers-4.9.0-6-amd64'
/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/Makefile:310: /usr/src/source/include/linux/can/dev.h not found: netdev mode might fail to compile
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_main.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_fops.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_fifo.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_filter.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_parse.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_sja1000.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_common.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_timing.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcanfd_core.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcanfd_ucan.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_pci.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcanfd_pci.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_pciec.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_isa.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_dongle.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_pccard_core.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_pccard.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_usb_core.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_usb.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_usbpro.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcanfd_usb.o
  CC [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/src/pcan_netdev.o
  LD [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/pcan.o
  Building modules, stage 2.
/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/Makefile:310: /usr/src/source/include/linux/can/dev.h not found: netdev mode might fail to compile
  MODPOST 1 modules
  CC      /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/pcan.mod.o
  LD [M]  /home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/pcan.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.9.0-6-amd64'
make: Leaving directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver'

Code: Select all

$sudo make install
make[1]: Entering directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver'
Info: /lib/modules/4.9.0-6-amd64/misc exists.
Info: Left current 'pcan'-entry in /etc/modprobe.d/pcan.conf untouched.
Info: Copied 45-pcan.rules to /etc/udev/rules.d.
Info: mainline drivers removed and blacklisted in
      /etc/modprobe.d/blacklist-peak.conf
make[1]: Leaving directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver'
make[1]: Entering directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/lib'
mkdir -p /usr/lib
cp -d lib/* /usr/lib
cp: cannot stat 'lib/*': No such file or directory
Makefile:186: recipe for target 'install' failed
make[1]: *** [install] Error 1
make[1]: Leaving directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/lib'
make[1]: Entering directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/test'
cp receivetest transmitest bitratetest filtertest pcanfdtst pcan-settings /usr/local/bin
cp: cannot stat 'receivetest': No such file or directory
cp: cannot stat 'transmitest': No such file or directory
cp: cannot stat 'bitratetest': No such file or directory
cp: cannot stat 'filtertest': No such file or directory
cp: cannot stat 'pcanfdtst': No such file or directory
cp: cannot stat 'pcan-settings': No such file or directory
Makefile:160: recipe for target 'install' failed
make[1]: *** [install] Error 1
make[1]: Leaving directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/test'
Last edited by M.Gerber on Tue 31. Jul 2018, 14:49, edited 1 time in total.
Reason: Inserted [code] tags for improved readability

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: PCAN-USB cannot be recognized as can0

Post by M.Maidhof » Mon 16. Jul 2018, 09:13

Hi,

with your command make -C driver, you only build the driver! Simply call only make NET=NETDEV_SUPPORT, so that all components will be builded.

regards

Michael

huihuili
Posts: 6
Joined: Fri 13. Jul 2018, 19:25

Re: PCAN-USB cannot be recognized as can0

Post by huihuili » Tue 17. Jul 2018, 00:54

I think I got the the driver installed OK.

I ran "sudo modprobe pcan".

Then I ran cat /poroc/pcan and no device is not lised.

Code: Select all

huihuili@huihuili-glaptop:~/CAN/PCAN-USB/peak-linux-driver-8.5.1$ cat /proc/pcan

*------------- PEAK-System CAN interfaces (http://www.peak-system.com) -------------
*------------- Release_20171027_n (8.5.1) Jul 16 2018 14:49:30 --------------
*---------- [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] [net] -----------
*--------------------- 0 interfaces @ major 242 found -----------------------
*n -type- -ndev- --base-- irq --btr- --read-- --write- --irqs-- -errors- status
Last edited by M.Gerber on Tue 31. Jul 2018, 14:50, edited 1 time in total.
Reason: Inserted [code] tags for improved readability

huihuili
Posts: 6
Joined: Fri 13. Jul 2018, 19:25

Re: PCAN-USB cannot be recognized as can0

Post by huihuili » Tue 17. Jul 2018, 01:01

Actually I was not able to make successfully with only the command "make NET=NETDEV_SUPPORT":

Code: Select all

huihuili@huihuili-glaptop:~/CAN/PCAN-USB/peak-linux-driver-8.5.1$ make NET=NETDEV_SUPPORT
make[1]: Entering directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver'
Makefile:310: /usr/src/source/include/linux/can/dev.h not found: netdev mode might fail to compile
make[1]: Nothing to be done for 'depend'.
make[1]: Leaving directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver'
make[1]: Entering directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver'
Makefile:310: /usr/src/source/include/linux/can/dev.h not found: netdev mode might fail to compile
***
*** Host machine kernel version=4.9.0-6-amd64
*** Driver kernel version=4.9.0-6-amd64 (4.9.0)
*** Path to kernel sources=/usr/src/linux-headers-4.9.0-6-amd64
*** use KBUILD=yes
*** cc version=7
***
make -C /usr/src/linux-headers-4.9.0-6-amd64  SUBDIRS=/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver        EXTRA_CFLAGS="-I/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver        -DNO_DEBUG -DMODVERSIONS -DPARPORT_SUBSYSTEM -DUSB_SUPPORT -DPCI_SUPPORT -DPCIEC_SUPPORT -DISA_SUPPORT -DDONGLE_SUPPORT -DPCCARD_SUPPORT -DNETDEV_SUPPORT -DNO_RT  -Wno-date-time" V=0 modules
make[2]: Entering directory '/usr/src/linux-headers-4.9.0-6-amd64'
/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/Makefile:310: /usr/src/source/include/linux/can/dev.h not found: netdev mode might fail to compile
  Building modules, stage 2.
/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver/Makefile:310: /usr/src/source/include/linux/can/dev.h not found: netdev mode might fail to compile
  MODPOST 1 modules
make[2]: Leaving directory '/usr/src/linux-headers-4.9.0-6-amd64'
make[1]: Leaving directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/driver'
make[1]: Entering directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/lib'

Info: only 64-bit version of libpcan can be built. 32-bit version of libpcan can't because the 32-bit version of libc seems not being installed...

make[1]: Leaving directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/lib'
make[1]: Entering directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/test'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/huihuili/CAN/PCAN-USB/peak-linux-driver-8.5.1/test'
Last edited by M.Gerber on Tue 31. Jul 2018, 14:51, edited 1 time in total.
Reason: Inserted [code] tags for improved readability

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: PCAN-USB cannot be recognized as can0

Post by M.Maidhof » Tue 17. Jul 2018, 09:21

Hi,

- what is the state of the LED when you plug in the PCAN-USB to your system?
- what does dmesg show after inserting the PCAN-USB?

If you like to use the SocketCAN driver, there is no need to install our peak-linux-driver. The SocketCAN driver for the PCAN-USB is part or the mainline kernel since kernel version 3.4. Simply uninstall the peak-linux-driver again with sudo make uninstall, and reboot your system once. Then call ip link ls to scan for canX devices.

Please also check if the SOCKETCAN option is enabled in your kernel config.

please post the output of the following command:

cat /boot/config-4.xxxxxxxx |grep -i can
(replace xxxxxx with your kernel version)

regards

Michael

huihuili
Posts: 6
Joined: Fri 13. Jul 2018, 19:25

Re: PCAN-USB cannot be recognized as can0

Post by huihuili » Tue 17. Jul 2018, 19:05

HI Michael,

The status of LED after I plugged into my machine:
PWR : Solid green
COM RX: flashing green
Others: Off

The following is the dmesg outputs. It does not seem to recoginize the pcan device:

Code: Select all

huihuili@huihuili-glaptop:~$ dmesg -T | grep pcan
[Tue Jul 17 03:02:38 2018] Modules linked in: pcan(O) can_dev pcmcia pcmcia_core rfcomm fuse tcp_diag inet_diag cpuid ctr ccm xt_recent iptable_nat nf_nat_ipv4 cmac linhelmk(O) bnep uinput binfmt_misc nls_ascii nls_cp437 vfat fat thinkpad_wmi(O) sparse_keymap snd_soc_skl snd_soc_skl_ipc snd_soc_sst_ipc intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp snd_soc_sst_dsp arc4 kvm_intel snd_hda_ext_core snd_soc_sst_match kvm ftdi_sio uvcvideo usbserial irqbypass snd_hda_codec_hdmi snd_soc_core intel_cstate videobuf2_vmalloc videobuf2_memops efi_pstore snd_hda_codec_conexant snd_hda_codec_generic snd_compress videobuf2_v4l2 intel_uncore snd_hda_intel intel_rapl_perf iwlmvm videobuf2_core joydev mac80211 snd_hda_codec videodev serio_raw media efivars btusb snd_hda_core btrtl iTCO_wdt iwlwifi iTCO_vendor_support
Then I uninstalled the driver with “sudo make uninstall” , restart the PC. Then plug the PCAN-USB, I called “ip link ls”. Below is the outputs. I dont see can0 listed.

Code: Select all

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
    link/ether 54:ee:75:a7:9b:30 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
    link/ether e4:a4:71:4d:41:6c brd ff:ff:ff:ff:ff:ff
Below are the outputs of cat /boot/config-4.9.0-6-amd64 |grep -i can:

Code: Select all

huihuili@huihuili-glaptop:/boot$ cat /boot/config-4.9.0-6-amd64 |grep -i can
CONFIG_NET_EMATCH_CANID=m
CONFIG_CAN=m
CONFIG_CAN_RAW=m
CONFIG_CAN_BCM=m
CONFIG_CAN_GW=m
# CAN Device Drivers
CONFIG_CAN_VCAN=m
CONFIG_CAN_SLCAN=m
CONFIG_CAN_DEV=m
CONFIG_CAN_CALC_BITTIMING=y
# CONFIG_CAN_LEDS 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_SJA1000=m
CONFIG_CAN_SJA1000_ISA=m
# CONFIG_CAN_SJA1000_PLATFORM is not set
CONFIG_CAN_EMS_PCMCIA=m
CONFIG_CAN_EMS_PCI=m
CONFIG_CAN_PEAK_PCMCIA=m
CONFIG_CAN_PEAK_PCI=m
CONFIG_CAN_PEAK_PCIEC=y
CONFIG_CAN_KVASER_PCI=m
CONFIG_CAN_PLX_PCI=m
CONFIG_CAN_SOFTING=m
CONFIG_CAN_SOFTING_CS=m
# CAN SPI interfaces
# CONFIG_CAN_MCP251X is not set
# CAN USB interfaces
CONFIG_CAN_EMS_USB=m
CONFIG_CAN_ESD_USB2=m
CONFIG_CAN_GS_USB=m
CONFIG_CAN_KVASER_USB=m
CONFIG_CAN_PEAK_USB=m
CONFIG_CAN_8DEV_USB=m
# CONFIG_CAN_DEBUG_DEVICES is not set
CONFIG_SCSI_SCAN_ASYNC=y
# ATSC (North American/Korean Terrestrial/Cable DTV) frontends
CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK=y
Last edited by M.Gerber on Tue 31. Jul 2018, 14:58, edited 1 time in total.
Reason: Inserted [code] tags for improved readability

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: PCAN-USB cannot be recognized as can0

Post by M.Maidhof » Wed 18. Jul 2018, 09:27

Hi,

please tell us the serialnumber or send a picture of the device, it looks like you do not use a PCAN-USB module, because our PCAN-USB has no COM RX LED!

See PCAN-USB here: https://www.peak-system.com/PCAN-USB.199.0.html?&L=1

regards

Michael

huihuili
Posts: 6
Joined: Fri 13. Jul 2018, 19:25

Re: PCAN-USB cannot be recognized as can0

Post by huihuili » Wed 18. Jul 2018, 09:46

Hi Michael,

This is the web of my CANUSB adapter:

https://gridconnect.com/usb-can-interface.html#

I thought it was from Peak. But it is not.

I think gridconnect offered Peak PCAN-USB adapter like this:
https://gridconnect.com/can-usb.html#

I have been using the manual of Peak's adapter for gridconnect's CANUSB adapter.

No wonder why I did not get the expected results.

I will oder the Peak PCAN-USB adapter then.

huihuili
Posts: 6
Joined: Fri 13. Jul 2018, 19:25

Re: PCAN-USB cannot be recognized as can0

Post by huihuili » Wed 18. Jul 2018, 09:52

Hi Michael,

By the way, there are two versions of Peak PCAN-USB: isolation and non-isolation.

What is the difference?

Which one should I choose?

Thanks.

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: PCAN-USB cannot be recognized as can0

Post by M.Maidhof » Wed 18. Jul 2018, 10:02

Hi,

whatever interface this is, it is NOT a PEAK interface. Looks like a simple COM port USBCAN, which is defenitely not from PEAK. The second link shows a PCAN-USB interface.

An optoisolated version will be helpfull if you connect CAN nodes over different buildings or use CAN nodes which have a high power supply. The isolation will just save your PC from over voltages from the CAN bus and prevent ground loops, which could cause communication errors or transceiver damages.

regards

Michael

Post Reply