Simple CAN (FD) test on i.MX8QXP's MEK board

Document created by vincent.aubineau Employee on Oct 1, 2018Last modified by vincent.aubineau Employee on Apr 8, 2019
Version 4Show Document
  • View in full screen mode

One of the new feature of  the i.MX8 family is to support CAN FD. Fortunately the MEK board has a TJA1043 supporting CAN FD.

The following document show you how to do simple CAN (FD) test under Linux.

 

First of all let configure the CAN0 to be at 500kps in CAN, and 4Mbps in CAN FD:

ip link set can0 up type can bitrate 500000 sample-point 0.75 dbitrate 4000000 dsample-point 0.8 fd on

Let's do the same for CAN1:

ip link set can1 up type can bitrate 500000 sample-point 0.75 dbitrate 4000000 dsample-point 0.8 fd on

Now you can do a bridge between CAN0 and CAN1 on the board. The easiest way is to put simple wires (pin 2 to pin 2 a,d pin 7 to pin 7), normally you have to twist your wires, but as it is on your desk, you can get rid of it):

You can check the configurations of your FlexCAN:

root@imx8qxpmek:~# ip -details link show can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
link/can promiscuity 0
can <FD> state ERROR-WARNING (berr-counter tx 0 rx 0) restart-ms 0
bitrate 500000 sample-point 0.750
tq 25 prop-seg 29 phase-seg1 30 phase-seg2 20 sjw 1
flexcan: tseg1 2..64 tseg2 1..32 sjw 1..32 brp 1..1024 brp-inc 1
dbitrate 4000000 dsample-point 0.800
dtq 25 dprop-seg 3 dphase-seg1 4 dphase-seg2 2 dsjw 1
flexcan: dtseg1 1..39 dtseg2 1..8 dsjw 1..8 dbrp 1..1024 dbrp-inc 1
clock 40000000numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
root@imx8qxpmek:~# ip -details link show can1
4: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
link/can promiscuity 0
can <FD> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
bitrate 500000 sample-point 0.750
tq 25 prop-seg 29 phase-seg1 30 phase-seg2 20 sjw 1
flexcan: tseg1 2..64 tseg2 1..32 sjw 1..32 brp 1..1024 brp-inc 1
dbitrate 4000000 dsample-point 0.800
dtq 25 dprop-seg 3 dphase-seg1 4 dphase-seg2 2 dsjw 1
flexcan: dtseg1 1..39 dtseg2 1..8 dsjw 1..8 dbrp 1..1024 dbrp-inc 1
clock 40000000numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
root@imx8qxpmek:~#

