cancel
Showing results for 
Search instead for 
Did you mean: 

FDCAN - No buffer space available

tj5
Associate

I'm trying to run STM32MP1 with two CAN FD drivers connected to PD0/1 and PB5/13.

I have connected saleae analyzer to all four TX, RX lines and there is no changes during candsend command. I got only " write: No buffer space available" message.

How to properly run CAN bus on STM32MP1 ?

root@txmp-1530:~# ifconfig -a
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:51
 
can1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:53
 
 
root@txmp-1530:~# ip link set can0 type can bitrate 125000
root@txmp-1530:~# ip link set can0 up
root@txmp-1530:~# ip link set can1 type can bitrate 125000
root@txmp-1530:~# ip link set can1 up
root@txmp-1530:~# cansend can1 5A1#11.22.33.44.55.66.77.88
interface = can1, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
write: No buffer space available
root@txmp-1530:~# cansend can0 1 2 3 4 5 6 7 8 -i 200
interface = can0, family = 29, type = 3, proto = 1
write: No buffer space available
root@txmp-1530:~#
root@txmp-1530:~#
root@txmp-1530:~# ip -details link show can0
2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
    link/can  promiscuity 0 minmtu 0 maxmtu 0
    can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
          bitrate 125000 sample-point 0.875
          tq 41 prop-seg 83 phase-seg1 84 phase-seg2 24 sjw 1
          m_can: tseg1 2..256 tseg2 1..128 sjw 1..128 brp 1..512 brp-inc 1
          m_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..32 dbrp-inc 1
          clock 24000000numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
root@txmp-1530:~# ip -details link show can1
3: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
    link/can  promiscuity 0 minmtu 0 maxmtu 0
    can state ERROR-ACTIVE (berr-counter tx 0 rx 121) restart-ms 0
          bitrate 125000 sample-point 0.875
          tq 41 prop-seg 83 phase-seg1 84 phase-seg2 24 sjw 1
          m_can: tseg1 2..256 tseg2 1..128 sjw 1..128 brp 1..512 brp-inc 1
          m_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..32 dbrp-inc 1
          clock 24000000numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
root@txmp-1530:~#
root@txmp-1530:~# dmesg | grep -i can
[    0.079632] of_get_named_gpiod_flags: can't parse 'gpios' property of node '/regulator-3v3[0]'
[    0.079656] of_get_named_gpiod_flags: can't parse 'gpio' property of node '/regulator-3v3[0]'
[    0.080265] of_get_named_gpiod_flags: can't parse 'gpios' property of node '/regulator-usbh-vbus[0]'
[    0.080831] of_get_named_gpiod_flags: can't parse 'gpios' property of node '/regulator-usbotg-vbus[0]'
[    0.932645] slcan: serial line CAN interface driver
[    0.936946] slcan: 10 dynamic interface channels.
[    0.941519] CAN device driver interface
[    0.945798] cc770: CAN netdevice driver
[    0.949915] stm32mp157-pinctrl soc:pin-controller@50002000: request pin 48 (PD0) for 4400e000.can
[    0.949961] stm32mp157-pinctrl soc:pin-controller@50002000: request pin 49 (PD1) for 4400e000.can
[    0.950100] m_can_platform 4400e000.can: sidf 0x0 0 xidf 0x0 0 rxf0 0x0 32 rxf1 0x900 0 rxb 0x900 0 txe 0x900 2 txb 0x910 2
[    0.950995] m_can_platform 4400e000.can: m_can device registered (irq=51, version=32)
[    0.957469] stm32mp157-pinctrl soc:pin-controller@50002000: request pin 48 (PD0) for 4400e000.can
[    0.957506] stm32mp157-pinctrl soc:pin-controller@50002000: request pin 49 (PD1) for 4400e000.can
[    0.957920] stm32mp157-pinctrl soc:pin-controller@50002000: request pin 29 (PB13) for 4400f000.can
[    0.957964] stm32mp157-pinctrl soc:pin-controller@50002000: request pin 21 (PB5) for 4400f000.can
[    0.958090] m_can_platform 4400f000.can: sidf 0x1400 0 xidf 0x1400 0 rxf0 0x1400 32 rxf1 0x1d00 0 rxb 0x1d00 0 txe 0x1d00 2 txb 0x1d10 2
[    0.958928] m_can_platform 4400f000.can: m_can device registered (irq=53, version=32)
[    0.965484] stm32mp157-pinctrl soc:pin-controller@50002000: request pin 21 (PB5) for 4400f000.can
[    0.965517] stm32mp157-pinctrl soc:pin-controller@50002000: request pin 29 (PB13) for 4400f000.can
[    0.965723] sja1000 CAN netdevice driver
[    1.065720] of_get_named_gpiod_flags: can't parse 'snps,reset-gpios' property of node '/soc/ethernet@5800a000[0]'
[    1.065747] of_get_named_gpiod_flags: can't parse 'snps,reset-gpio' property of node '/soc/ethernet@5800a000[0]'
[    1.069057] of_get_named_gpiod_flags: can't parse 'reset-gpios' property of node '/soc/ethernet@5800a000/mdio0/ethernet-phy@0[0]'
[    1.069091] of_get_named_gpiod_flags: can't parse 'reset-gpio' property of node '/soc/ethernet@5800a000/mdio0/ethernet-phy@0[0]'
[    1.191497] stm32f7-i2c 5c009000.i2c: can't request DMA tx channel
[    1.191509] stm32f7-i2c 5c009000.i2c: can't use DMA
[    1.204249] stm32mp157-pinctrl soc:pin-controller@50002000: pin PD0 already requested by 4400e000.can; cannot claim for 48004000.sdmmc
[    1.251661] of_get_named_gpiod_flags: can't parse 'wp-gpios' property of node '/soc/sdmmc@58007000[0]'
[    1.251688] of_get_named_gpiod_flags: can't parse 'wp-gpio' property of node '/soc/sdmmc@58007000[0]'
[    1.327510] of_get_named_gpiod_flags: can't parse 'wp-gpios' property of node '/soc/efuse@5c005000[0]'
[    1.327537] of_get_named_gpiod_flags: can't parse 'wp-gpio' property of node '/soc/efuse@5c005000[0]'
[    1.333948] can: controller area network core (rev 20170425 abi 9)
[    1.344505] can: raw protocol (rev 20170425)
[    1.348722] can: broadcast manager protocol (rev 20170425 t)

