Difference between revisions of "DESK-MX6-L/Peripherals/CAN"

From DAVE Developer's Wiki
Jump to: navigation, search
m (U0007 moved page DESK-MX6-L/Pheripherals/CAN to DESK-MX6-L/Peripherals/CAN without leaving a redirect)
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<section begin="History" />
+
<section begin=History/>
 
{| style="border-collapse:collapse; "
 
{| style="border-collapse:collapse; "
! colspan="4" style="width:100%; text-align:left" ; border-bottom:solid 2px #ededed" |History
+
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
 
|-  
 
|-  
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white" |Issue Date
+
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Version
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white" |Notes
+
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Issue Date
 +
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Notes
 
|-
 
|-
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |{{oldid|14105|2021/07/16}}
+
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|1.0.0
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |First DESK-MX6-L release
+
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|Oct 2020
|-
+
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|First DESK release
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |{{oldid|16995|2022/03/03}}
 
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |DESK-MX6-L 3.0.0 release
 
|-
 
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |2023/04/11
 
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |DESK-MX6-L 4.0.0 release
 
 
|-
 
|-
 
|}
 
|}
<section end="History" />
+
<section end=History/>
<section begin="Body" />
+
<section begin=Body/>
  
 
==Peripheral CAN ==
 
==Peripheral CAN ==
Line 53: Line 49:
 
...
 
...
 
...
 
...
[    4.455222] can: controller area network core
+
[    2.354147] flexcan 2090000.flexcan: 2090000.flexcan supply xceiver not found, using dummy regulator
[    4.464472] can: raw protocol
+
[    2.363991] flexcan 2090000.flexcan: device registered (reg_base=c0ad0000, irq=34)
[    4.467614] can: broadcast manager protocol
 
[    4.471816] can: netlink gateway - max_hops=1
 
 
...
 
...
 
...
 
...
 +
[    4.731593] can: controller area network core (rev 20170425 abi 9)
 +
[    4.742342] can: raw protocol (rev 20170425)
 +
[    4.746641] can: broadcast manager protocol (rev 20170425 t)
 +
[    4.752317] can: netlink gateway (rev 20170425) max_hops=1
 
</pre>
 
</pre>
  
Line 65: Line 63:
 
root@desk-mx6:~# ip link set can0 type can bitrate 500000
 
root@desk-mx6:~# ip link set can0 type can bitrate 500000
 
root@desk-mx6:~# ifconfig can0 up
 
root@desk-mx6:~# ifconfig can0 up
[  839.886499] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
 
 
root@desk-mx6:~# ifconfig can0
 
root@desk-mx6:~# ifconfig can0
can0: flags=193<UP,RUNNING,NOARP> mtu 16
+
can0     Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10 (UNSPEC)
+
          UP RUNNING NOARP MTU:16 Metric:1
        RX packets 0 bytes 0 (0.0 B)
+
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
        RX errors 0 dropped 0 overruns 0 frame 0
+
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
        TX packets 0 bytes 0 (0.0 B)
+
          collisions:0 txqueuelen:10
        TX errors 0 dropped 0 overruns 0  carrier 0  collisions 0
+
          RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
        device interrupt 39
+
          Interrupt:31
 +
 
 +
root@desk-mx6:~#
 
</pre>
 
</pre>
  
==== Usage with [https://public.pengutronix.de/software/socket-can/canutils/v4.0/ can-utils] ====
+
==== Usage with [https://github.com/linux-can/can-utils can-utils] ====
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6:~# ip link set can0 type can bitrate 500000 triple-sampling on loopback on                                                                                                                         
+
root@desk-mx6:~# ip link set can0 type can bitrate 500000 triple-sampling on
root@desk-mx6:~# ifconfig can0 up                                                                                                                                                                        
+
root@desk-mx6:~# ifconfig can0 up
root@desk-mx6:~# candump can0 &                                                                                                                                                                         
+
root@desk-mx6:~# cansend can0 01a#11223344AABBCCDD
[1] 321
+
root@desk-mx6:~# candump can0
interface = can0, family = 29, type = 3, proto = 1
 
root@desk-mx6:~# cansend can0 7ff#0001020304050607
 
  can0  7FF  [8]  00 01 02 03 04 05 06 07
 
  can0 7FF  [8]  00 01 02 03 04 05 06 07
 
 
</pre>
 
</pre>
  
Line 92: Line 87:
 
Each CAN port appears like a networking interface in the form <code>canX</code> where <b><i>X</i></b> is the port number.  
 
Each CAN port appears like a networking interface in the form <code>canX</code> where <b><i>X</i></b> is the port number.  
  
Information about programming the CAN socket interface is given in the kernel tree under ''Documentation/networking/can.rst''
+
Information about programming the CAN socket interface is given in the kernel tree under ''Documentation/networking/can.txt''
<section end="Body" />
+
<section end=Body/>
 +
 
 
----
 
----
  
 
[[Category:AXEL Lite]]
 
[[Category:AXEL Lite]]

Revision as of 13:49, 14 July 2021

History
Version Issue Date Notes
1.0.0 Oct 2020 First DESK release


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]

...
...
[    2.354147] flexcan 2090000.flexcan: 2090000.flexcan supply xceiver not found, using dummy regulator
[    2.363991] flexcan 2090000.flexcan: device registered (reg_base=c0ad0000, irq=34)
...
...
[    4.731593] can: controller area network core (rev 20170425 abi 9)
[    4.742342] can: raw protocol (rev 20170425)
[    4.746641] can: broadcast manager protocol (rev 20170425 t)
[    4.752317] can: netlink gateway (rev 20170425) 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
root@desk-mx6:~# ifconfig can0
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:31

root@desk-mx6:~#

Usage with can-utils[edit | edit source]

root@desk-mx6:~# ip link set can0 type can bitrate 500000 triple-sampling on
root@desk-mx6:~# ifconfig can0 up
root@desk-mx6:~# cansend can0 01a#11223344AABBCCDD
root@desk-mx6:~# candump can0

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.txt