EPC-R3720 CAN control

I am writing a program that executes CAN control on the Cortex-M7 of the EPC-R3720.

\mcuxsdk-2.12.0\examples\evkmimx8mp\driver_examples\flexcan
\mcuxsdk-2.12.0\examples\evkmimx8mp\driver_examples\canfd
I installed the above sample code on the M7 and checked the connection (PEAK IPEH), but the connection is not complete.

The Linux side is the same as when it was shipped (Linux imx8mprsb3720a1),
but do I need to change the device tree or something?

If you have any information, please let me know.

Hi~

Thanks for interest in the Advantech products. There is an example for running “imx8mp_m7_TCM_rpmsg_lite_str_echo_rtos.bin” that you can reference. It needs to modify the device tree to arrange the resource for the M7.
EPC-3720 M7 Debug - Technical Supports / Software - Advantech AIM-Linux Community

@Jems_Cheng
Thank you for contacting us.
I am able to run the M7 program, but do you have any information necessary to create a program to control the CAN controller (CAN1/CAN2)?
I can currently transmit via CAN2, but am unable to receive.

Hi~

There is no information to create a program to control the CAN through M7. We only test by running RPMsg and FreeRTOS with specific steps for loading and debugging but not directly accessing CAN control.

For running RPMsg, there is a need to include a specific Device Tree Blob (DTB) file, as mentioned in the context of running RPMsg on the Cortex-M7.

You might consider a similar approach for CAN control, implying that adjusting or including a specific DTB related to CAN might be necessary if your current setup doesn’t work. Specifically, there was a mention of creating a new DTB file for RPMsg (imx8mp-rsb3720-a1-rpmsg.dtb) by referencing a similar file and then building it for the RSB-3720 for testing.

Sending and receiving via CAN1 (COM/CAN) is working properly, but when sending via CAN2 (UIO-4034), IFLAG1 and IFLAG2 are not set and the completion of transmission cannot be confirmed. If you have any information on the difference between CAN1 and CAN2, please let me know.

@Jems_Cheng
For example, where are the dts and dti files that make up imx8mp-rsb3720-a1-rpmsg.dtb? If I knew where to get them, I think it would be possible to build a new dtb.

Hi~

There is no different for the CAN2(UIO-4034). Please check the screenshot below, bothe CAN1 and CAN2 is output from CPU.
RSB-3720_DS(080122)20220801131816.pdf (advantech.com)
image

For CAN test, please check the user manual 3.14
image

The imx8mp-rsb3720-a1-rpmsg.dts file is I copy from [imx8mp-evk-rpmsg.dts] and modify it for RSB-3720. It can reference the kernel source v5.4.70_2.3.0 at the link below,
(linux-imx/arch/arm64/boot/dts/freescale/imx8mp-evk-rpmsg.dts at adv_5.4.70_2.3.0 · ADVANTECH-Corp/linux-imx · GitHub)
linux-imx/arch/arm64/boot/dts/freescale at adv_5.4.70_2.3.0 · ADVANTECH-Corp/linux-imx (github.com)

@Jems_Cheng
Thank you for providing this information.
I have checked the wiring diagram.
I have also performed unit testing (connecting each port) and confirmed that it works properly.
However, as I mentioned at the beginning of my question, my development environment is a problem that occurs on a Cortex-M7 (IFLAG for CAN2 does not turn ON).
Is it possible to control it with Cortex-M7 (FreeRTOS) in the same way as with Linux?

Hi~

From previously reply, we have verified the CAN function can work well on A-core without any problem. For control it on M-core M7, it is the CPU layer application, so you may search the resource on the CPU vendor NXP website to get more development document.
Cortex M7 software development on imx8m plus - NXP Community
i.MX 8M Plus | Cortex-A53/M7 | NXP Semiconductors

There is kernel source include rpmsg dts/dtb files have provided for your reference and you might consider a similar approach for CAN control, implying that adjusting or including a specific DTB related to CAN might be necessary if your current setup doesn’t work. Specifically, there was a mention of creating a new DTB file for RPMsg (imx8mp-rsb3720-a1-rpmsg.dtb) by referencing a similar file and then building it for the RSB-3720 for testing.

In the kernel source, it can find the rpmsg dts file for NXP mx8mp evk(imx8mp-rsb3720-a1-rpmsg.dts also based on this dts but change to include the imx8mp-rsb3720-a1.dts):
image

There is mention which resource can be used for M7. you can try to modify and develop it for your applications.
linux-imx/arch/arm64/boot/dts/freescale/imx8mp-evk-rpmsg.dts at adv_5.4.70_2.3.0 · ADVANTECH-Corp/linux-imx (github.com)

@Jems_Cheng
Thank you for providing this information.
I tried making the following changes to the decompiled [imx8mp-rsb3720-a1-rpmsg.dtb] using DTC.
can@308c0000 {
/status = “disabled”;/
status = “okey”;
}
I made no changes to can2.
However, the situation remains the same and the IFLAG for CAN2 does not change.
CAN1 can be sent and received from the M7 without any problems.
It seems that what is written in [imx8mp-evk-flexcan2.dts] is reflected in a1-rpmsg.
I’m really in a difficult position.

Hi~

Yes, in imx8mp-rsb3720-a1.dts file, the flexcan2 has described in this file for A core use.
linux-imx/arch/arm64/boot/dts/freescale/imx8mp-rsb3720-a1.dts at adv_5.4.70_2.3.0 · ADVANTECH-Corp/linux-imx (github.com)

