Send and receive CAN frames on i.MX6 Sabre Lite Board?

cancel
Showing results for 
Search instead for 
Did you mean: 

Send and receive CAN frames on i.MX6 Sabre Lite Board?

16,648 Views
Contributor III

Hello,

I am using a Freescale iMX6 Sabre Lite, for which I tried to compile an image with the LTIB. Since I couldn't install it, I tried using this image on my board.

I seem to be able to configure my can0 interface with the command:

root@freescale ~$ ip link set can0 up type can bitrate 500000
root@freescale ~$ ip -details -statistics link show can0
2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
    link/can
    can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
    bitrate 500000 sample-point 0.866
    tq 133 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1
    flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1
    clock 30000000
    re-started bus-errors arbit-lost error-warn error-pass bus-off
    0          0          0          0          0          0        
    RX: bytes  packets  errors  dropped overrun mcast  
    0          0        0       0       0       0     
    TX: bytes  packets  errors  dropped carrier collsns
    0          0        0       0       0       0   

But then, when I tried to send frames to another computer which is using this USB/CAN adapter, the frames are not received. I tried with both this kind of C program, and this command:

root@freescale ~$ while true; do cantest can0 123#12345678

So now I am wondering if this is proper way to configure my can0 interface and send frames on it. Since I am really new to both embedded devices and CAN communication, I have absolutely no clue of what could or should be done. If this method isn't the appropriate one, what would be the proper way to work with CAN?

Any help would be greatly appreciated.

Labels (2)
0 Kudos
7 Replies

99 Views
Contributor III

Here is what I finally did to get the CAN working on my board. I installed a Yocto image, build following this guide, and adding libsocketcan and canutils packages (as explained in the comments). With this the code shown in the SocketCAN wikipedia page is working perfectly fine.

Thanks for your time and help.

0 Kudos

99 Views
Contributor I

Thank you for the hint. Meanwhile I could also run the CAN-bus, after uprading the u-boot and installing following image: http://boundarydevices.com/freescale-ubuntu-image-with-4-0-0-kernel/

I also added libsocketcan and canutils to test the interface. Now it seems working correctly.

Thanks and best regards.

0 Kudos

99 Views
Contributor I

Dear All,

I do have the same problem as jcpep. I can not send or receive CAN bus data on the SABRE Lite board.