Here is full FDT: https://anotepad.com/notes/7kdny7xr

3 REPLIES 3
TBind.2
Associate II

Hey tj5,

have you found a solution to you problem? It seems that we have a similar problem

Greetings Tom

ASuar.1
Associate III

I'm also having this issue any resolution? From what I can tell it doesn't even seem like the packet is even getting to the pin. I've got a scope connected and never seem to get any activity.

TBind.2
Associate II

Not really a solution but we found out, that the pin is indeed not set up to FDCAN and is set to analog instead.

/sys/kernel/debug/pinctrl/soc:pin-controller@50002000# cat pinconf-pins | grep 'PA11\|PD1'
pin 11 (PA11): analog 
pin 49 (PD1): analog 

This setting seems to be the result of the two different modes(default, sleep) described in the device tree which was generated by the CubeMx software.

(At least it seems to be two different modes)

&m_can1{
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&fdcan1_pins_mx>;
	pinctrl-1 = <&fdcan1_sleep_pins_mx>;
	status = "okay";
 
	/* USER CODE BEGIN m_can1 */
	/* USER CODE END m_can1 */
};
fdcan1_pins_mx: fdcan1_mx-0 {
		pins1 {
		pinmux = <STM32_PINMUX('A', 11, AF9)>; /* FDCAN1_RX */
		bias-disable;
	};
	pins2 {
		pinmux = <STM32_PINMUX('D', 1, AF9)>; /* FDCAN1_TX */
		bias-disable;
		drive-push-pull;
		slew-rate = <1>;
	};
};
fdcan1_sleep_pins_mx: fdcan1_sleep_mx-0 {
	pins {
		pinmux = <STM32_PINMUX('A', 11, ANALOG)>, /* FDCAN1_RX */
				 <STM32_PINMUX('D', 1, ANALOG)>; /* FDCAN1_TX */
	};
};

It is not clear to me, why the sleep mode is used instead of the default mode. But changing the sleep mode configuration to also use FDCAN, to check if that is the actual problem, results in the can interface to work as expected and we could observe the output via a scope.

fdcan1_sleep_pins_mx: fdcan1_sleep_mx-0 {
	pins {
		pinmux = <STM32_PINMUX('A', 11, AF9)>, /* FDCAN1_RX */
				 <STM32_PINMUX('D', 1, AF9)>; /* FDCAN1_TX */
	};
};
/sys/kernel/debug/pinctrl/soc:pin-controller@50002000# cat pinconf-pins | grep CAN
pin 11 (PA11): alternate 9 (FDCAN1_RX) - push pull - floating - low speed
pin 49 (PD1): alternate 9 (FDCAN1_TX) - push pull - floating - medium speed

As to why sleep-mode is used instead of the default mode is beyond my understanding, maybe someone can provide some information as to why this happens and who decides which mode to use, or why we need to different modes in the first place?