Enable CAN Bus on Jetson TX2

Hello

we bought the new Jetson TX2 Dev Kit to replace our old TX1, running with an
SPI to CAN Chip.

We are currently trying to enable the CAN Bus on the Jetson TX2 to send and receive
Messages with socketcan.

After we installed the current Version of JetPack 3.0 can0 doesn’t show up under ifconfig.
Ifconfig just shows the Ethernet and Wlan Connection.

Any idea how to enable the CAN Bus ?

Hi,

I’m able to see can0 and can1 with ifconfig -a

To achieve this, I rebuilt the jetson TX2 kernel enabling Bosh’s MTTCAN driver.

This link might help you to rebuild the TX2 kernel : Build Kernel and Modules - NVIDIA Jetson TX2 - JetsonHacks

You just have to search for can driver referenced here : https://devtalk.nvidia.com/default/topic/1006762/jetson-tx2/how-can-i-use-can-bus-in-tx2-/

instead of the one he uses in the tutorial.

ps. I have no been able to use the can bus yet, but I’m working on it, let me know how it goes!

Cheers

Thanks this is working.

I am now adding an CAN Transciever to the Dev Kit. If this is done
I will try to send and recieve CAN Messages with socketCAN.

Hi, I added a CAN transceiver this morning and I have been able to send and receive messages instantly using SocketCAN feature tools: cansend and candump

You can install those using sudo apt-get install can-utils

Regards

thank you for share your experience
as my transceiver is on the way to my home. I am curious
if you can get the specific id that you want to get from the python code
thanks

I’m using a c++ script that I run on ROS.

But yes i’m able to set the id I want.

Otherwise I’m pretty new to CAN BUS communication protocol, so probably not the best to help you with this.

Best of luck!

How do you guys automatically bring up the CAN interface when booting?

Systemd and ubuntu have a bunch of different ways to activate network interfaces.
To see how network interfaces typically start up, do “sudo journalctl -xb --unit NetworkManager.service” to see logs of the network manager.

Easiest might be to hit it with a hammer, and create a script that installs the modules and brings up the interface, and then make sure that script gets started on bootup by creating a .system module file and put it in /etc/systemd/system

Better might be to list the modules in the /etc/modules file, and then define the interfaces in /etc/network/interfaces.

You can also put scripts in /etc/network/if-up.d/ that run when network interfaces show up; that script can look for the can interfaces and do whatever you want.

Tried various script approaches, but none worked.

I resoved it by commenting out #mttcan in /etc/modprobe.d/blacklist-mttcan.conf in order ensure that the modules were loaded.

Then I added this to /etc/network/interfaces

[b]# interfaces(5) file used by ifup(8) and ifdown(8)

Include files from /etc/network/interfaces.d:

source-directory /etc/network/interfaces.d

auto can0
iface can0 inet manual
pre-up /sbin/ip link set $IFACE type can bitrate 500000
up /sbin/ifconfig $IFACE up
down /sbin/ifconfig $IFACE down[/b]

ifconfig now shows can0 after booting

I need to use connector j23 and use SPI0 (pin 38 on SoC tegra, E3) like GPIO. Which is its gpio number?

I have an Elroy Carrier board for the Jetson TX2 and want to use it, and because it has no pins for CANbus, I was planning to use the SPI…
What SPI to CANChip are you using?
It will be useful to know.