cancel
Showing results for 
Search instead for 
Did you mean: 

FDCAN in production mode is not working

TArre.1
Associate III

Hi!

I am using a STM32MP157C-DK2 board to communicate via CAN. To do this, I have created a program in STM32CubeIDE and set the FDCAN parameters:

  • Classic mode.
  • 150KB/s nominal baud rate.
  • HSE clock source (24MH)

0693W00000WLXyJQAX.png 

I have been testing in engineering mode and I was able to receive and send CAN messages (I have connected to an IXXAT device).

My problem starts when I try to do it in production mode:

  • I cannot send and receive messages

I do not know if I forgot to set a clock or something to enable FDCAN.

Can someone help me please?

Thanks!

4 REPLIES 4
PatrickF
ST Employee

Hi @TArre.1​ 

Root clocks (i.e. PLLs, mux) and power supplies are managed by uBoot/Linux.

In order to control them properly, the Device Tree should contain resources required by your Cortex-M4 FW. Also, the resource manager should be enabled.

These are usually configured within CubeMx.

See https://wiki.st.com/stm32mpu/wiki/How_to_configure_system_resources

and https://wiki.st.com/stm32mpu/wiki/Resource_manager_for_coprocessing

and https://wiki.st.com/stm32mpu/wiki/How_to_assign_an_internal_peripheral_to_a_runtime_context

Regards.

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
TArre.1
Associate III

Hi @PatrickF​ , thank you for your reply!

I have created the device tree in CubeMx. After reading all the wiki pages, i have verified in my program the following parameters (kernel .dts):

m4_fdcan1_pins_mx: m4_fdcan1_mx-0 {

pins {

pinmux = <STM32_PINMUX('A', 11, RSVD)>, /* FDCAN1_RX */

<STM32_PINMUX('A', 12, RSVD)>; /* FDCAN1_TX */

&m4_m_can1{

pinctrl-names = "default";

pinctrl-0 = <&m4_fdcan1_pins_mx>;

status = "okay";

&m4_rproc{

m4_system_resources{

status = "okay";

&m4_m_can1{

pinctrl-names = "default";

pinctrl-0 = <&m4_fdcan1_pins_mx>;

status = "okay";

I think I have all the parameters set correctly. Is there any other step I have to do?

Thanks!

PatrickF
ST Employee

Hi,

note that clocks should be defined in TF-A DT (as well as in uBoot and linux kernel DT).

Check if fdcan_k is from right source: cat /sys/kernel/debug/clk/clk_summary

If not, check if DT is what you expect for FDCAN_CK, e.g. https://github.com/STMicroelectronics/arm-trusted-firmware/blob/v2.6-stm32mp/fdts/stm32mp15xx-dkx.dtsi#L254

Check in your DT that you did not have status = "okay" on &m_can1 node.

Check in your M4 code that you skip the right init when in production mode but still have somewhere a code that enable the FDCAN clocks, e.g. __HAL_RCC_FDCAN_CLK_ENABLE().

Check in your M4 code that you still have GPIO mux for FDCAN pins.

Regards

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
TArre.1
Associate III

hi @PatrickF​ 

In order to change the clocks, do I have to create my own machine?

I have checked the clocks with the command "cat /sys/kernel/debug/clk/clk_summary" and I have seen that the configuration is not the same as the one I have designed in the STM32CubeIDE:

  • "cat /sys/kernel/debug/clk/clk_summary" shows the following:

 clock                        enable_cnt prepare_cnt       rate  accuracy  phase

----------------------------------------------------------------------------------------

clk-hse                                 1           1   24000000         0 0 

  ck_hse                               7           7   24000000         0 0 

     ck_hse_rtc                        0           0    1000000         0 0 

     stgen_k                           1           1   24000000         0 0 

     usbphy_k                          1           1   24000000         0 0 

     ck_per                            1           1   24000000         0 0 

        adc12_k                        1           1   24000000         0 0 

     ref4                              1           1   24000000         0 0 

        pll4                           1           1  594000000         0 0 

           pll4_r                      0           0   74250000         0 0 

           pll4_q                      1           1   31263158         0 0 

              ltdc_px                  1           1   31263158         0 0 

              dsi_px                   0           0   31263158         0 0 

              fdcan_k                  0           0   31263158         0 0 

  • In my desing the FDCAN clock is connected to HSE as it can be seen above

I'm thinking that maybe the FDCAN clock is not activated when I turn on the board in production mode

Thanks!