repo restructure

This commit is contained in:
2026-08-04 16:01:09 +08:00
parent 6813d2f069
commit bbfe1440aa
2 changed files with 11 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
---
type: default
---
# Orin Nano env setup Guidelines
## 1. Where applicable, keep self-built binaries under a dedicated `infra` directory
- `/home/mikkeli/infra/` houses self-built binaries and their source code/repositories(organised to their own sub directories)
- **Where applicable,** symlink built binaries to a PATH entry or where said binary is usually expected
*Exception:* if symlink is not accepted for some reason, copy the binary to the expected destination and keep track of freshness.
## 2. To be added
+132
View File
@@ -0,0 +1,132 @@
# 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.