Re: Meta-respberrypi socketcan - how do I bring up the interfaces?


Chris Tapp
 

Hi Stephen,

I managed to miss some of the output to ip -s -d link show can0, which should have shown:

3: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0 minmtu 0 maxmtu 0 
    can state STOPPED restart-ms 0 
  bitrate 1000000 sample-point 0.750 
  tq 125 prop-seg 2 phase-seg1 3 phase-seg2 2 sjw 1
  mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
  clock 8000000 
  re-started bus-errors arbit-lost error-warn error-pass bus-off
  0          0          0          0          0          0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
    RX: bytes  packets  errors  dropped missed  mcast   
    0          0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    0          0        0       0       0       0       

This shows “DOWN” as well as “STOPPED”, and is different because I have found that I can set the bitrate using:

ip link set can0 type can bitrate 1000000

Note that this does not include ‘up’ as that is what was causing the SSH session to stop responding.

However, any attempt to bring it up:

ifconfig can0 up

stops the SSH session again. If I set a second connection up first and run ‘ps’, I can see:

  480 root      2140 D    ifconfig can0 up
  481 root         0 DW   [irq/65-spi0.1]
  482 root         0 IW<  [mcp251x_wq]

So it’s stuck in an uninterruptible sleep (which explains the ssh session behaviour)!

The output of dmesg shows:

[  735.196538] INFO: task irq/65-spi0.1:481 blocked for more than 122 seconds.
[  735.196559]       Tainted: G         C        5.10.31-v7l #1
[  735.196578] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[  735.196598] task:irq/65-spi0.1   state:D stack:    0 pid:  481 ppid:     2 flags:0x00000000
[  735.196634] Backtrace: 
[  735.196671] [<c0ca4808>] (__schedule) from [<c0ca523c>] (schedule+0x6c/0xe0)
[  735.196696]  r10:c2e286b8 r9:00000000 r8:c1952000 r7:00000002 r6:c1953e4c r5:c1952000
[  735.196717]  r4:c2e35d00
[  735.196742] [<c0ca51d0>] (schedule) from [<c0ca56ac>] (schedule_preempt_disabled+0x18/0x1c)
[  735.196763]  r5:c1952000 r4:c2e286b4
[  735.196789] [<c0ca5694>] (schedule_preempt_disabled) from [<c0ca6d9c>] (__mutex_lock.constprop.0+0x2e0/0x58c)
[  735.196816] [<c0ca6abc>] (__mutex_lock.constprop.0) from [<c0ca7164>] (__mutex_lock_slowpath+0x1c/0x20)
[  735.196840]  r10:ffffe000 r9:c2e28000 r8:c30491c0 r7:c2a3f400 r6:c30491e4 r5:c2e285c0
[  735.196861]  r4:c2e286b4
[  735.196885] [<c0ca7148>] (__mutex_lock_slowpath) from [<c0ca71c4>] (mutex_lock+0x5c/0x60)
[  735.196915] [<c0ca7168>] (mutex_lock) from [<bf05ab60>] (mcp251x_can_ist+0x54/0x434 [mcp251x])
[  735.196937]  r5:c2e285c0 r4:c30491c0
[  735.196969] [<bf05ab0c>] (mcp251x_can_ist [mcp251x]) from [<c02975c8>] (irq_thread_fn+0x2c/0x8c)
[  735.196994]  r10:ffffe000 r9:c029759c r8:c30491c0 r7:c270cb00 r6:c30491e4 r5:c270cb00
[  735.197014]  r4:c30491c0
[  735.197041] [<c029759c>] (irq_thread_fn) from [<c02978d4>] (irq_thread+0x1e0/0x2b4)
[  735.197064]  r7:c270cb00 r6:c30491e4 r5:c1952000 r4:00000000
[  735.197091] [<c02976f4>] (irq_thread) from [<c02486dc>] (kthread+0x168/0x16c)
[  735.197116]  r10:c1925c3c r9:c30491c0 r8:c02976f4 r7:c1952000 r6:00000000 r5:c18cfe00
[  735.197136]  r4:c316fd80
[  735.197161] [<c0248574>] (kthread) from [<c020010c>] (ret_from_fork+0x14/0x28)
[  735.197182] Exception stack(0xc1953fb0 to 0xc1953ff8)
[  735.197205] 3fa0:                                     00000000 00000000 00000000 00000000
[  735.197228] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  735.197251] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[  735.197276]  r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c0248574
[  735.197296]  r4:c18cfe00

I think this means the driver is stuck in a wait loop. No idea (yet) on how to work this one out ;-)

--

Chris Tapp

----
You can tell you're getting older when your car insurance gets real cheap!

On 30 Sep 2021, at 13:16, Stephen John Smoogen <smooge@...> wrote:

On Thu, 30 Sept 2021 at 05:21, Chris Tapp <opensource@...> wrote:

I am trying to get a Waveshare CAN interface[1] running on an RPi4 using meta-raspberrypi with hardknott.


I am looking at getting one of these so do not have final answers.
However looking at
http://www.port.de/cgi-bin/CAN/CanFaqErrors
https://stackoverflow.com/questions/64892746/socketcan-device-state-stopped
https://www.can-cia.org/can-knowledge/canopen/network-management/

The STOPPED state indicates that the device is detecting some sort of
error and can not continue. My guess is that the iproute2 command
tried to bring things up and found the bus in a non-workable state or
too many errors. For other buses this could be due to non-termination
(aka is the CAN bus connected to anything?) For some buses they have a
'self-termination' if the leads do not have the voltages/resistance on
the end. Others will fail (like removing the end terminator on a
thinwire ethernet network or not having a good loop on one of the
RS422? networks (memory is fuzzy if this is the one or it was a
different one))

Sorry I can't be of more help.

I have added ENABLE_SPI_BUS = “1” and ENABLE_DUAL_CAN = “1” to my local.conf and see the following at boot:

[    2.858284] CAN device driver interface
[    2.879431] mcp251x spi0.1 can0: MCP2515 successfully initialized.
[    2.891019] mcp251x spi0.0 can1: MCP2515 successfully initialized.
[  176.170231] can: controller area network core
[  176.178987] can: raw protocol

So, the interfaces are detected.

However, I cannot bring the interfaces up. I am expecting to use something like:

 ip link set can0 up type can bitrate 1000000
 ifconfig can0 up

But that results in :

 ip: either "dev" is duplicate, or "type" is garbage

This appears to be due to the ‘ip’ command not working with Busybox, so I tried adding iproute2 to the image, but the command then hangs the system.

I have tried skipping the ‘ip’ command, but ifconfig then reports:

 ifconfig: SIOCSIFFLAGS: Invalid argument

I can get some information for the interface:

 ip -s -d link show can0
   link/can  promiscuity 0 minmtu 0 maxmtu 0
   can state STOPPED restart-ms 0
         mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
         clock 8000000
         re-started bus-errors arbit-lost error-warn error-pass bus-off
         0          0          0          0          0          0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
   RX: bytes  packets  errors  dropped missed  mcast
   0          0        0       0       0       0
   TX: bytes  packets  errors  dropped carrier collsns
   0          0        0       0       0       0

What do I need to do to bring the interface up?

Chris



[1] https://www.waveshare.com/wiki/2-CH_CAN_HAT

--

Chris Tapp
opensource@...
www.keylevel.com






--
Stephen J Smoogen.
I've seen things you people wouldn't believe. Flame wars in
sci.astro.orion. I have seen SPAM filters overload because of Godwin's
Law. All those moments will be lost in time... like posts on a BBS...
time to shutdown -h now.




Join yocto@lists.yoctoproject.org to automatically receive all group messages.