mcp251x Error during multiple ip link ups/downs

Open
#5,976 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
32/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
c, linux, raspberry-pi, shell

Research direction

Start by reproducing the failure with the supplied Bash loop and review the mcp251x driver paths involved in repeated interface down/up and bitrate changes. Use the kernel messages about failure to enter config mode and inconsistent configuration to trace the transition; done means repeated changes no longer produce RTNETLINK timeouts or hang the Raspberry Pi.

Written by the indexing model from the issue text.

Description

Describe the bug

Hello,

I work with the CAN bus (simple write and reads works fine) I wanted to prepare automatic detection of the baud rate. The problem occurs when we changing interface settings in a loop. After a few tries, "RTNETLINK Replies: Connection Timeout" appears and the Raspberry Pi hangs.

I founded similar problem at fork but for mcp25xxfd driver https://github.com/msperl/linux-rpi/issues/12

Steps to reproduce the behaviour

Connect to a CAN bus device that sends data and run script at Raspberry Pi. I added sleeps to check if this could help

#!/bin/bash
array=(10000 20000 50000 100000 125000 250000 500000 800000 1000000)
can=$1
while true
do
    for i in "${array[@]}"
    do
        echo $i
        sleep 1
        sudo ip link set $can down
        sleep 1
        sudo ip link set $can up type can bitrate $i
        sleep 1
        candump $can -T 100
    done
done
Device (s)

Raspberry Pi CM4 Lite

System

Raspberry Pi reference 2023-10-10
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 962bf483c8f326405794827cce8c0313fd5880a8, stage2

Aug 10 2023 15:33:38
Copyright (c) 2012 Broadcom
version 03dc77429335caee083e22ddc8eec09c07f12a7a (clean) (release) (start)

Linux raspberrypi 6.1.0-rpi4-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.54-1+rpt2 (2023-10-05) aarch64 GNU/Linux

Logs

Feb 21 14:40:10 raspberrypi kernel: mcp251x spi0.0: MCP251x didn't enter in config mode
Feb 21 14:40:10 raspberrypi kernel: A link change request failed with some changes committed already. Interface can1 may have been left with an inconsistent configuration, please check.

Additional context

No response

Dominant language
C
Stars
13.2k
Forks
5.5k
Avg merge
2d 21h
Merged PRs (30d)
21

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from raspberrypi/linux

All issues in raspberrypi/linux

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.