Let me give you some information about our system. A colleague of mine did buy a "SABRE Lite" board from boundarydevices.com.  We installed one of the available builds, which was offered by boundarydevices. Unfortunately not every available build was bootable, after we have created an SD-Card as described on the corresponding web page. To cut a long story short, my colleague did find a linaro Ubuntu image, which we could install with this USB-Image-tool. (Side note: I also tried to install the Freescale image with this tool, but after creating the SD card the system didn't not boot)

Nevertheless the linaro image boots properly and I can log into the system. On the following you can see the output of

$ cat /proc/version

Linux version 3.0.15-01386-g5c661b1 (ericn@ericsony) (gcc version 4.4.4 (4.4.4_09.06.2010) ) #64 SMP PREEMPT Tue Jun 26 11:16:43 MST 2012

I additionally installed libsocketcan and canutils:

http://www.pengutronix.de/software/libsocketcan/download/libsocketcan-0.0.8.tar.bz2

http://www.pengutronix.de/software/socket-can/download/canutils/v4.0/canutils-4.0.6.tar.bz2

I compiled the sources and everything looks fine. I can theoretically start and configure the can0 interface. On the following you can see the commands and the output on the terminal:

$ sudo canconfig can0 bitrate 500000

   can0 bitrate: 500000, sample-point: 0.866

$ sudo ifconfig can0 up

If I check the interface with ifconfig, I get an output like this:

linaro@linaro-ubuntu-desktop /$ ifconfig                                                     

can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-0

          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:142 

From my point of view the hardware seems to be configured properly. At least I can not see any error message. Now I tried to test the CAN interface. But unfortunately it didn't work. I connected the board to a PC on which the tool CANalyzer is running. Than I did try to send some data on the CAN bus, but nothing was send.

$ sudo cansend can0 -i0x100 11 22 33 44

interface = can0, family = 29, type = 3, proto = 1

No data could be send. CANalyzer itself works properly, which I did check by connecting another device to it. Also the bitrates are set correctly.


I tried to send the data a couple of times, but nothing changed. When I check the ip statistics I get following output:


$ ip -det -stat link show can0

2: can0: <NO-CARRIER,NOARP,UP,ECHO> mtu 16 qdisc pfifo_fast state DOWN qlen 10

    link/can

    can state BUS-OFF (berr-counter tx 0 rx 0) restart-ms 0

    bitrate 50000 sample-point 0.866

    tq 1333 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1

    flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1

    clock 30000000

    re-started bus-errors arbit-lost error-warn error-pass bus-off

    0               0               0               8               7               7        

    RX: bytes  packets  errors  dropped overrun mcast  

    128        16       0       0       0       0     

    TX: bytes  packets  errors  dropped carrier collsns

    20         0        0       0       0       0  

There are two interesting observations. Every time when  I send some data the bus-off flag is incremented. Than I have to restart the can0 device. The second thing is, that the RX bytes are always increased by 8.

I also tried to send data on the can0 interface, when there was no device connected on the CAN bus interface of the SABRE Lite board. The behavior was the same. The bus-off flag was incremented and also the RX bytes increased by 8. I am still wondering, why there are 8 bytes at RX, although there was no device connected.

I also tried to read data on the can0 interface. But unfortunately also nothing happened. 

$ sudo canecho can0 -v

interface-in = can0, interface-out = can0, family = 29, type = 3, proto = 1

$ sudo candump can0

interface = can0, family = 29, type = 3, proto = 1

Thank you in advance for your efforts.

Bye Oezguer


0 Kudos

99 Views
NXP Employee
NXP Employee

Hi, check this https://community.freescale.com/docs/DOC-1437

and this one: https://community.freescale.com/thread/300921

Do you see the signals on the oscilloscope?

There are chances you need a patch as mentioned on the second thread.

0 Kudos

99 Views
Contributor IV

you cant catch up the frame in scope.better i would suggest you to use some can analyzer to see the signal.

i could able to see the data in analyzer .

0 Kudos

99 Views
NXP Employee
NXP Employee

yes, but he can't see anything on this tool. So it is good just to double check if there is any signal activity at all with a scope.

0 Kudos

99 Views
Contributor IV

i tried with SocketCAN - Wikipedia, the free encyclopedia this link

and compiled the same code .i run this code on my board. it is sending the frames on can bus.

find the below terminal msg one for ref and for every tranmission value and packets will be changed.there is no error and etc..

hope..this answer would solve your query..

root@freescale ~$ cat /proc/net/dev

Inter-|   Receive                                                |  Transmit

face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed

  can0:       0       0    0    0    0     0          0         0        5       1    0    0    0     0       0          0

root@freescale ~$ cd /usr/bin/

root@freescale /usr/bin$ ./can_eclipse

can0 at index 3

Wrote 16 bytes

root@freescale /usr/bin$ cat /proc/net/dev

Inter-|   Receive                                                |  Transmit

face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed  

can0:       0       0    0    0    0     0          0         0       10       2    0    0    0     0       0          0

root@freescale /usr/bin$ ./can_eclipse

can0 at index 3

Wrote 16 bytes

root@freescale /usr/bin$ cat /proc/net/dev

Inter-|   Receive                                                |  Transmit

face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed

  can0:       0       0    0    0    0     0          0         0       15       3    0    0    0     0       0          0

root@freescale /usr/bin$ ./can_eclipse

can0 at index 3

Wrote 16 bytes

root@freescale /usr/bin$ cat /proc/net/dev

Inter-|   Receive                                                |  Transmit

face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed

  can0:       0       0    0    0    0     0          0         0       20       4    0    0    0     0       0          0

root@freescale /usr/bin$


0 Kudos