cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot get can0 interface to appear on STM32MP157f-dk2

IanY
Associate II

Hello,

I am trying to setup CANbus on the STM32MP157f-dk2 board, but I am unable to get any CAN interface to appear. I have installed the STM32MP1 OpenSTLinux Developer-Package onto the board, and I am using an SN65HVD230 transceiver.

First I tried enabling pins PB12 and PB13 for FDCAN2, and connecting the transceiver to GPIO pins 10 and 36 on the board.

For device tree configuration, I generated a device tree source file with STM32CubeMX and copied the pinctrl and m_can2 bindings from the generated file into "stm32mp157f-dk2.dts" located in the kernel sources. I then compiled the device tree using "make ARCH=arm dtbs". I then copy stm32mp157f-dk2.dtb to the board.

I attached the exact dts file I am using.


For driver configuration, I believe the BOSCH M_CAN driver is enabled by default, so I did not change anything in Menuconfig. Although I doubled checked that the selections were correct.

 

IanY_4-1715666366381.png

IanY_5-1715666429018.png

 


The can0 interface does not appear as an available network interface:

root@stm32mp1:~# ls /sys/class/net
end0  lo  usb0 wlan0


I also checked the log messages to see if the driver was properly set up:

root@stm32mp1:~# dmesg | grep CAN
[    0.310964] CAN device driver interface
[    0.361318] NET: Registered PF_CAN protocol family


Then I checked the device-tree on the board and it seems the device is enabled:

root@stm32mp1:/proc/device-tree/soc/etzpc@5c007000# cat can@4400f000/status
okay


Another thing I have tried is setting up FDCAN1 by adding the m_can1 binding to the end of "stm32mp157f-dk2.dts".

&m_can1 {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&m_can1_pins_b>;
pinctrl-1 = <&m_can1_sleep_pins_b>;
status = "okay";
};

This binding will set the pinctrl to pins PA11 and PA12, which connect to pins 5 and 3 of CN2 on the board. However, I am experiencing the exact same issue in this scenario. I see the same log messages as above, and confirmed that the can@4400e000 status is okay.


I started to wonder if maybe the interface will not be available if there is no transceiver connected? I have tried connecting my SN65HVD230 transceiver, but this does not seem to make any difference.

I am also wondering if there is a problem with how I am modifying the device tree sources? Or perhaps there are issues if some other devices are also using the same pins?

I noticed in the post https://community.st.com/t5/stm32-mpus-products/how-to-setup-fdcan-on-stm32mp157f-dk2/td-p/66594 the op said they removed the i2c pullup resistors connected to pins PA11 and PA12. I am assuming they mean they desoldered those resistors from the board? Is that really necessary?

Any help would be greatly appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
IanY
Associate II

In "stm32mp157c0dk2-scmi.dtsi" which was included from "stm32mp157f-dk2.dts", I found this binding:
&rcc {
compatible = "st,stm32mp1-rcc-secure", "syscon";
clock-names = "hse", "hsi", "csi", "lse", "lsi";
clocks = <&scmi_clk CK_SCMI_HSE>,
<&scmi_clk CK_SCMI_HSI>,
<&scmi_clk CK_SCMI_CSI>,
<&scmi_clk CK_SCMI_LSE>,
<&scmi_clk CK_SCMI_LSI>;
};


I then modified the m_can1 binding in "stm32mp157f-dk2.dts" so that the line:
"clocks = <&rcc CK_HSE>, <&rcc FDCAN_K>;"
would be replaced with
"clocks = <&scmi_clk CK_SCMI_HSE>, <&rcc FDCAN_K>;"

I attached my complete stm32mp157f-dk2.dts file.

This is the same solution as for this post:
https://community.st.com/t5/stm32-mpus-products/fdcan-can-not-start-no-clock-found/m-p/613570

After compiling with this change, the no clock found error went away and the can0 interface became available.

I still have no idea how the FDCAN_K property is used, or where it is defined.

View solution in original post

