[CAN 05] - PCAN Device Driver Installation on Linux

Step-by-step guide to installing PEAK-System's PCAN drivers on Linux for SocketCAN and PCAN-Basic API

If you’re working with CAN bus networks on a Linux machine, chances are you’re using hardware from PEAK-System. While newer Linux kernels natively support many PCAN interfaces via SocketCAN, there are plenty of scenarios where you need to get your hands dirty and manually install the proprietary drivers.

Whether you are working in a minimized Linux environment, running an older kernel, or specifically need the character-based driver (chardev) to use the PCAN-Basic API (like the PCAN Python API), this guide will walk you through the entire installation process from start to finish.

Part 1: Installing the PCAN Linux Driver

First, we need to install the core driver. You can find the latest proprietary PCAN-Linux driver package here. For deeper technical details, you can always refer to the official PCAN Driver Manual.

Step 1: Download and Extract

Once you’ve downloaded the driver package, open your terminal and extract the files:

tar -xzvf peak-linux-driver-*.tar.gz

Navigate into the newly created directory and clear out any old build files:

cd peak-linux-driver-*
make clean

Step 2: Install Dependencies

Before we can compile the driver, our system needs a few development libraries. Install them using apt:

sudo apt-get update
sudo apt-get install libelf-dev libpopt-dev

Step 3: Compile and Install

Now you are ready to build the driver. Run the following commands:

make clean
make
sudo make install

🛠️ Troubleshooting: GCC Errors If you encounter compilation errors and are using gcc-11, try compiling with gcc-12 instead. You can do this by specifying the compiler in your make command:

make clean
make CC=gcc-12
sudo make install

A Note on SocketCAN vs. PCAN-Basic

By default, running the standard make command builds the driver with chardev (Character Device) support. This is exactly what you need if you plan to use the PCAN-Basic API.

However, if your goal is to use the device with SocketCAN (which typically works without driver installation on modern kernels, but might need an update on older ones), you must explicitly rebuild the driver with network device support (netdev):

make -C driver NET=NETDEV_SUPPORT

Part 2: Installing the PCAN-Basic API

With the base driver installed via chardev, we can now install the PCAN-Basic API. This API provides the necessary libraries to write custom applications (in C++, Python, etc.) that communicate with your CAN bus.

Step 1: Download and Extract

Head over to the PEAK-System website and Download the PCAN-Basic API for Linux.

Extract the tarball and navigate into the pcanbasic source directory:

tar -xzvf PCAN-Basic_Linux-*.tar.gz
cd PCAN-Basic_Linux-*/libpcanbasic/pcanbasic/

Step 2: Compile and Install

Just like with the driver, we will clean, make, and install the API libraries:

make clean
make
sudo make install

Part 3: Load the Driver (No Reboot Required!)

Normally, installing kernel modules requires a system reboot. However, you can bypass this and start using your CAN interface immediately by asking the Linux kernel to probe for the newly installed PCAN module:

sudo modprobe pcan

Plug in your PCAN hardware, and you are ready to start sniffing, sending, and analyzing CAN frames!