CAN Busoff


dmesg日志上报上面截图的错误,can0的通信目前也是不正常的,如何处理这个问题,内核版本5.10.216,can0的脚本配置如下

regval=$(busybox devmem 0x0c303000)                                                                                                         
echo $regval                                                                                                                                
if [[ "$regval" != 0x0000C400 ]]; then                                                                                                      
  echo "Enable CAN"                                                                                                                         
  busybox devmem 0x0c303000 32 0x0000C400                                                                                                   
  busybox devmem 0x0c303008 32 0x0000C458                                                                                                   
  busybox devmem 0x0c303010 32 0x0000C400                                                                                                   
  busybox devmem 0x0c303018 32 0x0000C458                                                                                                   

  modprobe can                     
  modprobe can-raw                 
  modprobe can-dev                 
  modprobe mttcan                  
fiip -details -statistics link show can0 || true
ip link set can0 down || true
ifconfig can0 down || true

# reload kernel driver
if [[ "$1" == "reset" ]]; then
  rmmod mttcan
  rmmod can-dev
  rmmod can-raw
  rmmod can
  modprobe can
  modprobe can-raw
  modprobe can-dev
  modprobe mttcan
fi

# bring up
ip link set can0 type can bitrate 250000 sjw 4 dbitrate 250000 dsjw 4 berr-reporting on fd on restart-ms 100
ip link set up can0
ip -details -statistics link show can0

Hi DreamLan,

Are you using the devkit or custom board for AGX Xavier?

L4T R35.6.0?

Do you use CAN transceiver for internal mttcan (can0) connecting with your CAN device?
Please share the block diagram for CAN connections.

是的,我使用的是jetson AGX Xavier定制板,然后通过can0和外部设备进行通信,主要是和stm32进行通信,can0是运行一段时间之后才出现上面的log的,一开始是正常的

Please share the result of the following command when you hit the issue.

$ sudo ip -d -s link show can0

Please also share the block diagram of your connection between AGX Xavier with STM32 MCU.

好的,下次出现这个问题的时候,我再分享这个日志

刚刚复现这个问题了,信息如下

It seems there’re error packets in your case and it enters in to bus-off few times.

You used 249350 as bitrate from AGX Xavier. How about the bitrate from your CAN device(STM32 MCU)?

另外請提供你的連接圖(包含AGX Xavier & STM32 & CAN tranceivers是如何連接的)讓我們做進一步確認

ip link set can0 type can bitrate 250000 sjw 4 dbitrate 250000 dsjw 4 berr-reporting on fd on restart-ms 100,
我们设置的比特率是250000,连接图稍等一下


这是我们的连接图


出现问题的时候,jetson只能通过can0写数据,读取数据失败

How do you transmit/receive CAN data? (are you using custom CAN application?)

I don’t see STM32 from your connection block diagram.

It seems 250k is not available so that it uses 249350 instead.
Could you also try using 500k as bitrate?
and how do you configure the bitrate from MCU side?