cancel
Showing results for 
Search instead for 
Did you mean: 

How to setup FDCAN on STM32MP157F-DK2?

SScar.2
Senior

Hi everyone!

I'm here with my devkit and trying to have FDCAN working properly! I compiled the Yocto distribution for the board and I followed all the tutorials in the wiki ( https://wiki.st.com/stm32mpu/wiki/Category:CAN ) and here's what I came up with:

I initialized m_can1

&m_can1 {

pinctrl-names = "default", "sleep";

pinctrl-0 = <&m_can1_pins_b>;

pinctrl-1 = <&m_can1_sleep_pins_b>;

status = "okay";

};

I used the pins_b configuration because looking at the datasheet they were the only possible exposed pins on the PI_GPIO extender (CN2) on the board (overwriting I2C5 pins for the Arduino). I also removed the pullup resistors for i2c (R166 and R167).

On the kernel side I tried the loopback and seems to work fine:

root@stm32mp1:~# ip link set can0 up type can bitrate 1000000 dbitrate 2000000 fd on

[ 1602.982564] m_can_platform 4400e000.can can0: bitrate error 0.3%

[ 1602.988958] m_can_platform 4400e000.can can0: bitrate error 0.3%

[ 1602.994593] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready

(the second bitrate error is different from the tutorials...) and seems working ok

root@stm32mp1:~# candump can0 -L &

root@stm32mp1:~# cansend can0 300#AC.AB.AD.AE.75.49.AD.D1

(1669130989.509567) can0 300#ACABADAE7549ADD1

(1669130989.509533) can0 300#ACABADAE7549ADD1

Now, I'm trying to get some data on the physical bus but it seems not working, I attached the oscilloscope on the pin PA12 (EXP_GPIO2) which should be the FDCAN tx, and enabled the bus as the example :

ip link set can0 up type can bitrate 1000000 dbitrate 2000000 fd on

But I can see absolutely nothing on the pin if I send any packet with cansend.

I also tried to attach a proper transceiver ( I used mikro CAN FD 3 click https://www.mikroe.com/can-fd-3-click --> TLE9251V based) , and after the cansend, the bus goes instantly bus-off :

root@stm32mp1:~# cansend can0 01a#11223344AABBCCFF

[ 706.810510] m_can_platform 4400e000.can can0: bus-off

Do you have any suggestions to make the protocol work properly? Do you have tried it yourself?

Huge thanks!

Simone

10 REPLIES 10

of course! the 5v pin, i have been hours scratching my head, i was only connecting 3v3 :,(

we dont need to firmware by ourselves, lets talk