This forum covers PCAN-Linux and Linux development issues concerning our products
-
Magnus.Z
- Posts: 7
- Joined: Mon 2. May 2022, 11:24
Post
by Magnus.Z » Mon 2. May 2022, 16:07
Hi, I am installing pcan driver for linux in our raspberry pi compute module 4 that has "Debian GNU/Linux 11 (bullseye)". Ther kernel is 5.15.32-v8+
We followed the guide in this link:
viewtopic.php?f=59&t=6897&sid=0d035991e ... 10ca1be8c9
"sudo make install" and "sudo modprobe pcan" went well. However when we are running "dmesg | grep pcan" we are getting the following output:
Code: Select all
evoy@raspberrypi:~/peak-linux-driver-8.14.0 $ dmesg | grep pcan
[ 4.477943] pcan: loading out-of-tree module taints kernel.
[ 4.506656] pcan: Release_20220124_n (le)
[ 4.506688] pcan: driver config [mod] [pci] [pec] [usb] [net]
[ 4.507393] pcan 0000:01:00.0: enabling device (0000 -> 0002)
[ 4.507425] pcan 0000:01:00.0: PCAN-M.2 sub-system id 14h (4 channels)
[ 4.628624] pcan: PCAN-M.2: flash write failure (err -16)
[ 4.628671] pcan: PCB v2h FPGA v3.2.1 (mode 3)
[ 4.628783] pcan 0000:01:00.0: pcan: Rx dma_alloc_coherent(4096) failure
[ 4.628856] pcan: probe of 0000:01:00.0 failed with error -12
[ 4.629288] usbcore: registered new interface driver pcan
[ 4.629324] pcan: major 510.
We have an pci device connected to the raspberry pi. Can you help us with this issue?
-
S.Grosjean
- Software Development

