we often get asked about how to install the drivers for our PCAN-USB devices on a Raspberry PI. Here a small guide which I have tested on my RPI 4 with the 2019-07-10-raspbian-buster.img:
- download the latest raspbian image and install it on a sd card using Win32DiskImager or any other tool
- boot your RPI, and setup all necessary settings (language, network etc.)
- now update your PI to the latest version and reboot once:
- sudo apt get update
- sudo apt get upgrade
- install the kernel headers: sudo apt-get install raspberrypi-kernel-headers
- install libpopt-dev: sudo apt-get install libpopt-dev
Now download the peak-linux driver-8.9 (or newer) from our linux website and put it into the /home/pi directory:
- tar -xzf peak-linux-driver-8.9.0.tar.gz
- cd peak-linux-driver-8.9.0
- make clean
- make PCC=NO PCI=NO ISA=NO DNG=NO
- sudo make install
- sudo modprobe pcan
- cat /proc/pcan should now show all connected PCAN-USB devices.
- you can now use all chardev tools and libs to work with the PCAN-USB devices
If you want to use the SocketCAN driver, simply uninstall the driver again, and compile it with the following option:
- sudo make uninstall
- make clean
- make PCC=NO PCI=NO ISA=NO DNG=NO NET=NETDEV_SUPPORT
- sudo make install
- sudo modprobe pcan
- cat /proc/pcan should now show all connected PCAN-USB as canX devices.
- you can now install the can-utils and setup the devices with sudo ip link set can0 up type can bitrate 500000 and use the can-utils tools like "candump can0" to trace the connected CAN bus.
Thank you for the detailed instructions.
I am trying to install the peak can driver on my raspberry pi, I followed the instructions but met a problem when executing the make command. the following error occurred.
Code: Select all
make PCC=NO PCI=NO ISA=NO DNG=NO make: Entering directory '/home/pi/peak-linux-driver-8.9.0/driver' *** *** Making pcan driver in chardev mode *** *** Host machine kernel version=4.9.76-rt60-v7+ *** Driver kernel version=4.9.76-rt60-v7+ (4.9.76) *** Path to kernel sources=/usr/src/linux-headers-4.9.76-rt60-v7+ *** use KBUILD=yes *** gcc version=6.3.0 *** make -C /usr/src/linux-headers-4.9.76-rt60-v7+ EXTRA_CFLAGS="-I/home/pi/peak-linux-driver-8.9.0/driver -DNO_DEBUG -DMODVERSIONS -DPARPORT_SUBSYSTEM -DUSB_SUPPORT -DNO -DNO_PCIEC_SUPPORT -DNO -DNO -DNO -DNO_NETDEV_SUPPORT -DNO_RT -Wno-date-time" V=0 modules SUBDIRS=/home/pi/peak-linux-driver-8.9.0/driver make: Entering directory '/usr/src/linux-headers-4.9.76-rt60-v7+' CC [M] /home/pi/peak-linux-driver-8.9.0/driver/src/pcan_main.o /bin/sh: 1: scripts/basic/fixdep: not found scripts/Makefile.build:293: recipe for target '/home/pi/peak-linux-driver-8.9.0/driver/src/pcan_main.o' failed make: *** [/home/pi/peak-linux-driver-8.9.0/driver/src/pcan_main.o] Error 127 Makefile:1497: recipe for target '_module_/home/pi/peak-linux-driver-8.9.0/driver' failed make: *** [_module_/home/pi/peak-linux-driver-8.9.0/driver] Error 2 make: Leaving directory '/usr/src/linux-headers-4.9.76-rt60-v7+' Makefile:474: recipe for target 'all' failed make: *** [all] Error 2 make: Leaving directory '/home/pi/peak-linux-driver-8.9.0/driver' Makefile:91: recipe for target 'all' failed make: *** [all] Error 2
Could you please let me know how to fix this?
Thank you in advance for your help.
Reason: Inserted [code] tags for improved readability
Either your linux-headers package is wrong or it has not been correctly installed. Try to purge then reinstall it.
with this image you will have a kernel 4.19 and my guide was made for this image only!
I have a problem with installing the drivers on my Raspbian Buster (Linux version 4.19.88-v7+). Last week I could follow your instructions and everything was fine - I could connect to my PCAN-USB. Suddenly - I don't know what happened in between - I couldn't connect anymore to the PCAN-USB. For this reason I tried to reinstall everything again. Now I still get errors while follow your instructions:
EDIT: I also reinstalled the kernel headers and libpopt-dev. Without success...pi@RPi-Logger:~/peak-linux-driver-8.9.3 $ make clean
make: Verzeichnis „/home/pi/peak-linux-driver-8.9.3/driver“ wird betreten
Makefile:104: *** "Unable to automatically find the Kernel headers. These are mandatory to build the pcan driver. Please set the KERNEL_LOCATION variable to the root directory of your own built Kernel.". Schluss.
make: Verzeichnis „/home/pi/peak-linux-driver-8.9.3/driver“ wird verlassen
make: *** [Makefile:106: clean] Fehler 2
I hope you can tell me what I am doing wrong....
How did you update to Kernel 4.19.88?
Using official sources (via apt-get upgrade) the latest kernel you can update to is 4.19.75.
Did you use rpi-update by any chance?
thank you for your fast reply. Indeed I did an rpi-update - I can't remember for what reason. I think I tried it to get rid of another problem. Is there a chance to get back?
Unfortunately, once rpi-update has done its work there are two options available:
You either get the kernel-headers for the kernel or you have to start from scratch again.
If possible, do not use rpi-update when using our devices/drivers, since it introduces issues like this.
big thx for your help. I did a rollback to 4.19.75 by rpi-update. The hint how to do this I found at this website:
https://www.elektronik-kompendium.de/si ... 006061.htm
So I was able to rollback with "sudo rpi-update d9321aceacfc6619b4238c6c764203b1122f2f9b"
It seems that everything is fine again...
i dont know if anyone would answer this 2 years old thread
I am having same problem with @Bernd, but my kernel version is 4.19.75-v7l+
Is it only works for exact same Peak driver version ?make: Entering directory '/home/pi/peak-linux-driver-8.10.1/driver'
Makefile:117: *** "Unable to automatically find the Kernel headers. These are mandatory to build the pcan driver. Please set the KERNEL_LOCATION variable to the root directory of your own built Kernel.". Stop.
make: Leaving directory '/home/pi/peak-linux-driver-8.10.1/driver'
make: *** [Makefile:87: clean] Error 2