Linux 6.5 Mainline kernel driver (NetDev): PCAN-USB Pro FD lost channel-id assignment after reconnect

This forum covers PCAN-Linux and Linux development issues concerning our products
TomyYamy
Posts: 7
Joined: Fri 5. Apr 2024, 05:09

Linux 6.5 Mainline kernel driver (NetDev): PCAN-USB Pro FD lost channel-id assignment after reconnect

Post by TomyYamy » Fri 5. Apr 2024, 05:28

I'm using several PCAN-USB Pro FDs on Linux. I would like identify the adapter to correct can interface number in Linux. In order to that can_channel_id is necessary to identify them in /etc/udev/rules.d/.
PCAN-USB Pro FD can keep only one channel of can_channel_id. It can not keep both channels with different can_channel_id.

Environment
  • PCAN-USB Pro FD firmware v3.4.4 (latest)
  • Ubuntu 22.04 kernel v6.5
  • Not using peak-linux-driver-8.17.0. Using kernel original one.
Situation
I'm following "Linux and PEAK-System's CAN Interfaces" https://www.peak-system.com/fileadmin/m ... /index.htm.
I succeeded in registering can_channel_id.

Code: Select all

Ubuntu2204:~$ sudo ethtool -E can0 value 10
Ubuntu2204:~$ cat /sys/class/net/can0/peak_usb/can_channel_id 
0000000A
Ubuntu2204:~$ sudo ethtool -E can1 value 11
Ubuntu2204:~$ cat /sys/class/net/can1/peak_usb/can_channel_id 
0000000B
However, when I reconnected the adapters, only one channel keeps the can_channel_id.

Code: Select all

Ubuntu2204:~$ cat /sys/class/net/can0/peak_usb/can_channel_id 
0000000A
Ubuntu2204:~$ cat /sys/class/net/can1/peak_usb/can_channel_id 
FFFFFFFF
Is that my setting mistake? or firmware issue?
Do we have solution for identifying several PCAN-USB Pro FDs?

M.Heidemann
Sales & Support
Sales & Support
Posts: 989
Joined: Fri 20. Sep 2019, 13:31

Re: Linux 6.5 Mainline kernel driver (NetDev): PCAN-USB Pro FD lost channel-id assignment after reconnect

Post by M.Heidemann » Fri 5. Apr 2024, 09:57

Hello,

To confirm:

You also added the appropiate rules and the the shell script as described in the documentation?

The purpose of this number is to be used for the naming of the associated CAN interface. This is made possible by the Udev daemon and:

1/ adding a new appropriate rule in (for example) the file "70-persistent-net.rules":

Code: Select all

$ cat /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="peak_usb", KERNEL=="can*", PROGRAM="/bin/peak_usb_device_namer %k", NAME="%c"
2/ adding the following shell script (for example) "/bin/peak_usb_device_namer":

Code: Select all

$ cat /bin/peak_usb_device_namer
#!/bin/sh
#
# External Udev program to rename peak_usb CAN interfaces according to the flashed device numbers.
#
# (C) 2023 PEAK-System GmbH by Stephane Grosjean 
#
[ -z "$1" ] && exit 1
CAN_ID="/sys/class/net/$1/peak_usb/can_channel_id"
if [ -f $CAN_ID ]; then
        devid=`cat $CAN_ID`
        # PCAN-USB specific: use "000000FF" instead of "FFFFFFFF" below
        if [ "$devid" != "00000000" -a "$devid" != "FFFFFFFF" ]; then
                printf "can%d\n" 0x${devid}
                exit 0
        fi
fi
echo $1
By convention, the value of the device id when leaving the factory is either 00000000 or FFFFFFFF (000000FF specifically for PCAN-USB). In these specific cases, the above script considers that the CAN interface should not be renamed. Once these changes have been made, the peak_usb driver must be unloaded from memory (if it was previously loaded) and then reloaded:

Code: Select all

$ sudo rmmod peak_usb
$ sudo modprobe peak_usb
i was not able to replicate the issue using the same kernel and a PCAN-USB Pro FD here.

Please let me know!

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

TomyYamy
Posts: 7
Joined: Fri 5. Apr 2024, 05:09

Re: Linux 6.5 Mainline kernel driver (NetDev): PCAN-USB Pro FD lost channel-id assignment after reconnect

Post by TomyYamy » Fri 5. Apr 2024, 20:54

Hi Marvin.

Thank you for your support. Yes I have done "70-persistent-net.rules" and "/bin/peak_usb_device_namer". However, it did not work. And more than that, the setting and can_channel_id setting is independent issue.
Please see "/bin/peak_usb_device_namer". It includes following line.

Code: Select all

