2011-02-17 23:55:48     SocketCAN problem - ERRORFRAME

Document created by Aaronwu Employee on Aug 26, 2013
Version 1Show Document
  • View in full screen mode

2011-02-17 23:55:48     SocketCAN problem - ERRORFRAME

Jay Ku (UNITED STATES)

Message: 98236   

 

Probably this belongs on a socketcan list, but I thought I'd start here.

 

I'm using socketcan on a custom BF537 board with 2010R1 (2.6.34.7-ADI-2010R1-pre-svn9156) (using the built-in 537 CAN peripheral).  My application has been working fine (receiving all the packets I expect), but today I happened to type ifconfig and I noticed fully 1/2 of the packets being received are error frames.  This was surprising because the Kvaser CAN analyzer I have on the bus isn't reporting any errors at all.  My packet rate is pretty low - around 25 frames/s on a 500Kbit bus.

 

Exploring a little more, if I look at the bus transcript from my CAN analyzer I see something like:

 

0    00000020         8  1B  00  07  98  80  09  88  80     515.903420 R

0    00000020         8  1B  08  0B  78  80  09  78  80     515.903610 R

0    00000020         8  1B  10  07  88  80  08  78  80     515.903870 R

0    00000020         8  1B  14  07  C8  81  07  58  80     515.904120 R

0    00000020         8  1B  04  0B  98  80  08  88  80     515.904380 R

0    00000020         8  1B  0C  07  98  80  09  58  80     515.904570 R

0    00000060         6  6B  2B  00  00  00  00             515.911100 R

0    00000020         8  1F  00  08  98  80  09  88  80     516.153400 R

0    00000020         8  1F  08  0B  78  80  09  78  80     516.153660 R

0    00000020         8  1F  10  07  78  80  08  78  80     516.153910 R

0    00000020         8  1F  14  07  D8  81  07  58  80     516.154170 R

0    00000020         8  1F  04  0A  98  80  07  88  80     516.154360 R

0    00000020         8  1F  0C  07  98  80  09  68  80     516.154620 R

 

But if I run candump can0 -m 0 -e 0xffffffff on my host I get:

 

     can0   20  [8] 1B 00 07 98 80 09 88 80

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0   20  [8] 1B 08 0B 78 80 09 78 80

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0   20  [8] 1B 10 07 88 80 08 78 80

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0   20  [8] 1B 14 07 C8 81 07 58 80

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0   20  [8] 1B 04 0B 98 80 08 88 80

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0   20  [8] 1B 0C 07 98 80 09 58 80

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0   60  [6] 6B 2B 00 00 00 00

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0   20  [8] 1F 00 08 98 80 09 88 80

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0   20  [8] 1F 08 0B 78 80 09 78 80

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0   20  [8] 1F 10 07 78 80 08 78 80

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0   20  [8] 1F 14 07 D8 81 07 58 80

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0   20  [8] 1F 04 0A 98 80 07 88 80

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0   20  [8] 1F 0C 07 98 80 09 68 80

 

 

I've no idea where those error frames are coming from.  My bus is properly terminated (at both ends) and is very short in this case - just three nodes (+ the analyzer), separated from one another by ~1ft of twisted-pair.  The only configuration I do is when I start up the interface in /etc/rc:

 

ip link set can0 type can bitrate 500000

ifconfig can0 up

 

I assume the detailed bit timing is being set to some default values by the driver... I wonder if that could be my problem.

 

Has anyone else seen this type of problem?

QuoteReplyEditDelete

 

 

2011-02-21 12:19:51     Re: SocketCAN problem - ERRORFRAME

Jay Ku (UNITED STATES)

Message: 98302   

 

Small update on this.  Turns out I get the ERRORFRAME frame BEFORE each good frame.  One of the SocketCAN developers seems to think it's an ADI-specific problem.  Can someone with a 537 eval board try this out and see if they're seeing the same problem?

QuoteReplyEditDelete

 

 

2011-02-21 12:24:53     Re: SocketCAN problem - ERRORFRAME

Mike Frysinger (UNITED STATES)

Message: 98303   

 

