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

From DAVE Developer's Wiki
Jump to: navigation, search
Line 1: Line 1:
[[File:TBD.png|thumb|center|200px|Work in progress]]
 
 
 
<section begin=History/>
 
<section begin=History/>
 
{| style="border-collapse:collapse; "
 
{| style="border-collapse:collapse; "
Line 18: Line 16:
  
 
==Peripheral CAN ==
 
==Peripheral CAN ==
 +
{{ImportantMessage|text=The CAN peripheral is not available on [[AXEL_ULite_SOM/AXEL_ULite_Evaluation_Kit | AXEL ULite EVK]]. This peripheral is available on the i.MX6UL standard product [[SBC_Lynx_SBC | SBCLynx]]}}
  
 
=== Device tree configuration ===
 
=== Device tree configuration ===
 
Here below an example of device tree configuration used on standard DAVE's kit for the [[AXEL ULite SOM]]:
 
Here below an example of device tree configuration used on standard DAVE's kit for the [[AXEL ULite SOM]]:
  
From <code>imx6ul-lynx-som0013-cb00XX.dts</code>:
+
From <code>imx6ul-lynx-som0013-cb002f.dts</code>:
  
 
<pre>
 
<pre>
Line 57: Line 56:
 
...
 
...
 
...
 
...
[    2.717142] flexcan 2090000.flexcan: 2090000.flexcan supply xceiver not found, using dummy regulator
+
[    2.722873] flexcan 2090000.flexcan: 2090000.flexcan supply xceiver not found, using dummy regulator
[    2.728107] flexcan 2090000.flexcan: device registered (reg_base=a099c000, irq=24)
+
[    2.734031] flexcan 2090000.flexcan: device registered (reg_base=a099c000, irq=24)
 
...
 
...
 
...
 
...
Line 69: Line 68:
 
====Enable the interface and check status====
 
====Enable the interface and check status====
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# ip link set can0 type can bitrate 500000
+
root@desk-mx6ul-lynx:~# ip link set can0 type can bitrate 500000
root@desk-mx6ul-axelulite:~# ifconfig can0 up
+
root@desk-mx6ul-lynx:~# ifconfig can0 up
root@desk-mx6ul-axelulite:~# ifconfig can0
+
root@desk-mx6ul-lynx:~# ifconfig can0
 
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
 
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
+
           UP NOARP  MTU:16  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
+
           RX packets:2 errors:0 dropped:0 overruns:0 frame:0
 
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 
           collisions:0 txqueuelen:10
 
           collisions:0 txqueuelen:10
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
+
           RX bytes:16 (16.0 B)  TX bytes:0 (0.0 B)
 
           Interrupt:24
 
           Interrupt:24
  
root@desk-mx6ul-axelulite:~#
+
root@desk-mx6ul-lynx:~#
 
</pre>
 
</pre>
  
 
==== Usage with [https://github.com/linux-can/can-utils can-utils] ====
 
==== Usage with [https://github.com/linux-can/can-utils can-utils] ====
 
''TBD: reference verso eventuali informazioni sul web''
 
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# ip link set can0 type can bitrate 500000 triple-sampling on
+
root@desk-mx6ul-lynx:~# ip link set can0 type can bitrate 500000 triple-sampling on
root@desk-mx6ul-axelulite:~# ifconfig can0 up
+
root@desk-mx6ul-lynx:~# ifconfig can0 up
root@desk-mx6ul-axelulite:~# cansend can0 128#1122334455667788
+
root@desk-mx6ul-lynx:~# cansend can0 128#1122334455667788
root@desk-mx6ul-axelulite:~# candump can0
+
interface = can0, family = 29, type = 3, proto = 1
 +
root@desk-mx6ul-lynx:~# candump can0
 
   can0  128  [8]  11 22 33 44 55 66 77 88
 
   can0  128  [8]  11 22 33 44 55 66 77 88
root@desk-mx6ul-axelulite:~#  
+
root@desk-mx6ul-lynx:~#
 
</pre>
 
</pre>
  

Revision as of 10:09, 16 July 2021

History
Version Issue Date Notes
1.0.0 Apr 2021 First DESK 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 SBCLynx

Device tree configuration[edit | edit source]

Here below an example of device tree configuration used on standard DAVE's kit for the AXEL ULite SOM:

From imx6ul-lynx-som0013-cb002f.dts:

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

From imx6ul-lynx-som0013.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[edit | edit source]

Linux messages at boot time[edit | edit source]

...
...
[    2.722873] flexcan 2090000.flexcan: 2090000.flexcan supply xceiver not found, using dummy regulator
[    2.734031] flexcan 2090000.flexcan: device registered (reg_base=a099c000, irq=24)
...
...
[    5.067979] can: controller area network core (rev 20170425 abi 9)
[    5.079006] can: raw protocol (rev 20170425)
[    5.083391] can: broadcast manager protocol (rev 20170425 t)
[    5.089108] can: netlink gateway (rev 20170425) max_hops=1

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

root@desk-mx6ul-lynx:~# ip link set can0 type can bitrate 500000
root@desk-mx6ul-lynx:~# ifconfig can0 up
root@desk-mx6ul-lynx:~# ifconfig can0
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP NOARP  MTU:16  Metric:1
          RX packets:2 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:16 (16.0 B)  TX bytes:0 (0.0 B)
          Interrupt:24

root@desk-mx6ul-lynx:~#

Usage with can-utils[edit | edit source]

root@desk-mx6ul-lynx:~# ip link set can0 type can bitrate 500000 triple-sampling on
root@desk-mx6ul-lynx:~# ifconfig can0 up
root@desk-mx6ul-lynx:~# cansend can0 128#1122334455667788
interface = can0, family = 29, type = 3, proto = 1
root@desk-mx6ul-lynx:~# candump can0
  can0  128   [8]  11 22 33 44 55 66 77 88
root@desk-mx6ul-lynx:~#

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