| Table of Contents | ||
|---|---|---|
|
| Info |
|---|
This is an add-on product that installs on top of the Linux BSP for the NXP i.MX RT EVK board. It must be purchased separately from the Linux BSP product. |
1. Overview
This project develops Linux CAN device driver in the Linux BSP for the i.MX RT processor.
2. Requirements
2.1. Detailed Requirements
The following are the requirements for this project:
Provide a Linux demo project combining all the requirements in this project.
Rationale: Needed to let Customer integrate results of this project into target embedded application.
Implementation: Section: "Design: Demo project".
Test: Section: "Test Plan: Demo Project".
Develop Linux CAN device driver for the i.MX RT CAN controller.
Rationale: Explicit Customer requirement.
Implementation: Section: "Design: Linux CAN Device Driver".
Test: Section: "Test Plan: Linux CAN Driver".
Port CANSocket to the Linux i.MX RT BSP.
Rationale: Explicit Customer requirement.
Implementation: Section: "Design: CANSocket".
Test: Section: "Test Plan: CANSocket".
Validate successful execution of the test suite from the SocketCAN package.
Rationale: Explicit Customer requirement.
Implementation: Section: "Design: CANSocket Test Suite".
Test: Section: "Test Plan: CANSocket Test Suite".
2.2. Detailed Non-Requirements
The following are the non-requirements for this project that may otherwise not be obvious:
None
3. Design
3.1. Detailed Design
3.1.1.
| Anchor | ||||
|---|---|---|---|---|
|
This project will enable the required CAN functionality in Linux configuration ("embedded project") called rootfs, which resides in a projects/rootfs directory, relative to the top of the Linux i.MX RT installation.
3.1.2.
| Anchor | ||||
|---|---|---|---|---|
|
The internal i.MX clocks necessary for the CAN interface will be enabled in the kernel. The i.MX RT flexcan interface network driver linux/drivers/net/can/flexcan.c will be enabled, and the respective changes will be added to the kernel .dts file.
The flexcan functionality will be enabled in the Linux kernel configuration as follows:
Go to
Networking support->CAN bus subsystem support->CAN Device DriversEnable
Platform CAN drivers with Netlink support(CONFIG_CAN_DEV) andSupport for Freescale FLEXCAN based chips(CONFIG_CAN_FLEXCAN)
3.1.3.
| Anchor | ||||
|---|---|---|---|---|
|
The CAN socket API, described in details in linux/Documentation/networking/can.txt, will be enabled using the Raw CAN Protocol (raw access with CAN-ID filtering) and Broadcast Manager CAN Protocol (with content filtering) configuration options in the Networking support -> CAN bus subsystem support configuration menu.
3.1.4.
| Anchor | ||||
|---|---|---|---|---|
|
The can-utils and can-tests packages will be used for verification of the functionality implemented in this project.
3.2. Effect on Related Products
This project makes the following updates in the related products:
None
3.3. Changes to User Documentation
This project updates the following user documents:
None
3.4. Alternative Design
The following alternative design approaches were considered by this project but then discarded for some reason:
None
4. Test Plan
4.1. Secure Download Area
The downloadable materials developed by this project are available from a secure Web page on the Emcraft Systems web site. Specifically, proceed to the following URL to download the software materials:
For the i.MX RT1024 BSP release:
https://www.emcraft.com/imxrtaddon/imxrt1024/can
The page is protected as follows:
Login: CONTACT EMCRAFT
Password: CONTACT EMCRAFT
For the i.MX RT1050 BSP (release 3.0.4):
https://www.emcraft.com/imxrtaddon/imxrt1050/can
The page is protected as follows:
Login: CONTACT EMCRAFT
Password: CONTACT EMCRAFT
For the i.MX RT1050 BSP (release 3.1.0):
https://www.emcraft.com/imxrtaddon/imxrt1050-3.1.0/can
The page is protected as follows:
Login: CONTACT EMCRAFT
Password: CONTACT EMCRAFT
For the i.MX RT1060 BSP (release 3.1.0):
https://www.emcraft.com/imxrtaddon/imxrt1060-3.1.0/can
The page is protected as follows:
Login: CONTACT EMCRAFT
Password: CONTACT EMCRAFT
...
This is an add-on product that installs on top of the Linux BSP for the NXP i.MX
...
https://www.emcraft.com/imxrtaddon/imxrt1170/can
The page is protected as follows:
Login: CONTACT EMCRAFT
Password: CONTACT EMCRAFT
...
The following files are available from the secure download area:
linux-flexcan.patch- patch to the Linux kernel sources;projects-flexcan.patch- patch to therootfsproject;rootfs.uImage- prebuilt bootable Linux image;
Refer to the below sections for the instructions on how to install and use these files.
4.3. 4.3. Test Set-Up
4.3.1. Hardware Setup
The following hardware setup is required for the i.MX RT1024 boards:
...
RT EVK board. It must be purchased separately from the Linux BSP product.
5. Overview
This project develops Linux CAN device driver in the Linux BSP for the i.MX RT processor.
6. Requirements
6.1. Detailed Requirements
The following are the requirements for this project:
Provide a Linux demo project combining all the requirements in this project.
Rationale: Needed to let Customer integrate results of this project into target embedded application.
Implementation: Section: "Design: Demo project".
Test: Section: "Test Plan: Demo Project".
Develop Linux CAN device driver for the i.MX RT CAN controller.
Rationale: Explicit Customer requirement.
Implementation: Section: "Design: Linux CAN Device Driver".
Test: Section: "Test Plan: Linux CAN Driver".
Port CANSocket to the Linux i.MX RT BSP.
Rationale: Explicit Customer requirement.
Implementation: Section: "Design: CANSocket".
Test: Section: "Test Plan: CANSocket".
Validate successful execution of the test suite from the SocketCAN package.
Rationale: Explicit Customer requirement.
Implementation: Section: "Design: CANSocket Test Suite".
Test: Section: "Test Plan: CANSocket Test Suite".
6.2. Detailed Non-Requirements
The following are the non-requirements for this project that may otherwise not be obvious:
None
7. Design
7.1. Detailed Design
7.1.1.
| Anchor | ||||
|---|---|---|---|---|
|
This project will enable the required CAN functionality in Linux configuration ("embedded project") called rootfs, which resides in a projects/rootfs directory, relative to the top of the Linux i.MX RT installation.
7.1.2.
| Anchor | ||||
|---|---|---|---|---|
|
The internal i.MX clocks necessary for the CAN interface will be enabled in the kernel. The i.MX RT flexcan interface network driver linux/drivers/net/can/flexcan.c will be enabled, and the respective changes will be added to the kernel .dts file.
The flexcan functionality will be enabled in the Linux kernel configuration as follows:
Go to
Networking support->CAN bus subsystem support->CAN Device DriversEnable
Platform CAN drivers with Netlink support(CONFIG_CAN_DEV) andSupport for Freescale FLEXCAN based chips(CONFIG_CAN_FLEXCAN)
7.1.3.
| Anchor | ||||
|---|---|---|---|---|
|
The CAN socket API, described in details in linux/Documentation/networking/can.txt, will be enabled using the Raw CAN Protocol (raw access with CAN-ID filtering) and Broadcast Manager CAN Protocol (with content filtering) configuration options in the Networking support -> CAN bus subsystem support configuration menu.
7.1.4.
| Anchor | ||||
|---|---|---|---|---|
|
The can-utils and can-tests packages will be used for verification of the functionality implemented in this project.
7.2. Effect on Related Products
This project makes the following updates in the related products:
None
7.3. Changes to User Documentation
This project updates the following user documents:
None
7.4. Alternative Design
The following alternative design approaches were considered by this project but then discarded for some reason:
None
8. Test Plan
8.1. Secure Download Area
The downloadable materials developed by this project are available from a secure Web page on the Emcraft Systems web site. Specifically, proceed to the following URL to download the software materials:
For the i.MX RT1024 BSP release:
https://www.emcraft.com/imxrtaddon/imxrt1024/can
The page is protected as follows:
Login: CONTACT EMCRAFT
Password: CONTACT EMCRAFT
For the i.MX RT1050 BSP (release 3.0.4):
https://www.emcraft.com/imxrtaddon/imxrt1050/can
The page is protected as follows:
Login: CONTACT EMCRAFT
Password: CONTACT EMCRAFT
For the i.MX RT1050 BSP (release 3.1.0):
https://www.emcraft.com/imxrtaddon/imxrt1050-3.1.0/can
The page is protected as follows:
Login: CONTACT EMCRAFT
Password: CONTACT EMCRAFT
For the i.MX RT1060 BSP (release 3.1.0):
https://www.emcraft.com/imxrtaddon/imxrt1060-3.1.0/can
The page is protected as follows:
Login: CONTACT EMCRAFT
Password: CONTACT EMCRAFT
For the i.MX RT1050 BSP (release 3.2.0):
https://www.emcraft.com/imxrtaddon/imxrt1050-3.2.0/can
The page is protected as follows:
Login: CONTACT EMCRAFT
Password: CONTACT EMCRAFT
For the i.MX RT1060 BSP (release 3.1.0):
https://www.emcraft.com/imxrtaddon/imxrt1060-3.2.0/can
The page is protected as follows:
Login: CONTACT EMCRAFT
Password: CONTACT EMCRAFT
For the i.MX RT1170 BSP release:
https://www.emcraft.com/imxrtaddon/imxrt1170/can
The page is protected as follows:
Login: CONTACT EMCRAFT
Password: CONTACT EMCRAFT
8.2.
| Anchor | ||||
|---|---|---|---|---|
|
The following files are available from the secure download area:
linux-flexcan.patch- patch to the Linux kernel sources;projects-flexcan.patch- patch to therootfsproject;rootfs.uImage- prebuilt bootable Linux image;
Refer to the below sections for the instructions on how to install and use these files.
8.3. Test Set-Up
8.3.1. Hardware Setup
The following hardware setup is required for the i.MX RT1024 boards:
The i.MX RT1024 EVK board, with the serial console attached as per https://emcraft.com/imxrt1024-evk-board/connecting-serial-console-to-imxrt1024-evk .
A Linux PC with the
VSCOM USB-CANUSB to CAN Adapter http://www.vscom.de/vscom-usb-can.html plugged into a USB port on the PC, and the following connections to the i.MX RT1024 EVK board:DB9.2of USB-CAN connected toCANLJ10.3 on the i.MX RT EVK board.DB9.7of USB-CAN connected toCANHJ10.1 on the i.MX RT EVK board.DB9.3of USB-CAN connected toGNDJ10.2 on the i.MX RT EVK board.
for the i.MX RT1050 boards:
The i.MX RT1050 EVKB board, with the serial console attached as per Connecting Serial Console to the NXP i.MX RT10XX EVK Board
A Linux PC with the
VSCOM USB-CANUSB to CAN Adapter http://www.vscom.de/vscom-usb-can.html plugged into a USB port on the PC, and the following connections to the i.MX
...
RT1050 EVKB board:
DB9.2of USB-CAN connected toCANL
...
J11.3 on the i.MX RT EVK board.
DB9.7of USB-CAN connected toCANH
...
J11.1 on the i.MX RT EVK board.
DB9.3of USB-CAN connected toGND
...
J11.2 on the i.MX RT EVK board.
for the i.MX
...
RT1060 boards:
The i.MX
...
RT1060 EVKB board, with the serial console attached as per Connecting Serial Console to the NXP i.MX RT10XX EVK Board .
A Linux PC with the
VSCOM USB-CANUSB to CAN Adapter http://www.vscom.de/vscom-usb-can.html plugged into a USB port on the PC, and the following connections to the i.MX
...
RT1060 EVKB board:
DB9.2of USB-CAN connected toCANL
...
J42.3 on the i.MX RT EVK board.
DB9.7of USB-CAN connected toCANH
...
J42.1 on the i.MX RT EVK board.
DB9.3of USB-CAN connected toGND
...
J42.2 on the i.MX RT EVK board.
for the i.MX
...
RT1170 boards:
The i.MX
...
RT1170 EVK/EVKB board, with the serial console attached as per
...
https://emcraft.com/imxrt1170-evk-board/connecting-serial-console-to-imxrt1170-evk .
A Linux PC with the
VSCOM USB-CANUSB to CAN Adapter http://www.vscom.de/vscom-usb-can.html plugged into a USB port on the PC, and the following connections to the i.MX
...
RT1170 EVK/EVKB board:
DB9.2of USB-CAN connected toCANL
...
J47.3 on the i.MX
...
RT1170 EVK/EVKB board.
DB9.7of USB-CAN connected toCANH
...
J47.1 on the i.MX
...
RT1170 EVK/EVKB board.
DB9.3of USB-CAN connected toGND
...
J47.2 on the i.MX
...
RT1170 EVK/EVKB board.
...
Remove J102 and J103 jumpers on the i.MX RT1170
...
EVKB board.
for the Avnet MaaXBoard-RT:
The i.MX RT1170 EVK/EVKB board, with
...
the serial console attached as per the MaaXBoard RT Hardware User Guide.
A Linux PC with the
VSCOM USB-CANUSB to CAN Adapter http://www.vscom.de/vscom-usb-can.html plugged into a USB port on the PC, and the following connections to the
...
Avnet MaaxBoard-RT board:
DB9.2of USB-CAN connected toCANL
...
J15.3 on the
...
Avnet MaaxBoard-RT board.
DB9.7of USB-CAN connected toCANH
...
J15.
...
6 on the
...
Avnet MaaxBoard-RT board.
DB9.3of USB-CAN connected toGND
...
J15.
...
4 on the
...
Avnet MaaxBoard-RT board.
...
8.3.2. Software Setup
The following software setup is required:
Download the files listed in Section: "Downloadable Files" to the top of the Linux i.MX RT installation.
Install the BSP, as per the respective "Installing and activating cross development environment" document in the "Software" section on the Emcraft site.
From the top of the Linux installation, activate the Linux cross-compile environment by running:
Code Block $ . ./ACTIVATE.shInstall U-Boot to the target board.
for the IMXRT10XX-EVK boards as per Installing U-Boot to the NXP i.MX RT10XX EVK Board
for the IMXRT1170-EVK and MaaXBoard-RT boards as per https://emcraft.com/imxrt1170-evk-board/installing-uboot-to-imxrt1170-evk-board
From the top of the BSP installation, go to the Linux kernel tree and install the kernel patch, eg:
Code Block $ cd linux/ $ patch -p1 < ../../linux-flexcan.patchFrom the top of the Linux installation, go to the
projectssub-directory, and patch therootfsproject:Code Block $ cd projects/ $ patch -p1 < ../../projects-flexcan.patchOn the Linux PC intended for execution of the CANsocket test suite, ensure that the following software is installed (Emcraft used Linux PC running the
Fedora 16(3.1.0-7.fc16.i686.PAE) installation; the other Linux distributives should work too, but may require some additional steps like compilation and installation of the CAN framework kernel modules):Install
can-utilspackage on the Linux PC (commands below are for a Fedora host):Code Block $ sudo yum install can-utils ... $Install and build
can-testson the Linux PC:Code Block $ cd ~ $ git clone https://github.com/linux-can/can-tests.git $ cd can-tests $ make $ sudo DESTDIR=/usr PREFIX= make installLoad the CAN kernel modules on the Linux PC:
Code Block $ sudo modprobe can $ sudo modprobe can-raw $ sudo modprobe slcan
Connect the VSCOM USB-CAN adapter to the Linux PC and configure it as follows:
Get the VSCOM USB-CAN serial device name (in the example below it is
ttyUSB0):Code Block $ dmesg | tail [77641.738206] usbcore: registered new interface driver ftdi_sio [77641.739086] usbserial: USB Serial support registered for FTDI USB Serial Device [77641.747063] ftdi_sio 1-2:1.0: FTDI USB Serial Device converter detected [77641.747348] usb 1-2: Detected FT232R [77641.781982] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0 [78603.073189] can: controller area network core [78603.073360] NET: Registered PF_CAN protocol family [78618.877319] can: raw protocol [78632.316446] CAN device driver interface [78632.334423] slcan: serial line CAN interface driverConfigure the VSCOM USB-CAN adapter to run with a 1Mbps CAN-bus speed (the
-s8parameter inslcan_attach), enable the corresponding network interface:Code Block $ sudo slcan_attach -o -s8 /dev/ttyUSB0 attached tty /dev/ttyUSB0 to netdevice can0 $ sudo slcand -o -s8 -t hw -S 3000000 /dev/ttyUSB0 $ sudo ifconfig can0 upIf you have disconnected the VSCOM USB-CAN adapter from the Linux PC, before reconnecting it back run the following command:
Code Block $ sudo killall slcand
...
8.4. Detailed Test Plan
...
8.4.1.
| Anchor | ||||
|---|---|---|---|---|
|
Perform the following step-wise test procedure:
Go to the
projects/rootfsdirectory, build the loadable Linux image (rootfs.uImage) and copy it to the TFTP directory on the host:Code Block $ cd projects/rootfs $ makeBoot the loadable Linux image (
rootfs.uImage) to the target via TFTP and validate that it boots to the Linux shell:Code Block => run netboot ... TFTP from server 192.168.1.96; our IP address is 192.168.1.86 Filename 'imxrt/rootfs.uImage'. Load address: 0x80007fc0 Loading: ################################################################# ################################################################# ... / #
...
8.4.2.
| Anchor | ||||
|---|---|---|---|---|
|
Perform the following step-wise test procedure:
In the kernel bootstrap messages, validate that the CAN driver has been successfully installed and activated:
Code Block / # dmesg | grep -i can CAN device driver interface can: controller area network core NET: Registered PF_CAN protocol family can: raw protocol can: broadcast manager protocol can: netlink gateway - max_hops=1 / #
...
8.4.3.
| Anchor | ||||
|---|---|---|---|---|
|
Perform the following step-wise test procedure:
On the target, configure the CAN network:
Code Block / # ip link set can0 type can bitrate 1000000 / # ifconfig can0 upTest target to Linux PC transfers:
Run the capture utility on the Linux PC:
Code Block $ candump can0Send packets from the target to the host:
Code Block / # cansend can0 12345678#99.AA.BB.CC.DD.EE.FF.00 / # cansend can0 12345678#99.AA.BB.CC.DD.EE.FF.01 / # cansend can0 12345678#99.AA.BB.CC.DD.EE.FF.02 / # cansend can0 12345678#99.AA.BB.CC.DD.EE.FF.03Validate that the packets have been captured on the Linux PC:
Code Block can0 12345678 [8] 99 AA BB CC DD EE FF 00 can0 12345678 [8] 99 AA BB CC DD EE FF 01 can0 12345678 [8] 99 AA BB CC DD EE FF 02 can0 12345678 [8] 99 AA BB CC DD EE FF 03On the host, stop the capture utility by pressing
Ctrl-C:Code Block ^C $
Test Linux PC to target transfers:
Run the capture utility on the target:
Code Block / # candump can0Send packets from the Linux PC to the target:
Code Block $ cansend can0 123abcde#11.22.33.44.56.78.90.01 $ cansend can0 123abcde#11.22.33.44.56.78.90.03 $ cansend can0 123abcde#11.22.33.44.56.78.90.05 $ cansend can0 123abcde#11.22.33.44.56.78.90.07Validate that the packets have been captured on the target:
Code Block can0 123ABCDE [8] 11 22 33 44 56 78 90 01 can0 123ABCDE [8] 11 22 33 44 56 78 90 03 can0 123ABCDE [8] 11 22 33 44 56 78 90 05 can0 123ABCDE [8] 11 22 33 44 56 78 90 07On the target, stop the capture utility by pressing
Ctrl-C:Code Block ^C / #
...
8.4.4.
| Anchor | ||||
|---|---|---|---|---|
|
Perform the following step-wise test procedure:
Run the
tst-rawLinux PC to target test:On the target:
Code Block / # tst-raw -i can0On the Linux PC:
Code Block $ sudo tst-raw-sendto -i can0Observe the test data on the target, then press
Ctrl-Cand complete the test:Code Block 123 [3] 11 22 33 ^C / #
Run the
tst-rawtarget to Linux PC test:On the Linux PC:
Code Block $ sudo tst-raw -i can0On the target:
Code Block / # tst-raw-sendto -i can0Observe test data on the Linux PC, then press
Ctrl-Cand complete the test:Code Block 123 [3] 11 22 33 ^C $
Run the
tst-packetLinux PC to target test:On the target:
Code Block / # tst-packet -i can0On the Linux PC send a packet, then press
Ctrl-Cand complete the test:Code Block $ sudo tst-packet -i can0 -s ^C $Observe the test packet on the target, then press
Ctrl-Cand complete the test:Code Block 123 [2] 11 22 ^C / #
Run the
tst-packettarget to Linux PC test:On the Linux PC:
Code Block $ sudo tst-packet -i can0On the target, send a packet, then press
Ctrl-Cand complete the test:Code Block / # tst-packet -i can0 -s ^C / #Observe the test packet on the Linux PC, then press
Ctrl-Cand complete the test:Code Block 123 [2] 11 22 ^C $
Run the
tst-filtertest on the target:Code Block / # tst-filter can0 --- testcase 0 filters : can_id = 0x00000123 can_mask = 0x000007FF testcase 0 sending patterns ... ok testcase 0 rx : can_id = 0x00000123 rx = 1 rxbits = 1 testcase 0 rx : can_id = 0x40000123 rx = 2 rxbits = 17 testcase 0 rx : can_id = 0x80000123 rx = 3 rxbits = 273 testcase 0 rx : can_id = 0xC0000123 rx = 4 rxbits = 4369 testcase 0 ok --- testcase 1 filters : can_id = 0x80000123 can_mask = 0x000007FF testcase 1 sending patterns ... ok testcase 1 rx : can_id = 0x00000123 rx = 1 rxbits = 1 testcase 1 rx : can_id = 0x40000123 rx = 2 rxbits = 17 testcase 1 rx : can_id = 0x80000123 rx = 3 rxbits = 273 testcase 1 rx : can_id = 0xC0000123 rx = 4 rxbits = 4369 testcase 1 ok --- testcase 2 filters : can_id = 0x40000123 can_mask = 0x000007FF testcase 2 sending patterns ... ok testcase 2 rx : can_id = 0x00000123 rx = 1 rxbits = 1 testcase 2 rx : can_id = 0x40000123 rx = 2 rxbits = 17 testcase 2 rx : can_id = 0x80000123 rx = 3 rxbits = 273 testcase 2 rx : can_id = 0xC0000123 rx = 4 rxbits = 4369 testcase 2 ok --- <...> --- testcase 15 filters : can_id = 0xC0000123 can_mask = 0xC00007FF testcase 15 sending patterns ... ok testcase 15 rx : can_id = 0xC0000123 rx = 1 rxbits = 4096 testcase 15 ok --- testcase 16 filters : can_id = 0x00000123 can_mask = 0xDFFFFFFF testcase 16 sending patterns ... ok testcase 16 rx : can_id = 0x00000123 rx = 1 rxbits = 1 testcase 16 ok --- testcase 17 filters : can_id = 0x80000123 can_mask = 0xDFFFFFFF testcase 17 sending patterns ... ok testcase 17 rx : can_id = 0x80000123 rx = 1 rxbits = 256 testcase 17 ok --- / #Run the
tst-rcv-own-msgstest on the target:Code Block / # tst-rcv-own-msgs can0 Starting PF_CAN frame flow test. checking socket default settings ... ok. check loopback 0 recv_own_msgs 0 ... ok. check loopback 0 recv_own_msgs 1 ... ok. check loopback 1 recv_own_msgs 0 ... ok. check loopback 1 recv_own_msgs 1 ... ok. PF_CAN frame flow test was successful. / #