DESK-MX6-L/Pheripherals/CAN
History | |||
---|---|---|---|
ID# | Issue Date | Notes | |
16/07/2021 | First DESK release | ||
03/03/2022 | DESK 3.0.0 release |
Contents
Peripheral CAN[edit | edit source]
Device tree configuration[edit | edit source]
Here below an example of device tree configuration used on standard DAVE's kit for the AXEL Lite SOM:
From imx6qdl-sbcx-revb-common.dtsi
:
&can1 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_flexcan1_axel>; status = "okay"; };
From imx6qdl-axelcommon.dtsi
:
can1 { pinctrl_flexcan1_axel: flexcan1axelgrp-1 { fsl,pins = < MX6QDL_PAD_GPIO_7__FLEXCAN1_TX 0x80000000 MX6QDL_PAD_GPIO_8__FLEXCAN1_RX 0x80000000 >; }; };
Accessing the peripheral[edit | edit source]
Linux messages at boot time[edit | edit source]
... ... [ 5.119440] can: controller area network core [ 5.128422] can: raw protocol [ 5.131399] can: broadcast manager protocol [ 5.135663] can: netlink gateway - max_hops=1 ... ...
Enable the interface and check status[edit | edit source]
root@desk-mx6:~# ip link set can0 type can bitrate 500000 root@desk-mx6:~# ifconfig can0 up [ 4184.530382] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready root@desk-mx6:~# 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 39
Usage with can-utils[edit | edit source]
root@desk-mx6:~# ip link set can0 type can bitrate 500000 triple-sampling on loopback on root@desk-mx6:~# ifconfig can0 up root@desk-mx6:~# candump can0 & [1] 321 interface = can0, family = 29, type = 3, proto = 1 root@desk-mx6:~# 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
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