thankyou everyone’suggest. i operate your suggest.
in the terminal , i execute the command 'dmesg
', report an error
“[ 99.095649] can :version magic '4.4.15-tegra SMP preempt mod_unload aarch64’should be ‘4.4.15 SMP preempt mod_unload aarch64’”
should i resolve this question??
and i execute the command ‘ifconfig -a’
, i cannot see any information about ‘can’.
in addition , i execute the command
sudo modprobe can
, prompt error
modprobe:ERROR:could not insert ‘can’:Exec format error
and the command
‘sudo modprobe mttcan’
,
prompt error
modprobe: FATAL:module mttcan not found in directory /lib/modules/4.4.15
These are the steps can be followed to enable and check CAN on TX2.
Enable kernel support for mttcan(Other required modules are already supported)
CONFIG_MTTCAN = m (Here mttcan is compiled as a module)
Insert CAN BUS subsystem support module. modprobe can
Insert Raw CAN protocol module (CAN-ID filtering) modprobe can_raw
Real CAN interface support (for our case, it is: mttcan) modprobe mttcan (dependent module is can_dev: can driver with netlink support)
CAN interface settings for both the controllers ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on
ip link set up can0
ip link set can1 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on
ip link set up can1
CAN interfaces are up now. Use ifconfig to list all the interfaces which are up.
Installation of user app to check CAN communication sudo apt-get install can-utils
Commands to run to check CAN packet send/receive
broadcasting a can data packet: cansend <can_interface> <can_frame>
e.g. cansend can0 123#abcdabcd
Receiving a can data packet: candump can_interface
e.g. candump can1
Different tools (i.e. cangen, cangw etc) can be used for various filtering options.
To check the interface statistics ip -details -statistics link show can0
ip -details -statistics link show can1
Thank you so much for the nice instructions. I followed it step by step, however I can not get your CAN test result. May i ask few questions?
Did you connect any CAN transceivers in your test setup? Is SN65HVD230 a working choice?
When I setup both CANs as you did, both CANs go to ERROR-WARNING state. After I send a message from can0, can0 goes to BUS-OFF state and can1 goes to ERROR-PASSIVE state. Do you know what is wrong?
I look forward to hearing from you soon. Thanks in advance.
Please note that, CAN node consists of a CAN controller and a CAN transceiver.
Hence, you’ll need to have a CAN transceiver with TX2 to make the setup behave as a proper CAN node/network.
Without the Transceiver, only BUS functionality can be used but not as CAN network communication.
Regarding Transceiver: Yes, SN65HVD230 is a good option to choose as a CAN transceiver with TX2. Its verified.
Also do note that for easy setup and testing basic feature you can use cansend and candump utilities.
Cangen can also be used for more detailed usage like packet filtering and CAN packet generation etc.
These commands can be found under can-utils package.
To your Second comment:
Yes, we are using 500 kbps speed and it works fine.
If are you getting any error at this speed, please share the error logs.
Thank you so much for your kind support. It is great to learn that SN65HVD230 works fine with TX2 CAN 500kbps communication.
Regarding my test issue. In order to make my question clearly, I list my TX2 setup and test sequence below:
My TX2 setup:
a. Added MTTCAN as a module, rebuilt kernel
b. Installed SocketCAN
c. Connected CAN0 and CAN1 with CAN transceivers as in attached picture:
Load below modules:
a. $ sudo modprobe can
b. $ sudo modprobe can_raw
c. $ sudo modprobe can_dev
d. $ sudo modprobe mttcan
Configure CAN0 and CAN1:
a. $ sudo ip link set can0 type can bitrate 500000
b. $ sudo ip link set up can0
c. $ sudo ip link set can1 type can bitrate 500000
d. $ sudo ip link set up can1
Check CAN0 and CAN1 with “ip –details link show can*”, both are in ERROR-WARNING state.
Open a terminal and set CAN1 to “$ candump can1”
Open another terminal, and set CAN0 to send data using “$ cansend can0 123#112233” or “cangen can0”
Check terminal which set “$candump can1” previously, it doesn’t show any signal.
Check CAN0 and CAN1 with “ip –details link show can*” again, CAN0 went to BUS-OFF state and CAN1 went to ERROR-PASSIVE state.
Do you see any issues with my tests? Could you give me some hints?
It is unlikely since I checked the connection multiple times. However, I will double check again and come back to you. In the meantime, please share if you come with any other ideas.
I double checked my connection and soldering. The tests still failed.
I wonder what exact CAN transceiver do you use? I use CJMCU-230 with SN65HVD230 (marked as VP230 61M CTCVG4) on its package. It is configured to slope control mode with a 10k resistor. Have you done any changes to your CAN transceiver to make the CAN communication working?
What is length of your CAN bus? Do you need to add any termination resistor to your can bus?
I look forward to hearing from you soon. Thank you so much.
I am also using CJMCU-230 with SN65HVD230.
Have a look at attached image for same.
I faced similar issue while connecting transceiver on breadboard using the connector which was supplied along with the transceiver.
We found it working fine after properly soldering and placing on the breadboard.
And you don’t have to configure with 10K resistor/termination resistor as that is there as part of the SoC - CJMCU-230.
Please check with the attachment and let us know if are you using it same way.
Also check the CAN Bus status when in ideal state (before transmitting/receiving the packets).
I finally figured out the route cause in my test setup. It turns out that there are some issues in the CAN transceivers that I used (CJMCU-230 PCBs). One obvious issue is that the CJMCU-230 PCBs have wrong resistor values of both resistors on it. After replacing them with same products from a different vendor supply, the tests passed.
I apologize for the inconvenience that I may caused and would like to thank you again for all your kind support.