Analysis of CAN driver problems in Linux system

On the TI sam3354 chip, use version 3.13 and 4.19 kernels to compile the CAN driver. After loading and starting, you can check that there is a CAN device, but you cannot directly use ifconfig to operate the CAN device. The following is a brief analysis of the problem.

After loading the driver, check the network devices:

 You can see that there are two CAN devices, CAN0 and CAN1, but ifconfig starts the network device, it prompts:

 As above, ifconfig CAN0 cannot be started directly. Configure the baud rate according to the instructions of newbing and chatgpt:

ip link set can0 type can bitrate 500000

There is still a problem. Newbing analyzed that it may be a problem with the driver or a problem with the phy.

Find another device. After starting it, check the ifconfig command. You can see the CAN0 device, but there is no CAN1 device. After turning off the CAN0 device, then starting CAN0 is OK, but unloading the driver and then loading it will also fail. The process is as follows:

 Failed to start CAN1, turn off CAN0, then turn it on normally

 Remove the CAN driver and then start it again, as follows:

 It will also fail. Looking at the debugging information, it seems that the rate is not set, but using the command provided by chatgpt will return failure (should be related to the modified version of the kernel). Finally, directly use a test program to start CAN0 and CAN1, and set The baud rate can be normal, as follows:

Command debugging:

 

 Summarize:

In the Linux system, CAN is a network device. The CAN interface needs to be configured with a baud rate before it can be started. The baud rate configuration method is related to the kernel. It is easier to use the system program interface program.

Guess you like

Origin blog.csdn.net/weixin_45119096/article/details/131106327