Hello,
I'm using linux-3.2.0-psp04.06.00.11 and recently I stumbled across an unexpected behavior whilst testing the DCAN error status.
I have an application that validates the controller as follows: the bus, physically disconnected, is opened and I get ERROR-ACTIVE when I read its status. I then send a dummy packet to force the controller to change to ERROR-WARNING, which it does. The problem happens if I try to do this twice, as shown below.
root@am335x-board:~# ip link set can0 type can bitrate 250000 triple-sampling on
root@am335x-board:~# ip link set can0 up
[ 400.400323] d_can d_can.1: can0: setting CAN BT = 0x1c05
root@am335x-board:~# ip -d link show can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 10
link/can
can <TRIPLE-SAMPLING> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
bitrate 250000 sample-point 0.875
tq 250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
d_can: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
clock 24000000
root@am335x-board:~# cansend can0 -i 0x10 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
interface = can0, family = 29, type = 3, proto = 1
root@am335x-board:~# ip -d link show can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 10
link/can
can <TRIPLE-SAMPLING> state ERROR-WARNING (berr-counter tx 128 rx 0) restart-ms 0
bitrate 250000 sample-point 0.875
tq 250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
d_can: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
clock 24000000
root@am335x-board:~# ip link set can0 down
root@am335x-board:~# ip link set can0 up
[ 462.705918] d_can d_can.1: can0: setting CAN BT = 0x1c05
root@am335x-board:~# ip -d link show can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 10
link/can
can <TRIPLE-SAMPLING> state ERROR-ACTIVE (berr-counter tx 128 rx 0) restart-ms 0
bitrate 250000 sample-point 0.875
tq 250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
d_can: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
clock 24000000
root@am335x-board:~# cansend can0 -i 0x10 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
interface = can0, family = 29, type = 3, proto = 1
root@am335x-board:~# ip -d link show can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 10
link/can
can <TRIPLE-SAMPLING> state ERROR-ACTIVE (berr-counter tx 128 rx 0) restart-ms 0
bitrate 250000 sample-point 0.875
tq 250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
d_can: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
clock 24000000
As you can see, after turned down and back on, the controller doesn't change its status anymore and my application fails the second time it runs.
As I don't fully comprehend how the driver works, I can't determine if this is a bug or if there is something I should do before turning the controller down. Either way, I also don't know if this happens to anyone else, any confirmation would be appreciated.
Thanks in advance,
DAVI