- Posts: 357
- Joined: Wed 4. Jul 2012, 17:02
Post
by S.Grosjean » Tue 3. May 2022, 11:24
Hi,
The PCAN M2 card needs to share DMA areas between the host and the card: for each CAN, the driver requests 2 x 4KB of such DMA area. It looks like your system lacks of such space.
Please have a look to topics that talk about tuning DMA for RPI4 (for example:
https://forums.raspberrypi.com/viewtopic.php?t=285068).
Regards,
— Stéphane
-
Magnus.Z
- Posts: 7
- Joined: Mon 2. May 2022, 11:24
Post
by Magnus.Z » Tue 3. May 2022, 16:26
Thanks for your answer. We took a look about how tuning DMA for RPI4. After a period of searching, we found this link
https://gist.github.com/geerlingguy/9d7 ... 54417429df where is mentioned how to configure the DMA size in "/boot/bcm2711-rpi-cm4.dtb" file. We have found the place where we should change the size in this file:
Code: Select all
scb {
compatible = "simple-bus";
#address-cells = <0x02>;
#size-cells = <0x02>;
ranges = <0x0 0x7c000000 0x0 0xfc000000 0x0 0x03800000>, <0x0 0x40000000 0x0 0xff800000 0x0 0x00800000>, <0x6 0x00000000 0x6 0x00000000 0x2 0x00000000>, <0x0 0x00000000 0x0 0x00000000 0x0 0xfc000000>;
dma-ranges = <0x00 0x00 0x00 0x00 0x04 0x00>;
phandle = <0xde>;
pcie@7d500000 {
compatible = "brcm,bcm2711-pcie";
reg = <0x00 0x7d500000 0x00 0x9310>;
device_type = "pci";
#address-cells = <0x03>;
#interrupt-cells = <0x01>;
#size-cells = <0x02>;
interrupts = <0x00 0x93 0x04 0x00 0x94 0x04>;
interrupt-names = "pcie\0msi";
interrupt-map-mask = <0x00 0x00 0x00 0x07>;
interrupt-map = <0x00 0x00 0x00 0x01 0x01 0x00 0x8f 0x04 0x00 0x00 0x00 0x02 0x01 0x00 0x90 0x04 0x00 0x00 0x00 0x03 0x01 0x00 0x91 0x04 0x00 0x00 0x00 0x04 0x01 0x00 0x92 0x04>;
msi-controller;
msi-parent = <0x2c>;
ranges = <0x02000000 0x0 0x00000000 0x6 0x00000000 0x2 0x00000000>;
dma-ranges = <0x2000000 0x00 0x00 0x00 0x00 0x00 0xc0000000>;
brcm,enable-ssc;
brcm,enable-l1ss;
phandle = <0x2c>;
pci@0,0 {
device-type = "pci";
#address-cells = <0x03>;
#size-cells = <0x02>;
ranges;
reg = <0x00 0x00 0x00 0x00 0x00>;
};
};
We tried different values for "#size-cells" but we are not getting this right. Do you have any advice after our searching?
Regards,
Magnus
-
Magnus.Z
- Posts: 7
- Joined: Mon 2. May 2022, 11:24
Post
by Magnus.Z » Wed 4. May 2022, 08:43
UPDATE!
We have changed the value of #size-cells in pcie@7d500000 struct from <0x02> to <0x04> and reboot the RPI4 that has raspbian
64bit and installed PCAN driver again. The output of "dmesg | grep pcan" is the following:
Code: Select all
evoy@raspberrypi:~/peak-linux-driver-8.14.0 $ dmesg | grep pcan
[ 79.742391] pcan: loading out-of-tree module taints kernel.
[ 79.744699] pcan: Release_20220124_n (le)
[ 79.744717] pcan: driver config [mod] [pci] [pec] [usb]
[ 79.746283] usbcore: registered new interface driver pcan
[ 79.746312] pcan: major 509.
We still can not see the connected device:
Code: Select all
evoy@raspberrypi:~/peak-linux-driver-8.14.0 $ ls -l /dev/pcan* | grep "^c"
ls: cannot access '/dev/pcan*': No such file or directory
evoy@raspberrypi:~/peak-linux-driver-8.14.0 $ ls -l /dev/pcan*
ls: cannot access '/dev/pcan*': No such file or directory
Do you have any advice that can help us after this update?
Regards,
Magnus
-
S.Grosjean
- Software Development

- Posts: 357
- Joined: Wed 4. Jul 2012, 17:02
Post
by S.Grosjean » Wed 4. May 2022, 09:36
Hello,
Looks like the M2 card is no more detected at all. You should at least see what you had before, that is:
Code: Select all
[ 4.507393] pcan 0000:01:00.0: enabling device (0000 -> 0002)
[ 4.507425] pcan 0000:01:00.0: PCAN-M.2 sub-system id 14h (4 channels)
[ 4.628624] pcan: PCAN-M.2: flash write failure (err -16)
[ 4.628671] pcan: PCB v2h FPGA v3.2.1 (mode 3)
Regards,
— Stéphane
-
S.Grosjean
- Software Development

- Posts: 357
- Joined: Wed 4. Jul 2012, 17:02
Post
by S.Grosjean » Thu 5. May 2022, 10:39
Hello,
FYI the mainline kernel includes for years now the peak_pciefd socket-can driver that is in charge to handle the PCAN M.2 card too.
I would also strongly suggest to configure its use in your kernel configuration (Networking support -> CAN bus subsystem support -> CAN Device Drivers -> PEAK-System PCAN-PCIe FD cards).
— Stéphane
-
Magnus.Z
- Posts: 7
- Joined: Mon 2. May 2022, 11:24
Post
by Magnus.Z » Thu 5. May 2022, 11:17
Hello again Stéphane,
We are already using the socket-can driver, but we want to use the chardev. We have tested the chardev with RPI cm4 with 32bit OS and it is working. The issue appeared when we tried using the same hardware but with 64bit OS.
We tried tuning the DMA but it was not successful. Where we should change the DMA size? and what we have to change it to?
Regards,
Magnus
-
S.Grosjean
- Software Development

- Posts: 357
- Joined: Wed 4. Jul 2012, 17:02
Post
by S.Grosjean » Thu 5. May 2022, 11:33
Hello,
This is important information that will allow us to move forward on this issue. So, to summarize, you confirm that under 5.15.32 the PCAN-M2:
- works with the socket-can driver in 32-bit and 64-bit modes
- works with the 32-bit pcan driver
- does not work with the 64-bit pcan driver
Right?
— Stéphane
-
Magnus.Z
- Posts: 7
- Joined: Mon 2. May 2022, 11:24
Post
by Magnus.Z » Thu 5. May 2022, 12:27
Under 5.15.32-v8+ 64bit the PCAN-M2:
- does not work with the socket-can and pcan driver
Under 5.15.32-v7l+ 32bit the PCAN-M2:
- works with the socket-can and the pcan driver
Regards,
Magnus
-
M.Maidhof
- Support

- Posts: 1751
- Joined: Wed 22. Sep 2010, 14:00
Post
by M.Maidhof » Mon 9. May 2022, 10:40
Updating the PCAN-M.2 card to the latest firmware 3.5.6 did solve the issue in the 64bit ARM environment.
regards
Michael