How to make can0 work

846 views
Skip to first unread message

klim...@gmail.com

unread,
May 19, 2020, 11:02:05 AM5/19/20
to BeagleBoard

I tried to do as indicated in this instruction, but it is outdated and does not produce results on new linux kernels. What I have to do to make the can interface work?


Board: custom board am3359 (almost like beaglebone black)

Target: linux kernel 4.14 , debian 9.9

Target: linux kernel 5.6.4 , debian 10 - same result


Problem: Can-bus working just listen-only-mode


listen-only mode is ok, messages comes:

1
2
3
4
5
6
7
sudo ifconfig can0 down
sudo ip link set can0 type can bitrate 125000 listen-only on
sudo ifconfig can0 up
candump -cae can0,0:0,#FFFFFFFF
  can0  1FE4F1DC   [8]  01 64 00 00 00 00 00 00   '.d......'
  can0  1FE4F1DC   [8]  01 64 00 00 00 00 00 00   '.d......'
  can0  1FE4F1DC   [8]  01 64 00 00 00 00 00 00   '.d......'

normal mode bus crashes:

1
2
3
4
5
6
sudo ip link set can0 type can bitrate 125000
sudo ifconfig can0 up
[13210.377469] c_can_platform 481cc000.can can0: setting BTR=1c0b BRPE=0000
[13210.391464] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
cansend can0 123#DEADBEAF
[13220.749607] c_can_platform 481cc000.can can0: bus-off

Gwen Stouthuysen

unread,
May 20, 2020, 3:54:44 AM5/20/20
to beagl...@googlegroups.com
I have the impression that your network is set up for J1939 or CANOpen (CAN 2.0B)

when you send a message to a short address (CAN 2.0A) it doesn't get acknowledged, and this might crash your bus, as the BB will try to send it till the message is acknowledged..
Try to send a message to  a 29bit address, or add a second can interface that will acknowledge your messages. (CAN1 on the BB).

I'm a bit stuck on moving over to J1939, as that requires at least kernel 5.4, which results in boot issues due the overlay approach as applied in the Beaglebone OS
You can stop this boot failure, but then I failed to have my network coming up, which was another issue. (I had to work through the debug port)

If you have some advancements in that domain? I am bit time constraint to solve it in the near future.
I hope the next release will have the latest kernel.

Prepare to learn a lot about working with micro controllers and OS environments when working in the CAN domain.

Regards,

Gwen


Op di 19 mei 2020 om 17:02 schreef <klim...@gmail.com>:
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/9673987a-f2a0-4a5f-8b48-d34a2aae61d9%40googlegroups.com.

Robert Nelson

unread,
May 20, 2020, 9:33:53 AM5/20/20
to Beagle Board, Gwen Stouthuysen
On Wed, May 20, 2020 at 2:54 AM Gwen Stouthuysen <gwen.sto...@gmail.com> wrote:
I have the impression that your network is set up for J1939 or CANOpen (CAN 2.0B)

when you send a message to a short address (CAN 2.0A) it doesn't get acknowledged, and this might crash your bus, as the BB will try to send it till the message is acknowledged..
Try to send a message to  a 29bit address, or add a second can interface that will acknowledge your messages. (CAN1 on the BB).

I'm a bit stuck on moving over to J1939, as that requires at least kernel 5.4, which results in boot issues due the overlay approach as applied in the Beaglebone OS

The issue with 5.4 should now have been resolved...  If you have free time, please re-test and let me know.

Regards,


--
Robert Nelson
https://rcn-ee.com/

William Hermans

unread,
May 20, 2020, 2:41:06 PM5/20/20
to beagl...@googlegroups.com
For the record, you do not have to wait for kernel 5.4 to do J1939. I wrote software using kernel 3.8.x that read a hybrid  NIMEA 2000 protocol, which uses the same high level protocol as J1939. All you have to do is understand J1939, and bit wrangle . . .

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

William Hermans

unread,
May 20, 2020, 2:46:02 PM5/20/20
to beagl...@googlegroups.com
Oh forgot to mention. You'd need to use socketCAN. Perhaps this guy will give you some ideas.  https://fabiobaltieri.com/2013/07/23/hacking-into-a-vehicle-can-bus-toyothack-and-socketcan/  

William Hermans

unread,
May 20, 2020, 2:53:50 PM5/20/20
to beagl...@googlegroups.com

Andrey

unread,
May 20, 2020, 3:29:02 PM5/20/20
to BeagleBoard
Guys, thanks for the answers!
Unfortunately, I can't use can1, it is have no output on my Board.
It is strange that after a bus crash, ifconfig shows the number of packets transmit 0 and received 3.
If the tire falls after only three attempts to send, it is not normal and does not look like a system for cars that is designed to be reliable.

debian@bone:~$ cansend can0 1F334455#1122334455667788
[  273.654439] can: raw protocol (rev 20170425)
[  273.670296] c_can_platform 481cc000.can can0: bus-off
debian@bone:~$ sudo ifconfig
can0: flags=129<UP,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 3  bytes 24 (24.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 47
...

This is more complicated than I thought.

William Hermans

unread,
May 20, 2020, 5:16:13 PM5/20/20
to beagl...@googlegroups.com
Without any code, or steps you've taken. No one can help, or say what's going on. I will say this however. I wrote in a relatively short period of time( with help! From multiple sources). Software that could communicate over CANBUS that was able to decode information from a "TRACE" inverter(XanBus) in real-time. This ran for weeks at a time, displaying the information in a web interface. Proven 100% accurate.

I would not say that using the CANBUS hardware interface on the beaglebone is 100% rock solid, but it had been very reliable in my case. Once I knew what I was doing. The only real problem we had was we were completely off-grid, powered by solar. So when we switched from solar power, to the genset. The quick power blip would sometimes put the beaglebone in a wonkey state. However, creating, and using canbus traffic logs. I was able to keep a working beaglebone powered via a laptop for months.

Probably the first place to look is at the hardware you're using. But I'd double check everything.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

William Hermans

unread,
May 20, 2020, 5:23:51 PM5/20/20
to beagl...@googlegroups.com
By the way "1F334455#1122334455667788" doesn't look like a valid J1939 packet. But I barely know that particular protocol.
Reply all
Reply to author
Forward
0 new messages