# CAN
Source: [https://docs.qualcomm.com/doc/80-70030-8/topic/can.html](https://docs.qualcomm.com/doc/80-70030-8/topic/can.html)
Controller area network (CAN) is a message-based serial protocol. The terms CAN and CAN
bus are used in the same context. The advantages of CAN are as follows:
- Uses CSMA/CD method and bitwise contention to sense the bus at the bit-level and
transmit the message.
- Each message is assigned a priority. Messages with the highest priority always
control the bus arbitration. Since arbitration is based on bits, there are dominant
and recessive bit levels.
- Any node can transmit at any time, no primary-secondary nodes.
- All the data is transmitted through two (differential pair) lines: CAN\_H and CAN\_L
line.
- CAN nodes are synchronized using bit-synchronization where each bit time is divided
in to four segments of time quanta.
- Facilitates communication between multiple nodes through a message-based protocol,
eliminating the need for extensive wiring.
- Ensures data security with error management including detection, signaling, and
correction.
Note:
- CAN is enabled by default in QCS6490 and QCS5430.
- Dragonwing IQ-9075, Dragonwing IQ-8275, and Dragonwing IQ-615 don't support CAN.
## CAN features
Source: [https://docs.qualcomm.com/doc/80-70030-8/topic/can.html](https://docs.qualcomm.com/doc/80-70030-8/topic/can.html)
The CAN protocol supports the following features.
- Multicontroller priority-based bus access
- Nondestructive content-based arbitration
- Broadcast through all-frame transfer
- Multicast frame transfer by acceptance filtering
- Remote data request
- Configuration flexibility
- Network-wide data consistency
- Error detection and error signaling
- Automatically retransmits frames that lose arbitration, lack acknowledgment, or
encounter errors during transmission
- Identifies differences between temporary node errors and permanent node failures,
and the automatic deactivation of faulty nodes
## CAN architecture
Source: [https://docs.qualcomm.com/doc/80-70030-8/topic/can.html](https://docs.qualcomm.com/doc/80-70030-8/topic/can.html)
The MCP2517 is an external configurable CAN controller, which can be accessed through the
SPI line. The SPI interface supports up to 20 MHz with support for Mode0,1. The
controller is connected to a QUP block with SE3 configured by a 4-pin SPI operation. The
SPI controller is connected to a transceiver (MCP2561xxx) which connects to the CAN bus.
Power input to the SPI controller and the CAN transceiver is through the SoC.
Figure : CAN architecture
The user application communicates with the network interface provided by the SocketCAN.
The software driver is a client of the SPI core module in Linux, to which the QUP\_SPI
driver is registered with. The actual hardware is connected through the SPI pins.
Figure : CAN software stack
## CAN APIs
Source: [https://docs.qualcomm.com/doc/80-70030-8/topic/can.html](https://docs.qualcomm.com/doc/80-70030-8/topic/can.html)
For CAN public APIs, see [https://www.kernel.org/doc/Documentation/networking/can.txt](https://www.kernel.org/doc/Documentation/networking/can.txt).
## CAN samples and tools
Source: [https://docs.qualcomm.com/doc/80-70030-8/topic/can.html](https://docs.qualcomm.com/doc/80-70030-8/topic/can.html)
The SocketCAN user space utilities and tools to display, record, generate, and replay the
CAN traffic are listed in the following table.
Table : SocketCAN utilities
| Utility | Description |
| --- | --- |
| `candump` | To display, filter and log CAN data to files. |
| `canplayer` | To replay CAN log files. |
| `cansend` | To send a single frame. |
| `cangen` | To generate (random) CAN traffic. |
| `cansniffer` | To display CAN data content differences (just 11‑bit CAN IDs). |
To download CAN utilities, see [https://github.com/linux-can/can-utils](https://github.com/linux-can/can-utils).
For information about CAN driver files, see
kernel/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c.
### CAN analyzer - PCAN-USB FD
The PCAN-USB FD is a versatile CAN packet/message sniffer that can operate as a node
on any CAN bus, supporting flexible data rates. It can be used to sniff and send CAN
packets on a host machine over USB. The key features are as follows:
- PCAN-View GUI tool
- Provides easy ways to sniff and send CAN packets as per-user needs.
- Monitors and debugs CAN packets during development and testing.
- PCAN-USB FD interface
- Enables a simple connection to CAN FD and CAN networks.
- Compact plastic casing suitable for mobile applications.
- Galvanic isolation of up to 500 V decouples the PC from the CAN
bus.
- CAN FD standard
- Characterized by higher bandwidth for data transfer.
- Allows transmission of up to 64 data bytes per CAN FD frame (instead of
8).
- Supports bit rates up to 12 Mbit/s.
- Downward compatible with the CAN 2.0 standard.
- CAN FD nodes can be inserted into existing CAN networks without CAN FD
extensions.
**Hardware setup**
1. Connect to the DB9 connector.
- The PCAN has a DB9 connector on which any standard DB9 connector can
be plugged in.
2. Connect to the Qualcomm device.
- Pull out the CAN\_H, CAN\_L, and GND lines.
- Connect these lines to the two terminal-resistors of 120 Ω.
3. Connect CAN\_H, CAN\_L, and Ground.

4. Connect an external terminating resistor.
Note: The
device doesn't have an internal terminating resistor of 120 Ω. This is
crucial because some tools provide built-in support for the terminating
resistor.

The following figure shows the connected hardware.
Figure : CAN USB FD, external resistor, and device connection

## Bringup CAN interface
Source: [https://docs.qualcomm.com/doc/80-70030-8/topic/can.html](https://docs.qualcomm.com/doc/80-70030-8/topic/can.html)
After the CAN driver is built and loaded into the kernel, the following sequence of
commands sends data to identify if the CAN node is up. A CAN node can be started or
stopped using the commands listed in the following table.
Note: All the network devices use `ifconfig -a`.
Table : CAN commands
| Instruction | Command |
| --- | --- |
| Check for the can node number | ifconfig -aCopy to clipboard |
| Set a bit rate of 125 kbps | ip link set can0 up type can bitrate 125000Copy to clipboard |
| Start CAN | ip link set can0 upCopy to clipboard |
| Stop CAN | ip link set can0 downCopy to clipboard |
| Check the CAN configuration | ip -details link show can0Copy to clipboard |
| CAN internal loopback | ip link set can0 up type can bitrate 500000 loopback onCopy to clipboard |
| CAN FD internal loopback | ip link set can0 up type can bitrate 1000000 dbitrate 5000000 fd on loopback onCopy to clipboard |
| Send CAN FD frame | cansend can0 213##311223344Copy to clipboard |
To start any CAN node, the bit rate for the bus must be defined, or configured if the
bus-rate is already available. This configuration ensures that the CAN node is up and
active. For more details about CAN utilities, see [https://manpages.debian.org/testing/can-utils/index.html](https://manpages.debian.org/testing/can-utils/index.html).
### Send and receive data
Some utilities are available in the `CAN-Utils`file. SocketCAN
enables CAN nodes for sending and receiving data. SocketCAN APIs are also used for
custom applications.
- Send data with 11‑bit
ID
cansend can0 7AF#11.22.33.44.55.66.aa.ffCopy to clipboard
- Send data with 29‑bit ID
cansend can0 111FFFFF#aa.00.cc.aa.33.61.aa.abCopy to clipboard
- View the current incoming data on can0
node
candump can0Copy to clipboard
## Configure CAN interface
Source: [https://docs.qualcomm.com/doc/80-70030-8/topic/can.html](https://docs.qualcomm.com/doc/80-70030-8/topic/can.html)
SocketCAN is an implementation of the CAN protocol for Linux. SocketCAN uses the
Berkeley socket API, the Linux network stack and implements the CAN device drivers
as network interfaces. The CAN socket API has been designed as similar as possible
to the TCP/IP protocols to allow users, familiar with network programming, easily
learn how to use CAN sockets.
### Initialize hardware
The driver initializes and configures the underlying hardware block. The
initialization occurs after the `driver's _probe()` function is
called.
static struct spi_driver mcp251xfd_driver = {
.driver = {
.name = DEVICE_NAME,
.pm = &mcp251xfd_pm_ops,
.of_match_table = mcp251xfd_of_match,
},
.probe = mcp251xfd_probe,
.remove = mcp251xfd_remove,
.id_table = mcp251xfd_id_table,
};
static int mcp251xfd_probe(struct spi_device *spi)
{
struct net_device *ndev;
struct mcp251xfd_priv *priv;
[..]
ndev = alloc_candev(sizeof(struct mcp251xfd_priv),
MCP251XFD_TX_OBJ_NUM_MAX);
if (!ndev)
return -ENOMEM;
SET_NETDEV_DEV(ndev, &spi->dev); // The SPI node is set as the parent node to the network device.
ndev->netdev_ops = &mcp251xfd_netdev_ops;
[..]
err = mcp251xfd_register(priv);
};Copy to clipboard
## Debug CAN issues
Source: [https://docs.qualcomm.com/doc/80-70030-8/topic/can.html](https://docs.qualcomm.com/doc/80-70030-8/topic/can.html)
CAN issues can be debugged using the `ftrace` tool. The MCP2517 driver
supports the `dev_coredump()` API.
## CAN examples
Source: [https://docs.qualcomm.com/doc/80-70030-8/topic/can.html](https://docs.qualcomm.com/doc/80-70030-8/topic/can.html)
For CAN examples, see [https://github.com/linux-can/can-utils/blob/master/README.md](https://github.com/linux-can/can-utils/blob/master/README.md).
Last Published: Jul 03, 2026
[Previous Topic
USB](https://docs.qualcomm.com/bundle/publicresource/80-70030-8/topics/usb.md) [Next Topic
References](https://docs.qualcomm.com/bundle/publicresource/80-70030-8/topics/references.md)