CAN_ID="/sys/class/net/$1/peak_usb/can_channel_id"
This means, the script uses

Code: Select all

Ubuntu2204:~$ cat /sys/class/net/can0/peak_usb/can_channel_id 
Unless correctly set the can_channel_id, whole script does not work. So it would be independent issue. We may make sure setting command

Code: Select all

Ubuntu2204:~$ sudo ethtool -E can0 value 10
works correctly, then we may discuss "70-persistent-net.rules" and "/bin/peak_usb_device_namer" settings.

Thanks,
Tom

M.Heidemann
Sales & Support
Sales & Support
Posts: 989
Joined: Fri 20. Sep 2019, 13:31

Re: Linux 6.5 Mainline kernel driver (NetDev): PCAN-USB Pro FD lost channel-id assignment after reconnect

Post by M.Heidemann » Mon 8. Apr 2024, 08:36

Hello Tom,

Setting an ID is required for this to work and it has to be explicitly given, yes.
How exactly does the setting command not work to your expectation? can you elaborate?

Best Regards
Marvin
---
Marvin Heidemann
PEAK-Support Team

TomyYamy
Posts: 7
Joined: Fri 5. Apr 2024, 05:09

Re: Linux 6.5 Mainline kernel driver (NetDev): PCAN-USB Pro FD lost channel-id assignment after reconnect

Post by TomyYamy » Mon 8. Apr 2024, 16:43

Hi Marin,

Thank you for your support. As I mentioned at the first post. ID set way is

Code: Select all

Ubuntu2204:~$ sudo ethtool -E can0 value 10
Ubuntu2204:~$ cat /sys/class/net/can0/peak_usb/can_channel_id 
0000000A
Ubuntu2204:~$ sudo ethtool -E can1 value 11
Ubuntu2204:~$ cat /sys/class/net/can1/peak_usb/can_channel_id 
0000000B

And even reconnect the same PCAN-USB Pro FD, I expect following result since it is registered EEPROM.

Code: Select all

Ubuntu2204:~$ cat /sys/class/net/can0/peak_usb/can_channel_id 
0000000A
Ubuntu2204:~$ cat /sys/class/net/can1/peak_usb/can_channel_id 
0000000B

However, after reconnecting, the result is

Code: Select all

Ubuntu2204:~$ cat /sys/class/net/can0/peak_usb/can_channel_id 
0000000A
Ubuntu2204:~$ cat /sys/class/net/can1/peak_usb/can_channel_id 
FFFFFFFF
That is not expected since /sys/class/net/can1/peak_usb/can_channel_id set FFFFFFFF rather than 0000000B.

Once could you represent my command in Ubuntu 2204 in your end? Then we'll see the same issue.

Thanks,
Tom

TomyYamy
Posts: 7
Joined: Fri 5. Apr 2024, 05:09

Re: Linux 6.5 Mainline kernel driver (NetDev): PCAN-USB Pro FD lost channel-id assignment after reconnect

Post by TomyYamy » Mon 8. Apr 2024, 17:35

Could you please try this represent shell script in your end with Ubuntu 22.04 kernel v6.5?

Code: Select all

#! /bin/bash

read -p "Please connect PCAN-USB Pro to a USB port. Then hit enter: "

echo "Setting '10' to 'can0's non-volatile memory."
sudo ethtool -E can0 value 10

echo "Setting '11' to 'can1's non-volatile memory."
sudo ethtool -E can1 value 11


can0val=$(cat /sys/class/net/can0/peak_usb/can_channel_id )
echo "Checking the stored 'can0' non-volatile memory value..."
if [ ${can0val} == "0000000A" ]; then
    echo "can0: OK."
else
    echo "can0: NG: actual:${can0val} != expected:000000A"
fi


can1val=$(cat /sys/class/net/can1/peak_usb/can_channel_id )
echo "Checking the stored 'can1' non-volatile memory value..."
if [ ${can1val} == "0000000B" ]; then
    echo "can1: OK."
else
    echo "can1: NG: actual:${can1val} != expected:000000B"
fi


read -p "Please replug (unplug 5 [sec] and then plug abd wait 5 [sec]) PCAN-USB Pro. Then hit enter: "

echo "We are expecting the non-volatile memory keep the stored values above."

can0val=$(cat /sys/class/net/can0/peak_usb/can_channel_id )
echo y"Checking the stored 'can0' non-volatile memory value..."
if [ ${can0val} == "0000000A" ]; then
    echo "can0: OK."
else
    echo "can0: NG: actual:${can0val} != expected:000000A"
fi


can1val=$(cat /sys/class/net/can1/peak_usb/can_channel_id )
echo "Checking the stored 'can1' non-volatile memory value..."
if [ ${can1val} == "0000000B" ]; then
    echo "can1: OK."
