cancel
Showing results for 
Search instead for 
Did you mean: 

Enable CANFD on STM32mp135f-dk

alzj
Associate II

Hi st team,

I am using the STM32MP135f-DK board and I want to enable CANFD drivers. First I checked if the CAN drivers are enabled in menuconfig using:

 bitbake virtual/kernel -c menuconfig (everything has been selected)

Then I went to ~/STM32MPU_workspace/STM32MP1-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1/tmp-glibc/work-shared/stm32mp1/kernel-source/arch/arm/boot and modified the files as follows:

stm32mp13-pinctrl.dtsi (configured the pins PG1 (pin 16 CN8) for TX and PG3 (pin 18 CN8) for RX)

fdcan2_pins_mx: fdcan2_mx-0 {
pins1 {
pinmux = <STM32_PINMUX('G', 1, AF9)>; /* FDCAN2_TX */
bias-disable;
drive-push-pull;
slew-rate = <0>;
};
pins2 {
pinmux = <STM32_PINMUX('G', 3, AF9)>; /* FDCAN2_RX */
bias-disable;
};
};

fdcan2_sleep_pins_mx: fdcan2_sleep_mx-0 {
pins {
pinmux = <STM32_PINMUX('G', 1, ANALOG)>, /* FDCAN2_TX */
<STM32_PINMUX('G', 3, ANALOG)>; /* FDCAN2_RX */
};
};

tm32mp135f-dk.dts added:

&m_can2{
pinctrl-names = "default", "sleep";
pinctrl-0 = <&fdcan2_pins_mx>;
pinctrl-1 = <&fdcan2_sleep_pins_mx>;
status = "okay";
};

 stm32mp133.dtsi (set can status to “okay”)

m_can2: can@4400f000 {
compatible = "bosch,m_can";
reg = <0x4400f000 0x400>, <0x44011000 0x2800>;
reg-names = "m_can", "message_ram";
interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "int0", "int1";
clocks = <&scmi_clk CK_SCMI_HSE>, <&rcc FDCAN_K>;
clock-names = "hclk", "cclk";
bosch,mram-cfg = <0x1400 0 0 32 0 0 2 2>;
status = "okay";
};

 After modifying the files, I run

bitbake virtual/kernel

Then I went to the generated .dtb files and copied the files stm32mp135f-dk.dtb stm32mp135f-dk-a7-examples.dtb uImage using spc to root@<board ip address>:/boot. I then run

cd /boot; sync; systemctl reboot 

I was then able to enable can on board. Here you can see that can0 has been configured:

root@stm32mp1:~# ip link set can0 up type can bitrate 500000
root@stm32mp1:~# ip link set can0 up
root@stm32mp1:~# ip 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
root@stm32mp1:~# ifconfig
can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING 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:50

The problem is that I am unable to send a message. I wrote a simple python code that just periodically sends an 8 byte msg and I can run it without errors but I am not able to send messages even though there is no error. This means I cannot receive the message on the other device. My first thought was that the hardware (CAN interface) that I connected to the board was not working, but that had no problems. So I tried to check PG1 (pin 16 CN8) FDCAN2_TX directly with an oszilloscope and there is nothing to see (signal is always high 3.3V). No message is transmitted.
I also did the Hardware self-check using loopback and this worked.

root@stm32mp1:~# ip link set can0 type can bitrate 1000000 dbitrate 2000000 fd on loopback on
root@stm32mp1:~# candump can0 -L &
root@stm32mp1:~# read: Network is down
[1]+ Done(1) candump can0 -L
root@stm32mp1:~# ip link set can0 up
root@stm32mp1:~# candump can0 -L &
root@stm32mp1:~# cansend can0 300#AC.AB.AD.AE.75.49.AD.D1
(1717592324.102885) can0 300#ACABADAE7549ADD1
(1717592324.102856) can0 300#ACABADAE7549ADD1

So my question is, are the steps I took to enable CAN correct or should I do it in a different way?

 

Best regards,
Arjan

1 ACCEPTED SOLUTION

Accepted Solutions
ngoctoan150699
Associate III

u should add  clocks = <&scmi_clk CK_SCMI_HSE>, <&rcc FDCAN_K>;  into

&m_can2{ pinctrl-names = "default", "sleep"; pinctrl-0 = <&fdcan2_pins_mx>; pinctrl-1 = <&fdcan2_sleep_pins_mx>; status = "okay"; clocks = <&scmi_clk CK_SCMI_HSE>, <&rcc FDCAN_K>; };

ngoctoan150699_0-1717644003613.png

 

View solution in original post

2 REPLIES 2
ngoctoan150699
Associate III

u should add  clocks = <&scmi_clk CK_SCMI_HSE>, <&rcc FDCAN_K>;  into

&m_can2{ pinctrl-names = "default", "sleep"; pinctrl-0 = <&fdcan2_pins_mx>; pinctrl-1 = <&fdcan2_sleep_pins_mx>; status = "okay"; clocks = <&scmi_clk CK_SCMI_HSE>, <&rcc FDCAN_K>; };

ngoctoan150699_0-1717644003613.png

 

Hello @ngoctoan150699 ,

Thank you for your reply. Now everything works! 

Best regards