I am developing can-bus application.
I faced the problem is can-bus state.
When my board is booted, can-bus receive data .
The state change ERROR-ACTIVE to ERROR-PASSIVE when can-bus is received first packet
To resolve this problem I reset can-bus driver.
for example
rmmod mttcan
modprobe mttcan
interface up…
This reactivated can-bus works well for a long time.
It only problem when the first packet is received.
can i get help?
sorry. I was on vacation last week. So late reply.
And I attached dmesg.txt
Create signals with STM microcontrollers that are being used in other projects.
I also tried Kvaser, a can simulator, and it was the same phenomenon. dmesg.txt (76.1 KB)
install
sudo busybox devmem 0x0c303018 w 0x458 # can 0 / in
sudo busybox devmem 0x0c303010 w 0x400 # can 0 / out
sudo busybox devmem 0x0c303008 w 0x458 # can 1 / in
sudo busybox devmem 0x0c303000 w 0x400 # can 1 / out
sudo modprobe can
sudo modprobe can_raw
sudo modprobe mttcan
sudo ip link set can0 up type can bitrate 250000 sjw 10 dbitrate 250000 dsjw 7 berr-reporting on fd on
sudo ip link set can1 up type can bitrate 250000 sjw 10 dbitrate 250000 dsjw 7 berr-reporting on fd on
I made a script with the above command and called by my application when booting.
The can1 does not use now. It’s just a setting.
When I was used command “sudo ip link set can0 up can0 bitrate 1000000”, It is not work and view error message “Error: either “dev” is duplicate, or “can0” is a garbage.”
So I changed the command to “sudo ip link set can0 up type can bitrate 1000000”.
Sorry that it’s my typo, your command should be right.
Do you know what causes can0 enter into ERROR-PASSIVE state?
can state ERROR-PASSIVE (berr-counter tx 0 rx 127) restart-ms 0
There’s berr-counter in rx, it should be caused from wrong configuration for either side in CAN communication.
Could you send/receive data when you are in ERROR-PASSIVE state?
I don’t know why the state entered ERROR-PASSIVE.
However, I ran the following test to know the problem.
The STM transmits can data periodically.
Boot up the xavier board.(no load can driver)
Load can driver after booting completed.
When xavier receive first packet, can0 state changed from ERROR-ACTIVE to ERROR-PASSIVE.
Reload can driver
The can0 state is ERROR-ACTIVE and remain it when receive first packet after reloading driver.
Restarting my application or reloading the driver works fine.
However, rebooting the xavier board is the same as in #4.(power down)
Analyzing the above phenomenon, power is applied for the first time and the first packet reception becomes a problem. So the initial driver status is questionable.
After applying that patch, you may just need to re-configure the can0 interface instead of re-load the kernel module.
Have you tried to start transmit can data from STM after the can setup finished on the Xavier board?
Entering ERROR-PASSIVE state may be caused from un-matched bitrate or configuration for both sides.