4 REPLIES 4
IanY
Associate II

Taking a closer look at this post https://community.st.com/t5/stm32-mpus-products/how-to-setup-fdcan-on-stm32mp157f-dk2/td-p/66594, it appears the op actually put the resisters back on the board, and another user also had success while leaving the resistors in place. So that answers one of my questions.


I built the kernel according to the instructions on this page: https://wiki.st.com/stm32mpu/wiki/Getting_started/STM32MP1_boards/STM32MP157x-DK2/Develop_on_Arm%C2%AE_Cortex%C2%AE-A7/Modify,_rebuild_and_reload_the_Linux%C2%AE_kernel

These instructions make no mention of building U-boot, OP-TEE, or T-FA. I have not even extracted the archives for these components, because I am not modifying them.

I am focusing now on enabling m_can1 as per the example on https://wiki.st.com/stm32mpu/wiki/FDCAN_device_tree_configuration

by appending these lines to the existing "stm32mp157f-dk2.dts" file in the kernel sources.

&m_can1 {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&m_can1_pins_b>;
pinctrl-1 = <&m_can1_sleep_pins_b>;
status = "okay";
};

After compiling the dtb and copying it to the board, I checked the kernel logs again with dmesg. This time I searched for "can" in lower case.


root@stm32mp1:~# dmesg | grep can
[ 0.372228] can: controller area network core
[ 0.372360] can: raw protocol
[ 0.372374] can: broadcast manager protocol
[ 0.372390] can: netlink gateway - max_hops=1
[ 2.101847] m_can_platform 4400e000.can: no clock found

The m_can1 binding defined in "stm32mp153.dtsi" contains this property.
clocks = <&rcc CK_HSE>, <&rcc FDCAN_K>;

But when I grep for "rcc CK_HSE" and "rcc FDCAN_K" in the kernel device tree sources, I don't get any results.

Where is the rcc binding defined? Do I need to modify the device tree sources for U-boot, OP-TEE, or T-FA to configure the RCC?

IanY
Associate II

In "stm32mp157c0dk2-scmi.dtsi" which was included from "stm32mp157f-dk2.dts", I found this binding:
&rcc {
compatible = "st,stm32mp1-rcc-secure", "syscon";
clock-names = "hse", "hsi", "csi", "lse", "lsi";
clocks = <&scmi_clk CK_SCMI_HSE>,
<&scmi_clk CK_SCMI_HSI>,
<&scmi_clk CK_SCMI_CSI>,
<&scmi_clk CK_SCMI_LSE>,
<&scmi_clk CK_SCMI_LSI>;
};


I then modified the m_can1 binding in "stm32mp157f-dk2.dts" so that the line:
"clocks = <&rcc CK_HSE>, <&rcc FDCAN_K>;"
would be replaced with
"clocks = <&scmi_clk CK_SCMI_HSE>, <&rcc FDCAN_K>;"

I attached my complete stm32mp157f-dk2.dts file.

This is the same solution as for this post:
https://community.st.com/t5/stm32-mpus-products/fdcan-can-not-start-no-clock-found/m-p/613570

After compiling with this change, the no clock found error went away and the can0 interface became available.

I still have no idea how the FDCAN_K property is used, or where it is defined.

xchen
Associate

Hi,

I had the same problem enabling the m_can1. 

I use the solution that modify the clock, the m_can1 bus is working, howerver, the DSI display is going wrong. 

I think it might be that the dsi and can share the same clock source.

Do you have the same problem or have any idea to fix this?

 

IanY
Associate II

I had actually removed the display for this project.

Perhaps if you check the discovery kit user manual UM2534 and the alternate function table in the STM32MP157f datasheet, you could find a different pair of CAN pins exposed on the development board. You could also try enabling m_can2 instead of m_can1.

Note the m_can1_pins_b property is defined in one of the pin control DTI files included from stm32mp157f-dk2.dts. So if you look in that DTI file you can find other pin combinations for m_can1 and m_can2.