In previous reply, I provide the information that I copy the rpmsg dts file from NXP mx8mp evk and develop imx8mp-rsb3720-a1-rpmsg.dts for the RSB-3720. The setting is the same with NXP mx8mp evk that only disable flexcan1 in this file. So, you should try to disable flexcan2 for testing in your applications.

Here is useful information that you also can reference:
MX8MP list of peripherals available from Cortex M7 - NXP Community

@Jems_Cheng
In the “imx8mp-rsb3720-a1.dts” you provided, both can1 and can2 are set to “okay”, so I think that this is a resource setting on the Cortex-A side. Even with this setting, CAN1 can be controlled from the Cortex-M7. Only CAN2 does not have the transmission completion flag (IFLAG) turned ON.
I have also built a DTB, but I am not getting good results.

@Jems_Cheng
Regarding the issue of CAN-2 not working (unable to transmit), let me confirm some basics. The catalog specifications state that CAN-1 is CAN-FD and CAN-2 is CAN2.0B. Can we assume that the control method, port control, interrupt control, MB control, etc. are the same for CAN-1/CAN-2?

@Jems_Cheng
Just to confirm, could you please tell me where the [imx8mp-rsb3720-a1-rpmsg.dts] file is located? Is it the same as [mx8mp-evk-rpmsg.dts]?

Hi~

Here already provided the information where the [imx8mp-rsb3720-a1-rpmsg.dts] file is.

EPC-3720 M7 Debug - Technical Supports / Software - Advantech AIM-Linux Community

For convenient to use, I have provided the imx8mp-rsb3720-a1-rpmsg.dts in this post. you can download it and copy to the kernel source and modify for your application.

Download from the link here:

@Jems_Cheng
Sorry, I overlooked that. Thank you

@Jems_Cheng
I still haven’t solved the problem with CAN2 transmission. I’ve tried tweaking the DeviceTree, but data is being output. For some reason, when I enable interrupts with (FLEXCAN_EnableMbInterrupts), an interrupt occurs, but the contents of the ESR1 register are [0x20000080], bit 29 is 1. Bit 29 of ESR1 is reserved, so it should not be 1. Bit 7 = 1 indicates IDLE. Why is the reserved bit turned ON? CAN2 is CAN-Bus 2.0B specification, so does it require special settings? I’ve spent a lot of time trying to solve the problem, but I’m still stuck.
The sample I’m using is [mcuxsdk-2.12.0\examples\evkmimx8mp\driver_examples\flexcan\interrupt_transfer].

Hi~

Here is some information for reference:
I try to create a “imx8mp-rsb3720-a1-rpmsg_can2.dtb” file that disables flexcan2.

It can download from the link below for take a try.
RSB-3720_M7
image

use dtc command to check the dtb file and the flexcan2(can@308d0000) has beed disabled:
dtc -W no-unit_address_vs_reg -W no-unit_address_format -W no-simple_bus_reg -W no-avoid_unnecessary_addr_size -W no-unique_unit_address -W no-graph_child_address -I dtb imx8mp-rsb3720-a1-rpmsg_can2.dtb | grep -n14 can@

Here is the information for the pinmux of the flexcan2. Check on the “imx8mp-rsb3720-a1.dts” the flexcan2 use two pins below:
“MX8MP_IOMUXC_SAI5_MCLK__CAN2_RX”: AF14
“MX8MP_IOMUXC_SAI5_RXD3__CAN2_TX”: AE14
linux-imx/arch/arm64/boot/dts/freescale/imx8mp-rsb3720-a1.dts at adv_5.4.70_2.3.0 · ADVANTECH-Corp/linux-imx (github.com)

Check on NXP MCUXpresso Config Tools: The flexcan2 also use these two pins.
Pins Tool | MCUXpresso SDK Builder (nxp.com)

Check the MCUXpresso SDK_2_15_000_MIMX8ML8…, the flexcan samples are all demo for using the CAN1. It should try to modify it for the CAN2 accordingly.

@Jems_Cheng
Thank you for contacting us.
Please confirm.

  1. About the setting of the Stby signal
    [imx8mp-evk.dts]Line954-Line958
    [SDK_2_15_000_MIMX8ML8xxxKZ\boards\evkmimx8mp\driver_examples\flexcan\interrupt_transfer] pin_mux.c Line61-65
    Is the CAN1-Stby signal set above also valid for the EPC-R3720?
    Also, is CAN2-Stby [IOMUXC_SAI2_MCLK_GPIO4_IO27] correct?
    It is written in [imx8mp-evk.dts]Line960-964.
  2. Why is both CAN1/2 set to “Disabled” in the DTB? (A5: Is it because the resources are shared with Linux, making the A53 side unavailable?

Hi~

  1. Compare the imx8mp-rsb3720-a1.dts and imx8mp-evk.dts file.
    The CAN1_STBY and CAN2_STBY are not available on RSB-3720.
    The “SPDIF_EXT_CLK” has been connect to “UART1_WAKE#” pin:

The SAI2_MCLK has been connect to “GPIO_LED” pin:

  1. Please reference the link below:
    i.MX8M Plus RPMsg Device Tree Entries (Cortex-M7/A53) with imx_rpmsg_tty driver - NXP Community

And here can provide the answer:
MX8MP list of peripherals available from Cortex M7 - NXP Community