Now a simple test can be to send random CAN FD messages, for that use "cangen" to send random CAN FD messages (read "cangen" documentation: https://manpages.debian.org/stretch-backports/can-utils/cangen.1.en.html ):

root@imx8qxpmek:~# cangen can0 -v -b -g 20
can1 3E6 [00]
can1 735 [20] F9 ED 40 53 AC CF 48 34 F9 ED 40 53 AC CF 48 34 F9 ED 40 53
can1 513 [20] 92 D2 E7 32 48 E6 EA 39 92 D2 E7 32 48 E6 EA 39 92 D2 E7 32
can1 03B [12] 6D 34 2F 11 52 8A 52 50 6D 34 2F 11
can1 47D [24] 72 08 88 0D E0 04 F7 09 72 08 88 0D E0 04 F7 09 72 08 88 0D E0 04 F7 09
can1 245 [00]
can1 6F6 [48] B9 82 A1 49 4E ED BA 06 B9 82 A1 49 4E ED BA 06 B9 82 A1 49 4E ED BA 06 B9 82 A1 49 4E ED BA 06 B9 82 A1 49 4E ED BA 06 B9 82 A1 49 4E ED BA 06
can1 1F4 [16] 03 5B 7C 00 DA E5 FA 03 03 5B 7C 00 DA E5 FA 03
can1 38A [48] 71 CE A3 1A C0 8A 4F 20 71 CE A3 1A C0 8A 4F 20 71 CE A3 1A C0 8A 4F 20 71 CE A3 1A C0 8A 4F 20 71 CE A3 1A C0 8A 4F 20 71 CE A3 1A C0 8A 4F 20
can1 4C9 [20] 6C 5A 98 54 DD D1 CB 09 6C 5A 98 54 DD D1 CB 09 6C 5A 98 54
can1 536 [48] 25 B8 B6 43 71 CD 54 71 25 B8 B6 43 71 CD 54 71 25 B8 B6 43 71 CD 54 71 25 B8 B6 43 71 CD 54 71 25 B8 B6 43 71 CD 54 71 25 B8 B6 43 71 CD 54 71
can1 308 [02] C3 57
can1 33E [05] 65 8C 7B 21 83
can1 3F5 [05] EA E0 07 63 EB
can1 633 [03] 39 10 18
can1 25D [32] 01 4E 65 41 E8 4D 94 6F 01 4E 65 41 E8 4D 94 6F 01 4E 65 41 E8 4D 94 6F 01 4E 65 41 E8 4D 94 6F
can1 2FB [03] A8 D8 E3
can1 0DE [04] A1 11 3F 32
can1 012 [06] 85 23 B2 07 1A 03
can1 658 [08] A0 8A 2D 67 97 79 A1 64
can1 37D [05] 1A 57 E8 4F 72
can1 70A [04] 5E 6A B8 0F
can1 3A8 [07] 65 C5 48 76 05 B6 11
can1 5D4 [07] ED 03 A6 07 CF D8 DC
can1 7DA [05] 94 18 50 09 B8
can1 7A9 [05] CC 5E 02 74 BC
can1 3FC [01] D6
can1 599 [06] EB 23 02 61 16 D9
can1 47C [06] 88 20 F2 62 86 3B
can1 30A [06] C4 98 57 61 B2 4E
can1 57E [16] B8 04 86 5B 52 EB DF 45 B8 04 86 5B 52 EB DF 45
can1 191 [05] 22 C4 BC 26 6B
can1 53B [06] 23 AA AA 00 E4 F4
can1 6EB [64] A0 64 BE 5E E7 FA 20 1D A0 64 BE 5E E7 FA 20 1D A0 64 BE 5E E7 FA 20 1D A0 64 BE 5E E7 FA 20 1D A0 64 BE 5E E7 FA 20 1D A0 64 BE 5E E7 FA 20 1D A0 64 BE 5E E7 FA 20 1D A0 64 BE 5E E7 FA 20 1D

 

You can check with a scope your CAN FD frame (here CAN High):

And you can see the first part of the frame sent @500kps and the second part @4Mbps.

If you unplug one wire, the messages will no longer be sent as no acknowlege will occurs.

 

You can also send message without flexible datarate. In our case, we'll send long frame at 500kps (no more 4Mbps transfer for end of the frame):

imx8qxpmek:~# cangen can0 -v -f -g 20
can0 6FE##0.6B.C6.BA.1A.82.2D.29.7E.6B.C6.BA.1A.82.2D.29.7E.6B.C6.BA.1A.82.2D.29.7E.6B.C6.BA.1A.82.2D.29.7E.6B.C6.BA.1A.82.2D.29.7E.6B.C6.BA.1A.82.2D.29.7E.6B.C6.BA.1A.82.2D.29.7E.6B.C6.BA.1A.82.2D.29.7E
can0 3E2##0.D4.9E.3D
can0 1DE##0.D0.D8.33.50.7E.39
can0 7CE##0.FA.68.25.74.86.E7.E1.4A.FA.68.25.74.86.E7.E1.4A.FA.68.25.74
can0 7C3##0.58.E6.F2.1E.BD.7D.F8.7F
can0 32A##0.0D.06.98.0D.08.81.5C.4E.0D.06.98.0D.08.81.5C.4E.0D.06.98.0D.08.81.5C.4E.0D.06.98.0D.08.81.5C.4E.0D.06.98.0D.08.81.5C.4E.0D.06.98.0D.08.81.5C.4E
can0 48B##0.76.48.B4.34.59.81.B9.47.76.48.B4.34.59.81.B9.47.76.48.B4.34.59.81.B9.47.76.48.B4.34.59.81.B9.47.76.48.B4.34.59.81.B9.47.76.48.B4.34.59.81.B9.47.76.48.B4.34.59.81.B9.47.76.48.B4.34.59.81.B9.47
can0 3FC##0.6E.70.F7.36.FB.82.B9.00.6E.70.F7.36.FB.82.B9.00.6E.70.F7.36.FB.82.B9.00.6E.70.F7.36.FB.82.B9.00.6E.70.F7.36.FB.82.B9.00.6E.70.F7.36.FB.82.B9.00.6E.70.F7.36.FB.82.B9.00.6E.70.F7.36.FB.82.B9.00
can0 4BE##0.7D.B0.E2.7E.A0.F0.DF.24.7D.B0.E2.7E
can0 60C##0.0E
can0 257##0.69.11.0C.4B.25.CA.16.65.69.11.0C.4B.25.CA.16.65.69.11.0C.4B.25.CA.16.65.69.11.0C.4B.25.CA.16.65.69.11.0C.4B.25.CA.16.65.69.11.0C.4B.25.CA.16.65
can0 0BA##0.AB.B1.F8
can0 0FC##0.3A.7E.FB.34
can0 452##0.2F.4D.04.26.DE.80.EA
can0 2C7##0.37.02.A4.4D.C3
can0 0B4##0.BE.39.AD.3B.73
can0 17E##0.13.66.44.6A.8A.8F.CE.7A.13.66.44.6A.8A.8F.CE.7A.13.66.44.6A

 

You can also force the CAN to only send CAN 2.0b frames (not FD, you'll have 8-byte data max frames):

imx8qxpmek:~# cangen can0 -v -g 20
can0 7FF#8F.04.3F.31.EB
can0 135#92.7C.46.5C.95.4E.6C.48
can0 0F8#E3.E4.7E.4D.92.2A.1D.69
can0 68F#C6.B7.BA.35.78.06
can0 4EC#D8.D9.86.19.40.BE.64.05
can0 09F#EE.E1.70.7D.13.C9.18.53
can0 7CE#BB.CD.FE.50.3E.B6.A4.4A
can0 3C7#04
can0 1F6#B2.E4.4B.42
can0 080#C1.81.65.41
can0 14C#0B.B4.7E.5D
can0 15A#53
can0 1CF#86.D4.ED.11.6E.BA.20.14
can0 257#82.83.39.67
can0 2C1#64.20.DF.0D.89.0E.14.55
can0 45E#50.72.44.76.55.4E.96.0F
can0 6FC#80.81
can0 046#F6
can0 1E5#6D
can0 0D2#
can0 7EB#0F.3D.29.78.42.72.60.61
can0 480#68
can0 1CE#CB.05.12.74.2D.0E.F2.14
can0 634#82.5C.88.24.31.75.AF.03
can0 71D#AE.4C
can0 144#F5.A8.17.70
can0 2A5#69.BE
can0 222#18.C6.AA.4A.0D.5A.EC.48
can0 5FA#4F.CC.4C.2A.7B.BA.31
can0 3B9#BD.B1.2F.3C.87.D5.D1
can0 583#B4.E3.C3.4E.B8.D3.22.43
2 people found this helpful

Attachments

    Outcomes