DESK-MX6UL-L/Peripherals/CAN

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes

2021/07/20

First DESK-MX6UL-L release

2022/03/16

DESK-MX6UL-L 3.0.0 release

2023/05/04

DESK-MX6UL-L 4.0.0 release
2024/07/21 DESK-MX6UL-L 4.2.x release


Peripheral CAN[edit | edit source]

200px-Emblem-important.svg.png

The CAN peripheral is not available on AXEL ULite EVK. This peripheral is available on the i.MX6UL standard product RIALTO SBC

Device tree configuration[edit | edit source]

RIALTO SBC[edit | edit source]

Here below is an example of device tree configuration used on standard DAVE's kit for the RIALTO SBC:

From imx6ul-lynx-som0022-cb0090.dts:

&can1 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_flexcan1>;
	status = "okay";
};

From imx6ul-lynx-som0022.dtsi:

...
&iomuxc {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_hog_gpios>;

	imx6ul-lynx {
...
...
		pinctrl_flexcan1: flexcan1grp{
			fsl,pins = <
				MX6UL_PAD_LCD_DATA09__FLEXCAN1_RX	0x1b020
				MX6UL_PAD_LCD_DATA08__FLEXCAN1_TX	0x1b020
			>;
		};
...

Accessing the peripheral RIALTO SBC[edit | edit source]

Linux messages at boot time[edit | edit source]

...
...
[    3.047454] can: controller area network core
[    3.057221] can: raw protocol
[    3.069417] can: broadcast manager protocol
[    3.073846] can: netlink gateway - max_hops=1
...
...

Enable the interface and check status[edit | edit source]

root@desk-mx6ul-rialto:~# ip link set can0 type can bitrate 500000
root@desk-mx6ul-rialto:~# ifconfig can0 up
root@desk-mx6ul-rialto:~# ifconfig can0
can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 31

root@desk-mx6ul-rialto:~#

Usage with can-utils[edit | edit source]

root@desk-mx6ul-rialto:~# ip link set can0 type can bitrate 500000 triple-sampling on loopback on
root@desk-mx6ul-rialto:~# ifconfig can0 up
root@desk-mx6ul-rialto:~# candump can0 &
[1] 275
root@desk-mx6ul-rialto:~# interface = can0, family = 29, type = 3, proto = 1

root@desk-mx6ul-rialto:~# cansend can0 -i 0x7ff 00 01 02 03 04 05 06 07
interface = can0, family = 29, type = 3, proto = 1
<0x7ff> [8] 00 01 02 03 04 05 06 07
<0x7ff> [8] 00 01 02 03 04 05 06 07
root@desk-mx6ul-rialto:~#

Additional information[edit | edit source]

Each CAN port appears like a networking interface in the form canX where X is the port number.

Information about programming the CAN socket interface is given in the kernel tree under Documentation/networking/can.rst