Files
orin-nano-env-setup/docs/impl/reports/PCAN-SETUP.md
T
mikkeli 007ce0bd8e Record PCAN driver install status on mikkeli-orin-nano
The original report was written on another host. On this machine the
pcan module (NETDEV_SUPPORT) is built, installed under misc/, and loaded
at boot via /etc/modules; the adapter was not yet plugged in. Adds the
verification and post-kernel-update rebuild steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 01:36:27 +09:00

184 lines
5.9 KiB
Markdown

---
type: report
date: 2026-08-04
---
# PCAN-USB Adapter Setup on Jetson Orin Nano
## Hardware
- **Board:** NVIDIA Jetson Orin Nano Engineering Reference Developer Kit Super
- **Hostname:** mikkeli-orin-nano-2
- **OS:** Ubuntu 22.04.5 LTS (aarch64)
- **Kernel:** 5.15.148-tegra (L4T 36.4.4, JetPack r36.4)
- **Adapter:** PEAK-System PCAN-USB (ID `0c72:000c`)
## Onboard CAN
The Jetson Orin Nano has a built-in CAN controller:
- **Interface:** `can0`
- **Controller:** MTTCan (`c310000.mttcan`) — SoC peripheral at memory address `0xc310000`
- **Driver:** `mttcan` (built into NVIDIA Tegra kernel)
- **Module:** `can_dev`
- **Clock:** 50 MHz
- **Status:** Always present, currently DOWN
## USB CAN Adapter — Initial Detection
### Problem
The PCAN-USB adapter was physically connected and detected by the USB subsystem:
```
Bus 001 Device 005: ID 0c72:000c PEAK System PCAN-USB
```
But no CAN interface appeared. The mainline kernel driver `peak_usb` (which supports this device since kernel v3.4) was **not compiled into this NVIDIA Tegra kernel**.
### Investigation
1. Checked for the `peak_usb` module — not present
2. Checked kernel config (`/boot/config-$(uname -r)`) — not available (NVIDIA kernel)
3. Checked for kernel headers — none matched the `5.15.148-tegra` kernel
4. The NVIDIA Tegra kernel from JetPack r36.4 (`repo.download.nvidia.com/jetson/t234`) uses a custom versioning scheme and does not include PEAK's mainline drivers
## Solution — Build PEAK's Proprietary Driver
### Why PEAK's driver instead of mainline?
PEAK's mainline `peak_usb` driver would be the preferred approach (SocketCAN netdev, auto-loading, no rebuild needed on kernel updates). However, the NVIDIA Tegra kernel does not include it. PEAK's proprietary driver package can be built against any kernel that has headers available.
### Step 1: Download PEAK Linux Driver Package
```bash
curl -L "https://www.peak-system.com/quick/PCAN-Linux-Driver" -o /tmp/pcan-driver.tar.gz
cd /tmp && tar -xzf pcan-driver.tar.gz
# Extracts to: /tmp/peak-linux-driver-9.2.0/
```
### Step 2: Build with SocketCAN (netdev) Support
The PEAK driver defaults to **chardev** mode (character devices like `/dev/pcanusb32`). For standard SocketCAN tools (`candump`, `ip link`, etc.), we need **netdev** mode:
```bash
cd /tmp/peak-linux-driver-9.2.0/driver
sudo make clean
sudo make NET=NETDEV_SUPPORT all
```
Key output confirming netdev build:
```
CC [M] /tmp/peak-linux-driver-9.2.0/driver/src/pcan_netdev.o
LD [M] /tmp/peak-linux-driver-9.2.0/driver/pcan.ko
```
### Step 3: Install the Module
```bash
cd /tmp/peak-linux-driver-9.2.0/driver
sudo cp pcan.ko /lib/modules/5.15.148-tegra/misc/pcan.ko
sudo depmod 5.15.148-tegra
```
### Step 4: Load the Module
```bash
sudo modprobe -r pcan 2>/dev/null
sudo modprobe pcan
```
### Result
```
$ ip link show type can
3: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
link/can
8: can1: <NOARP> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
link/can
```
- `can0` = onboard MTTCan
- `can1` = PCAN-USB adapter
### Step 5: Bring Up the Interface
```bash
sudo ip link set can1 up type can bitrate 500000
```
### Step 6: Read CAN Traffic
```bash
sudo candump can1
```
## Build Environment
- **GCC:** 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04.2)
- **make:** Available
- **Kernel headers:** Located at `/lib/modules/5.15.148-tegra/build`
- **Driver version:** PEAK Linux Driver 9.2.0
## Important Notes
1. **Out-of-tree module:** This driver is built from PEAK's source against the running kernel. It will **not survive a kernel update** — you must rebuild after any kernel upgrade.
2. **Netdev vs chardev:** The PEAK driver defaults to chardev mode. For SocketCAN tools, you must build with `NET=NETDEV_SUPPORT`. The chardev mode creates `/dev/pcan*` devices and requires PEAK's proprietary API.
3. **Blacklisting:** The PEAK installer (`make install`) blacklists the mainline `peak_*` drivers in `/etc/modprobe.d/blacklist-peak.conf`. Since the mainline drivers aren't available on this kernel anyway, this is harmless.
4. **Bitrate:** The default CAN bitrate is 500 kbps. Adjust as needed for your car's bus (common values: 500000, 250000, 1000000).
5. **Read-only use:** For reading car CAN traffic without transmitting, you only need to bring the interface up. No special configuration is needed.
## Cleanup
Source files left at `/tmp/peak-linux-driver-9.2.0/` and `/tmp/pcan-driver.tar.gz`. Can be removed after verifying everything works.
## Current Status — 2026-08-05
This report was written during an earlier session. On this machine (hostname: `mikkeli-orin-nano`,
kernel `5.15.148-tegra`, L4T 36.4.4) the driver has been **built and installed**:
| Step | Status |
|------|--------|
| Download PEAK Linux Driver 9.2.0 | Done (source at `/tmp/peak-linux-driver-9.2.0/`) |
| Build with `NET=NETDEV_SUPPORT` | Done — module compiled successfully |
| Install to `/lib/modules/.../misc/pcan.ko` | Done |
| `depmod 5.15.148-tegra` | Done |
| `modprobe pcan` | Done — module loaded (`lsmod | grep pcan` confirms) |
| Boot persistence (`/etc/modules`) | Done — `pcan` added to `/etc/modules` |
**Device not yet physically connected.** The USB adapter (`0c72:000c`) will be auto-detected and
a `canX` interface created when plugged in. No udev rule is needed since the module loads at boot
and the kernel matches the USB VID/PID against the module's built-in aliases.
### Verification (after plugging in the device)
```bash
# Confirm module is loaded
lsmod | grep pcan
# Check for new CAN interface
ip link show type can
# Bring it up at 500 kbps
sudo ip link set canX up type can bitrate 500000
# Read traffic
sudo candump canX
```
### After a kernel update
This is an out-of-tree module. Rebuild with:
```bash
cd /tmp/peak-linux-driver-9.2.0/driver
make clean
make NET=NETDEV_SUPPORT all
sudo cp pcan.ko /lib/modules/$(uname -r)/misc/pcan.ko
sudo depmod
sudo modprobe pcan
```