else
    echo "can1: NG: actual:${can1val} != expected:000000B"
fi

# (EOF)
You will see the result below.

Code: Select all

Ubuntu2204:~$ ./PCAN-USB_Pro_FD_can_channel_id_test.sh
Please connect PCAN-USB Pro to a USB port. Then hit enter: 
Setting '10' to 'can0's non-volatile memory.
Setting '11' to 'can1's non-volatile memory.
Checking the stored 'can0' non-volatile memory value...
can0: OK.
Checking the stored 'can1' non-volatile memory value...
can1: OK.
Please replug (unplug 5 [sec] and then plug abd wait 5 [sec]) PCAN-USB Pro. Then hit enter: 
We are expecting the non-volatile memory keep the stored values above.
yChecking the stored 'can0' non-volatile memory value...
can0: OK.
Checking the stored 'can1' non-volatile memory value...
can1: NG: actual:FFFFFFFF != expected:000000B

M.Heidemann
Sales & Support
Sales & Support
Posts: 989
Joined: Fri 20. Sep 2019, 13:31

Re: Linux 6.5 Mainline kernel driver (NetDev): PCAN-USB Pro FD lost channel-id assignment after reconnect

Post by M.Heidemann » Tue 9. Apr 2024, 08:28

Hello Tomy,

I already replicated your usecase on our test-rig using Ubuntu 22.04 (Kernel 6.5) and wasn't able to reproduce the issue,
when i set the corresponding IDs the will be A) set and B) retained (Using both config file and script)

Do you have the option to test this with a) another machine running Ubuntu or B) another PCAN-USB Pro FD?

I will also ask our Linux-Development Team if they have some insight regarding this and i will let you know what their take on this is.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

TomyYamy
Posts: 7
Joined: Fri 5. Apr 2024, 05:09

Re: Linux 6.5 Mainline kernel driver (NetDev): PCAN-USB Pro FD lost channel-id assignment after reconnect

Post by TomyYamy » Tue 9. Apr 2024, 17:34

Hi Marin,

Before going to the option, May I make sure?

"when i set the corresponding IDs the will be A) set and B) retained (Using both config file and script)"

Did you disconnect the PCAN-USB Pro FD then re-connect between A) set and B) ?

Could you please also paste your output log of represent shell?
Could you please send "dmesg" output which is filtered by "usb" word?

Thanks,
Tom

M.Heidemann
Sales & Support
Sales & Support
Posts: 989
Joined: Fri 20. Sep 2019, 13:31

Re: Linux 6.5 Mainline kernel driver (NetDev): PCAN-USB Pro FD lost channel-id assignment after reconnect

Post by M.Heidemann » Wed 10. Apr 2024, 08:04

Hi,
Did you disconnect the PCAN-USB Pro FD then re-connect between A) set and B) ?
Yes.
Could you please also paste your output log of represent shell?
Could you please send "dmesg" output which is filtered by "usb" word?
I don't have access to the test-machine right now, it is used for another test.
If you are willing to wait 1-2 days i could provide those to you

It might be faster to grab another PCAN-USB FD (if available) first and see if
it acts any different, swapping the system wholesale would be the last resort.

Thanks,
Marvin
---
Marvin Heidemann
PEAK-Support Team

TomyYamy
Posts: 7
Joined: Fri 5. Apr 2024, 05:09

Re: Linux 6.5 Mainline kernel driver (NetDev): PCAN-USB Pro FD lost channel-id assignment after reconnect

Post by TomyYamy » Wed 10. Apr 2024, 18:57

Hi Marvin,

I can share additional information. here is my machine that I tests.
  • Mother board: ASUS Sabertooth X79
  • Chipset: Intel X79
  • USB controller: ASMedia® USB 3.0 controllers
We also tried Ubuntu 20.04 and peak-linux-driver-8.17.0 (latest). But the situation is same.
I don't think it is a host-machine side's issue.
I don't have access to the test-machine right now, it is used for another test.
If you are willing to wait 1-2 days i could provide those to you
Please share test-rig machine spec/chip-set/USB controller information as well as I have shared.

Let me answer your previous questions.
a) another machine running Ubuntu
Sorry I don't have another machine that has Ubuntu 22.04. Trying with Ubuntu 20.04 with peak-linux-driver-8.17.0 is our best effort.
B) another PCAN-USB Pro FD?
Sorry I have only one PCAN-USB Pro FD. I wrote "I'm using several PCAN-USB Pro FDs on Linux.". That was my miss-writing. We are "planing" to use several PCAN-USB Pro FDs. We have only one PCAN-USB Pro FDs for bench-marking.

Thanks,
Tom

Post Reply