CANopen Overview¶
CANopen is a CAN-based communication system, which comprises higher-layer protocols and profile specifications. CANopen has been developed as an international standard (EN 50325-4)(CiA301)
with highly flexible configuration capabilities. It is used in various applications, such as medical equipment, AMR, and Robotic or motion-oriented machine control systems.
A general CANopen device has three logical parts:
CANopen protocol stack handles communication via the CAN network.
Application software provides the internal control functionality and the interface to process hardware.
Object dictionary interfaces the protocol and the application software. It contains references of all data types used, and stores all communication and application parameters.
This section describes the procedure to run CANopen stack on Intel® Edge Controls for Industrial (Intel® ECI or ECI).
Prepare CANopen¶
Install CANopen¶
You can install this component from the ECI APT repository. Setup the ECI APT repository, then perform either of the following commands to install this component:
- Install from meta-package
$ sudo apt install eci-softplc-fieldbus
- Install from individual Deb package
$ sudo apt install canopen canopen-tests canopenservo canopenservo-tests
Load Driver¶
Click the corresponding tab to learn more.
Check the CAN driver status, and confirm whether the peak_pci
kernel driver is in use:
01:00.0 Network controller: PEAK-System Technik GmbH Device 0008 (rev 02)
Subsystem: PEAK-System Technik GmbH Device 0002
Flags: bus master, fast devsel, latency 0, IRQ 16
Memory at 90810000 (32-bit, non-prefetchable) [size=64K]
Memory at 90800000 (32-bit, non-prefetchable) [size=64K]
Capabilities: <access denied>
Kernel driver in use: peak_pci
Kernel modules: peak_pci
If the peak_pci
kernel driver is not in use, set up udev
rules or type the following command manually:
$ modprobe peak_pci
Load the kernel module for virtual CAN support:
$ modprobe vcan
To enable CAN on Intel® X86 platform, re-purpose the existing Serial Peripheral Interface (SPI) fingerprint reader interface for a CAN device. This is an example to adapt Microchip* MCP2518FD as an external CAN FD Controller with SPI.
Hardware Connections
The following table lists the PIN mapping in between Tiger Lake and MCP2518FD.
Net Name
Tiger Lake
MCP2518FD (Pin)
SPI
GSPI1_MOSI_FPS_R
SDI(11)
GSPI1_MISO_FPS_R
SDO(12)
GSPI1_CLK_FPS_R
SCK(10)
GSPI1_CS0_FPS_R_N
CS(13)
IRQ
GPPC_E3_FPS_INT
INT1/GPIO1(8)
Make sure that your customized hardware designs relate to Intel’s platform reference design and the reference design of Microchip MCP251XFD.
Enable BIOS
BIOS needs to modify the ACPI table to add a SPI device for MCP2518FD. Make sure that the customized BIOS PIN uses the same configuration as that of Intel’s reference code for the corresponding PINs. Also, provide this table to BIOS for integration or use
iasl
to override the ASL code of the method.DefinitionBlock ("canbus.aml", "SSDT", 1, "Vendor", "Intel", 0x00000003) { External (\_SB.PC00.SPI1, DeviceObj) Scope (\_SB.PC00.SPI1) { Device (TP4) { Name (_HID, "MCP2518") Name (_DDN, "SPI test device connected to CS0") Name (_CRS, ResourceTemplate () { SpiSerialBus ( 0, // Chip select PolarityLow, // Chip select is active low FourWireMode, // Full duplex 8, // Bits per word is 8 (byte) ControllerInitiated, // Don't care 20000000, // 20 MHz ClockPolarityLow, // SPI mode 0 ClockPhaseFirst, // SPI mode 0 \\_SB.PC00.SPI1, // SPI host controller 0 // Must be 0 ) GpioInt (Edge, ActiveLow, ExclusiveAndWake, PullDefault, 0, \\_SB.GPI0, 0, ResourceConsumer, ) { 323 } }) Name (_DSD, Package () { ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package () { Package () {"rxint-gpios", Package () { ^TP4, 0, 0, 0 } } } }) } } }
Check the CAN driver status, and confirm whether the
mcp251xfd
kernel driver is in use:$ lsmod | grep mcp251xfd
The output should be similar to the following:
mcp251xfd 45056 0 can_dev 32768 1 mcp251xfd
If the
mcp251xfd
kernel driver is not in use, set upudev
rules or type the following command manually:$ modprobe mcp251xfd
For Elkhart Lake Programmable Services Engine (PSE), go to Intel(R) Advanced Menu > PCH-IO Configuration > PSE Configuration on the target system and configure the BIOS as listed in the following table:
Setting Name |
Option |
---|---|
I2C7 |
Host Owned with pin multiplexed |
CAN0 |
Host Owned with pin multiplexed |
CAN1 |
Host Owned with pin multiplexed |
Set up CAN/VCAN Interface¶
Click the corresponding tab to learn more.
Configure CAN bitrate (for example,
1Mbps
):$ ip link set can0 type can bitrate 1000000
Bring up the CAN interface:
$ ip link set up can0
Check the CAN interface link status:
$ ip addr ls dev can0
Add a virtual interface:
$ ip link add dev can0 type vcan
Bring up the virtual CAN interface:
$ ip link set up can0
Check the CAN interface link status:
$ ip addr ls dev can0
CANopen - Sanity Checks¶
The following section is applicable to:

Sanity Check #1: Virtual CAN Interface Link Up¶
Verify the CAN interface link status:
$ ip addr ls dev can0
Sanity Check #2: SocketCAN Dump Test¶
Capture the incoming CAN frames on
can0
:$ candump can0
Send a standard CAN frame with
0x1FF
as the ID and0x01
,0x02
,0x03
,0x04
as 4-byte payloads:$ cansend can0 1FF#01020304
Sanity Check #3: CANopen Tests Automatically¶
Navigate to the
/opt/opencan/test
directory:$ cd /opt/opencan/test
Start the devices:
$ canopend can0 -i 1 -c "local-/tmp/CO_command_socket" & $ ./demoLinuxDevice can0 &
Navigate to the
/opt/opencan/test/running_canopen
directory:$ cd /opt/opencan/test/running_canopen
Run the tests:
$ ./SDO_transfer.bats
View the test results on the console:
root@ECI:/opt/opencan/test/running_canopen# ./SDO_transfer.bats \u2713 Segmented write \u2713 Segmented read \u2713 Segmented transfer, files equal \u2713 Block write \u2713 Block read - 2x \u2713 Block transfer, files equal 10240 bytes, segmented written/read: / milliseconds. 10240 bytes, block written/read: / milliseconds. 6 tests, 0 failures
Tip
If
canopend
ordemoLinuxDevice
program exits abnormally, make sure that local socket interfacelocal-/tmp/CO_command_socket
and several*.persist
files has been deleted before next time launch the program.
Sanity Check #4: CANopen Servo SDO Enable Test¶
Set up the CAN/VCAN interface and connect servo drive.
Navigate to the
/opt/opencan/test
directory:$ cd /opt/opencan/test
Start the devices, default servo
nodeId
1
:$ ./demoLinuxDevice can0 -i 1 -c local-/tmp/CO_command_socket & $ cocomm "1 preop" $ cocomm "1 start" $ cocomm "1 w 0x6040 0x00 u16 0x86" $ cocomm "1 w 0x6040 0x00 u16 0x07" $ cocomm "1 w 0x6040 0x00 u16 0x0F" $ cocomm "1 w 0x6060 0x00 u8 0x03" $ cocomm "1 w 0x60FF 0x00 u32 100"
Expected result: CANopen servo motor will rotate.