i wonder if you took the bf537-stamp, installed the can loopback between the two ports on it, and then did some simple packet transmissions if you saw the same thing

 

could you post some code that does a simple socket creation + transmit that shows the same issue ?

QuoteReplyEditDelete

 

 

2011-02-21 13:04:05     Re: SocketCAN problem - ERRORFRAME

Jay Ku (UNITED STATES)

Message: 98304   

 

This problem doesn't depend on my code at all... I'm just using the candump utility that builds with the distro.

 

Sure I can dig out my eval board and try it on there (may take some time to get the cabling working since I've never used CAN on it), but maybe someone already has one of these set up on their bench and could see if this is happening in a few minutes.

QuoteReplyEditDelete

 

 

2011-02-21 13:18:01     Re: SocketCAN problem - ERRORFRAME

Mike Frysinger (UNITED STATES)

Message: 98307   

 

i'm not saying the problem is your code.  i'm saying i'd like a series of steps that shows the problem on your side which i can then also do on my side.  not much point in me slapping together some code only to have it work on my side.

 

so if you can show the issue using userspace utilities too, that's fine.

 

all bf537-stamp's should ship with a small loopback can connector ...

QuoteReplyEditDelete

 

 

2011-03-02 18:20:19     Re: SocketCAN problem - ERRORFRAME

Jay Ku (UNITED STATES)

Message: 98602   

 

My previous posts were pretty clear about how this could be repeated using just the utilites that are part of the uClinux distro (no slapping together of code needed), but I spent the time to demonstrate the problem on an ADI board using the latest code anyway.

 

I just loaded the latest 2010R1-RC4 onto my B537 STAMP board (v2.1) and it shows exactly the same problem I'm seeing on my custom BF537 board.  If I do candump can0 -m 0 -e 0xffffffff and send two '0 1 2 3' frames to CAN ID 0 (I'm generating these using my Kvaser Leaf CAN interface as I only have one BF537 STAMP board) I see the following on my board:

 

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0    0  [4] 00 01 02 03

  can0  20000004  [8] 00 01 00 00 00 00 00 00   ERRORFRAME

  can0    0  [4] 00 01 02 03

 

That's an errorframe generated before each valid frame.  ifconfig similary shows that half the receive frames are error frames.

 

I'll open a tracker for this issue.

QuoteReplyEditDelete

 

 

2011-03-02 18:23:05     Re: SocketCAN problem - ERRORFRAME

Jay Ku (UNITED STATES)

Message: 98603   

 

Typo in my previous message... I'm actually running 2010R1-RC5 - it's the latest version off the download site.

QuoteReplyEditDelete

 

 

2011-03-02 21:48:10     Re: SocketCAN problem - ERRORFRAME

Mike Frysinger (UNITED STATES)

Message: 98609   

 

you didnt show any commands for transmitting packets.  you only showed sniffing the bus (candump).  sniffing the bus isnt useful if no packets are being sent out.

QuoteReplyEditDelete

 

 

2011-03-02 23:06:53     Re: SocketCAN problem - ERRORFRAME

Jay Ku (UNITED STATES)

Message: 98612   

 

I think you guys can figure out how to generate packets (using another board or whatever)... I listed the contents/addressses of the packets.  It doesn't seem to matter what's in the packets - this error happens on every one.  I'm sure cangen will work just fine.

 

- Jay

QuoteReplyEditDelete

 

 

2011-03-02 23:19:56     Re: SocketCAN problem - ERRORFRAME

Mike Frysinger (UNITED STATES)

Message: 98613   

 

someone is going to half to, but ive never done socketcan before.  without a test util to run on my own board to exhibit the issue, i'll just let someone else on our team get to it.

QuoteReplyEditDelete

 

 

2011-03-03 11:52:36     Re: SocketCAN problem - ERRORFRAME

Jay Ku (UNITED STATES)

Message: 98629   

 

