STM32MP1 FDCAN issues
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-02-19 10:44 AM
Hello,
I have the stm32mp157c-dk2 board and have connected two CAN Bus transceivers to it.
FDCAN1 is assigned to the A7 CPU and the FDCAN2 is assigned to the M4 CPU.
Both transmitters are connected to the same CAN bus. There is also a 3rd device connected to the same can bus.
When there is very low traffic on the can bus everything is fine.
All messages from all 3 CAN nodes can be received correctly everywhere.
When there gets little more traffic on the bus then the FDCAN2 on the M4 CPU starts to transmit wrong frames.
Also when the traffic goes low again the problem stays the same until reboot of the M4 CPU.
It is also hard to reproduce the issue. It sometimes takes a few hours or days for the issue to happen.
Here is the data on the bus when everything is ok:
# candump can0
can0 10000681 [3] 0A 00 05 <- Data from M4 CPU
can0 10000682 [3] 0A 00 19 <- Data from M4 CPU
can0 1810A080 [8] 80 00 00 18 00 01 00 00 <- Data from 3rd device
can0 18E050E5 [8] 00 00 00 00 08 00 00 00 <- Data from 3rd device
can0 02200000 [8] 10 04 00 00 00 00 00 00 <- Data from A7 CPU
can0 02200000 [8] 12 00 00 00 00 00 00 00 <- Data from A7 CPU
Here is the data on the bus when the M4 CPU gets a problem (all devices are still sending exactly the same frames):
# candump can0
can0 1F080681 [3] remote request <- Data from M4 CPU
can0 1F080682 [3] remote request <- Data from M4 CPU
can0 1810A080 [8] 80 00 00 18 00 01 00 00 <- Data from 3rd device
can0 18E050E5 [8] 00 00 00 00 08 00 00 00 <- Data from 3rd device
can0 02200000 [8] 10 04 00 00 00 00 00 00 <- Data from A7 CPU
can0 02200000 [8] 12 00 00 00 00 00 00 00 <- Data from A7 CPU
So the CAN ID 0x10000681 is getting to 0x1F080681 and also the payload is lost.
It looks like something goes wrong in the M4 can bus memory.
Any ideas?
- Labels:
-
STM32MP15 Lines
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-02-25 8:09 AM
Hi Artem,
I checked both V1.1.0 and V1.2.0 releases and I could not find the dts declaration you mentioned. Was it the devicetree generated by cubemx ?
I am very suspicious about your correction. If it is working now, that's great but I would like to understand why.
I/ CAN device is not supported into u-boot:
- so anyway u-boot declaration about can will have no effect in u-boot
- stm32mp157c.dtsi file used in u-boot and kernel is the same (u-boot copy/past this file from kernel devicetree)
- The assumption I have is that your kernel is using u-boot devicetree to boot (some config allow it for ex with grub). Do you think it is realistic ?
II/ CAN2 device is M4 side on your use case:
- this means CAN2 is never activated on A7 Side (in u-boot nor in kernel side)
- this also means CAN2 device is declared in the resource manager (see: stm32mp157c-m4-srm.dtsi for exemple) as a "m4_m_can2" node to reserve the resource for the M4.
see: https://wiki.st.com/stm32mpu/wiki/How_to_assign_an_internal_peripheral_to_a_runtime_context for more details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-02-29 1:50 PM
@Bernard PUEL​ Can you explain the proper way to generate device tree for stm32mp157c-dk2 board? For instance, I'm using the latest version of CubeMX (ver. 5.6.0) and:
- I select stm32mp157c-dk2 board in CubeMX board selector, then
- I click on initialize all hardware to their default values, then
- Enable FDCAN1 (disabled by default) for CortexM4, go to pins and define pin PA12 alternative function as FDCAN1_TX.
- Enable FDCAN2 (disabled by default) for CortexA7NS, go to pins and define pin PB12 alternative function as FDCAN2_RX.
When I generate the code, in the project directory there's nothing got created under DeviceTree directory, but I can see some device tree file created under CA7/DeviceTree directory. Should I use the device tree from CA7/DeviceTree directory for this project?
I've tried to compile it, but got the following error:
bash-4.4# dtc -I dts -O dtb stm32mp157c-mp1-cubemx-fdcan1-only-mx.dts > stm32mp157c-mp1-cubemx-fdcan1-only-mx.dtb
Error: stm32mp157c-mp1-cubemx-fdcan1-only-mx.dts:12.1-9 syntax error
FATAL ERROR: Unable to parse input tree
bash-4.4# head -22 stm32mp157c-mp1-cubemx-fdcan1-only-mx.dts
/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
/*
* Copyright (C) STMicroelectronics 2020 - All Rights Reserved
* Author: STM32CubeMX code generation for STMicroelectronics.
*/
/* For more information on Device Tree configuration, please refer to
* https://wiki.st.com/stm32mpu/wiki/Category:Device_tree_configuration
*/
/dts-v1/;
#include "stm32mp157c.dtsi"
#include "stm32mp157cac-pinctrl.dtsi"
#include "stm32mp157c-m4-srm.dtsi"
/* USER CODE BEGIN includes */
#include <dt-bindings/input/input.h>
#include <dt-bindings/mfd/st,stpmic1.h>
#include <dt-bindings/rtc/rtc-stm32.h>
/* USER CODE END includes */
/ {
bash-4.4# ls -la stm32mp157c.dtsi
-rw-rw-r-- 1 1001 1001 51226 Feb 29 11:20 stm32mp157c.dtsi
bash-4.4# ls -la stm32mp157cac-pinctrl.dtsi
-rw-r--r-- 1 1001 1001 1500 Feb 29 11:20 stm32mp157cac-pinctrl.dtsi
bash-4.4# ls -la stm32mp157c-m4-srm.dtsi
-rw-r--r-- 1 1001 1001 25607 Feb 29 11:20 stm32mp157c-m4-srm.dtsi
bash-4.4# ls -la dt-bindings/input/input.h
-rw-rw-r-- 1 1001 1001 538 Jan 9 04:19 dt-bindings/input/input.h
bash-4.4# ls -la dt-bindings/mfd/st,stpmic1.h
-rw-r--r-- 1 1001 1001 1180 Feb 29 11:20 dt-bindings/mfd/st,stpmic1.h
bash-4.4# ls -la dt-bindings/rtc/rtc-stm32.h
-rw-r--r-- 1 1001 1001 249 Feb 29 11:20 dt-bindings/rtc/rtc-stm32.h
Any idea what I'm doing wrong here?
-albertr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-02-29 2:18 PM
Ok, I realize that I need to use gcc to process all these include files, but what is the right syntax to execute it?
bash-4.4# gcc -I dt-bindings/input -I dts -I . -x assembler-with-cpp -o stm32mp157c-mp1-cubemx-fdcan1-only-mx.tmp stm32mp157c-mp1-cubemx-fdcan1-only-mx.dts
In file included from stm32mp157c-mp1-cubemx-fdcan1-only-mx.dts:17:
./dt-bindings/input/input.h:13:10: fatal error: linux-event-codes.h: No such file or directory
#include "linux-event-codes.h"
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
-albertr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-02-29 3:57 PM
Ok, I have figured out how to compile it. Basically, I've just added the new dts file produced by CubeMX to the Makefile in the linux-4.19.94/arch/arm/boot/dts directory and then executed `make dtbs` and it there was it.
-albertr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-01 10:01 AM
Yes, I have made the configuration with CubeMX and copied the relevant sections to the kernel dts file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-01 10:09 AM
I have modified the dts supplied with the kernel with the needed sections of the cubemx generated dts file and then recompiled the kernel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-01 10:25 AM
I am using an older u-boot version directly from u-boot - not the stm u-boot. Here you can see that the m_can is initialized differently:
It was also corrected in the commit "ARM: dts: stm32mp1: DT alignment with kernel v5.4" so the upstream u-boot will correctly handle the can bus controller.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-01 11:48 PM
Yes Artem, I can see it. But in ST boot sequence the nodes declared in u-boot for m_can1 and 2 are not used. So anyway this wrong declaration should not change anything.
So probably your Kernel is using u-boot dts to boot .... anyway, no issue here as now it works on your side.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-01 11:54 PM
Ok fine. It is convenient to use yocto SDK to build your BSP with the dts generated by CubeMx.
You may have a look to this article for more details: https://wiki.st.com/stm32mpu/wiki/STM32MP1_Developer_Package
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-09 2:28 AM
Hi, I'm having some issues to make FDCAN working on Cortex-M4, could you please share your sources?
Thank you!
Kind Regards
Andrea