Just now I hooked two boards together (not both STAMPS but both BF537-based) and ran 'cangen can0' on one board and 'candump can0 -m 0 -e 0xffffffff' on the other and I see the errorframe before each correct frame.  However, if I run cangen and candump on the same board, candump prints out the frames cangen is generating but there are no errors.   So it seems it takes two boards to generate the error (and you have to be explicitly looking for errors like with the -e flag on candump - just 'candump can0' by default doesn't seem to print errors).

QuoteReplyEditDelete

 

 

2011-03-21 23:35:26     Re: SocketCAN problem - ERRORFRAME

steven miao (CHINA)

Message: 99111   

 

Hi Jay,

I tested the socketcan with 2 bf537-stamp board, ran cangen on one board and

candump on the other board, but didn't see the error frame messages. Can you check the hardware

connection of you can line?

 

Linux version 2.6.34.7-ADI-2010R1-svn9517

 

root:/> ip link set can0 type can bitrate 500000

bfin_can bfin_can.0: setting CLOCK=0x0031 TIMING=0x0002

root:/> ifconfig can0 up 

 

 

root:/> candump can0 -m 0 -e 0xffffffff

  can0  567  [6] 69 98 3C 64 73 48

  can0  451  [8] 4A 94 E8 2A EC 58 55 62

  can0  729  [8] BA 58 1B 3D AB D7 7E 50

  can0  1F2  [8] E3 A9 E2 79 46 E1 45 75

  can0   7C  [2] 54 08

  can0  31B  [8] E7 CD 90 11 8D 43 EF 66

  can0  776  [8] 2E F9 9C 10 63 72 ED 0D

  can0  233  [8] C9 C4 A7 41 9A 07 68 6B

  can0  366  [2] 0D 50

  can0  231  [8] A3 30 71 25 5A D9 BB 62

  can0  125  [8] 05 B1 3A 33 17 A3 1D 72

  can0   58  [8] 5E 84 63 67 D4 A8 A2 75

  can0  5AB  [2] CD D0

  can0  69B  [4] 54 24 F3 71

  can0  40E  [2] 74 F8

  can0  521  [8] DC 8D 7B 73 87 F0 EA 6C

  can0  270  [8] 3E C8 06 30 A1 D4 4F 61

  can0  241  [1] FC

  can0  23E  [1] 7E

  can0  1EA  [8] 6B D3 EA 51 96 77 51 2D

  can0  78F  [8] 5C 58 55 38 2A 4E A6 70

  can0  2EC  [0]

  can0  232  [8] 3C 8D 6D 7A 54 8F 58 4B

  can0  1EC  [8] DB 7F 43 38 5C A4 44 76

  can0  102  [8] FE 78 94 57 43 BB 9A 74

  can0   FB  [8] AA DE A1 79 3A C3 C6 75

  can0  5FB  [8] D1 ED 0E 52 E6 3F 4A 37

  can0    5  [8] 7C B7 9B 64 94 C7 5A 27

  can0  575  [8] BE 15 01 18 61 A8 5B 23

  can0  489  [8] 5C AF B5 15 BB 26 12 74

  can0  6A8  [8] 0F B6 6A 3F 95 40 57 61

  can0  7B1  [8] F1 E4 9B 57 B3 50 0C 31

  can0  605  [8] F7 0B A7 25 00 BF BA 1D

  can0  4E9  [1] 3A

  can0  7CA  [8] CB 4A 01 15 D0 7F 5E 5F

  can0  148  [7] 64 47 B9 06 BD 96 C2

  can0  21F  [3] 1E 3F 1E

  can0  71C  [8] 64 C5 D9 51 C5 FD 3E 61

  can0  314  [3] 5A 3E 96

  can0  15E  [8] 79 D3 0F 3B 63 2F EB 68

  can0  13B  [0]

  can0  211  [8] 09 11 EA 71 DC 59 0F 10

  can0   AA  [4] AC D9 6D 6F

  can0  61B  [0]

  can0  633  [8] E3 0E DE 74 50 C5 EB 68

  can0  648  [7] 15 C3 2A 4A 5C 01 EE

  can0  7BB  [8] 22 84 F1 43 19 01 EF 60

  can0  4BA  [8] 7D 30 DA 49 F5 A5 55 70

  can0  70B  [1] 1A

  can0  77F  [3] F8 5A C7

Attachments

    Outcomes