Unable to enable CAN in IMX8QM-MEK for mek_8q_car

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to enable CAN in IMX8QM-MEK for mek_8q_car

1,478 Views
TAug
Contributor I

I am trying to enable CAN interfaces of i.MX8QM-MEK device using the "imx-automotive-11.0.0_1.1.0". I have done the below configurations,

 

  • Changed the status of below items in "imx8qm-mek-rpmsg.dts" to ‘status = "okay"’
    1. &reg_can01_en
    2. &reg_can01_stby
    3. &can0_lpcg
    4. &can1_lpcg
    5. &flexcan1
    6. &flexcan2
  • Added the below lines to the file "device/nxp/imx8q/mek_8q/automotive_addition_defconfig"

CONFIG_CC_CAN_LINK=y
CONFIG_CAN=y
CONFIG_CAN_RAW=y
CONFIG_CAN_BCM=y
CONFIG_CAN_GW=y
CONFIG_CAN_DEV=y
CONFIG_CAN_CALC_BITTIMING=y
CONFIG_CAN_FLEXCAN=y

  • Commented the below line in the file 'vendor/nxp/fsl-proprietary/uboot-firmware/imx8q_car/board-imx8qm.c'.

 

 

 

 

 

/*BRD_ERR(rm_set_resource_movable(pt_boot, SC_R_CAN_0,
            SC_R_CAN_2, SC_TRUE));*/
			
/*BRD_ERR(rm_set_pad_movable(pt_boot, SC_P_FLEXCAN0_RX,
            SC_P_FLEXCAN2_TX, SC_TRUE));*/

 

 

 

 

 

After flashing the build, the messages shown in dmesg | grep can are,

 

[ 1.680016] can: controller area network core (rev 20170425 abi 9)
[ 1.690682] can: raw protocol (rev 20170425)
[ 1.694956] can: broadcast manager protocol (rev 20170425 t)
[ 1.700620] can: netlink gateway (rev 20190810) max_hops=1

But the can0 device is not listed when 'ifconfig -a' command is run.

/dev/can0 is not showing.

Tried to run the command "# ip link set can0 type can bitrate 125000 triple-sampling on" and the output was 'Cannot find device "can0"'.

Can someone advice me on what is wrong with above configuration and how to correct it to enable the CAN?

0 Kudos
8 Replies

574 Views
zdenek_zadera
NXP Employee
NXP Employee

Hi @Lancelot ,

have you been successful when using the guide from Martin? Let me know if you struggle on some part.

Best Regards,

Zdenek

0 Kudos

838 Views
Lancelot
Contributor I

I am trying to enable CAN bus on a iMX8QM MEK board + MCIMX8-8X-BB Base Board using i.MX Android automotive-13.0.0_1.3.0 and fail.

None of the things TAug tried worked, neither the things suggested in these topics: 

https://community.nxp.com/t5/i-MX-Processors/imx8qm-mek-Ongoing-issue-with-CAN-bus-on-imx8qm-mek-boa...

https://community.nxp.com/t5/i-MX-Processors/CANBus-interface-for-i-MX8QM-MEK-board/m-p/1171974

What are we missing ? 

0 Kudos

773 Views
Lancelot
Contributor I

Elaborating on my previous post,

iMX8QM MEK board + MCIMX8-8X-BB Base Board + imx-automotive-13.0.0_1.3.0.tar.gz

I've done the following changes: 

1. Enabled the following modules @ imx8qm-mek-rpmsg.dts:

&reg_can01_en {
status = "okay";
};

&reg_can2_en {
status = "okay";
};

&reg_can01_stby {
status = "okay";
};

&reg_can2_stby {
status = "okay";
};

&can0_lpcg {
status = "okay";
};

&can1_lpcg {
status = "okay";
};

&can2_lpcg {
status = "okay";
};

&flexcan1 {
status = "okay";
};

&flexcan2 {
status = "okay";
};

&flexcan3 {
status = "okay";
};
 

 2. Commented out the CAN resources and pads from M4 @ vendor/nxp/fsl-proprietary/uboot-firmware/imx8q_car/board-imx8qm, as per this thread (https://community.nxp.com/t5/i-MX-Processors/CANBus-interface-for-i-MX8QM-MEK-board/m-p/1169857/high...  the CAN resources must be allocated to A core.

            /* List of resources */
            static const sc_rsrc_t rsrc_list[12U] =
            {
                SC_R_IRQSTR_M4_1,
                SC_R_UART_2,
                SC_R_MU_6B,
                SC_R_MU_7B,
                SC_R_MU_9B,
                SC_R_GPT_3,
                //RM_RANGE(SC_R_CAN_0, SC_R_CAN_2),
                SC_R_FSPI_0,
                SC_R_MU_12B,
                SC_R_M4_1_INTMUX,
                SC_R_GPIO_1
            };
            /* List of pads */
            static const sc_pad_t pad_list[8U] =
            {
                RM_RANGE(SC_P_M41_I2C0_SCL, SC_P_M41_GPIO0_01),
                RM_RANGE(SC_P_UART0_CTS_B, SC_P_UART0_RTS_B),
                //RM_RANGE(SC_P_FLEXCAN0_RX, SC_P_FLEXCAN2_TX),
                RM_RANGE(SC_P_QSPI0A_DATA0, SC_P_COMP_CTL_GPIO_1V8_3V3_QSPI0)
            };


3. I'm building with imx-make.sh, using target mek_8q_car-userdebug and I've noticed the following: 
- out/target/product/mek_8q/vendor_dlkm/lib/modules contains no CAN modules:

$ ls
at803x.ko
fb.ko
mlan.ko
phy-fsl-imx8-pcie.ko
snd-soc-simple-card.ko
spi-fsl-lpspi.ko
cfbcopyarea.ko
fb_notify.ko
moal.ko
phy-generic.ko
snd-soc-simple-card-utils.ko
spi-imx.ko
cfbfillrect.ko
fec.ko
modules.alias
snd-soc-bt-sco.ko
snd-soc-wm8960.ko
spi-slave-system-control.ko
cfbimgblt.ko
galcore.ko
modules.dep
snd-soc-cs42xx8-i2c.ko
snd-sof-imx8.ko
spi-slave-time.ko
cfg80211.ko
imx-common.ko
modules.load
snd-soc-cs42xx8.ko
snd-sof.ko
ulpi.ko
ci_hdrc_imx.ko
imx_dsp_rproc.ko
modules.softdep
snd-soc-fsl-asoc-card.ko
snd-sof-of.ko
usbmisc_imx.ko
ci_hdrc.ko
imx-pcm-dma.ko
mx3fb.ko
snd-soc-fsl-esai.ko
snd-sof-xtensa-dsp.ko
device_cooling.ko
imx_sc_thermal.ko
mxc_edid.ko
snd-soc-fsl-sai.ko
spi-bitbang.ko
fb_fence.ko
mac80211.ko
pci-imx6.ko
snd-soc-imx-audmux.ko
spidev.ko

- in addition, out/target/product/mek_8q/vendor/lib/modules is symlinked to fixed path /vendor_dlkm/lib/modules, rather than relative  ../../vendor_dlkm/lib/modules

$ ls -al | grep modules
modules -> /vendor_dlkm/lib/modules


After building with this config and flashing the board with uuu script, I checked for the can modules via lsmod and kernel config:

mek_8q:/ $ lsmod | grep can
1|mek_8q:/ $ zcat proc/config.gz | grep CAN
# CONFIG_NET_EMATCH_CANID is not set
CONFIG_CAN=y
CONFIG_CAN_RAW=y
CONFIG_CAN_BCM=y
CONFIG_CAN_GW=y
# CONFIG_CAN_J1939 is not set
# CONFIG_CAN_ISOTP is not set
# CAN Device Drivers
# CONFIG_CAN_VCAN is not set
# CONFIG_CAN_VXCAN is not set
# CONFIG_CAN_SLCAN is not set
CONFIG_CAN_DEV=y
CONFIG_CAN_CALC_BITTIMING=y
# CONFIG_CAN_FLEXCAN is not set
# CONFIG_CAN_GRCAN is not set
# CONFIG_CAN_KVASER_PCIEFD is not set
# CONFIG_CAN_XILINXCAN is not set
# CONFIG_CAN_C_CAN is not set
# CONFIG_CAN_CC770 is not set
# CONFIG_CAN_IFI_CANFD is not set
# CONFIG_CAN_M_CAN is not set
# CONFIG_CAN_PEAK_PCIEFD is not set
# CONFIG_CAN_SJA1000 is not set
# CONFIG_CAN_SOFTING is not set
# CAN SPI interfaces
# CONFIG_CAN_HI311X is not set
# CONFIG_CAN_MCP251X is not set
# CONFIG_CAN_MCP251XFD is not set
# end of CAN SPI interfaces
# CAN USB interfaces
# CONFIG_CAN_8DEV_USB is not set
# CONFIG_CAN_EMS_USB is not set
# CONFIG_CAN_ESD_USB2 is not set
# CONFIG_CAN_ETAS_ES58X is not set
# CONFIG_CAN_GS_USB is not set
# CONFIG_CAN_KVASER_USB is not set
# CONFIG_CAN_MCBA_USB is not set
# CONFIG_CAN_PEAK_USB is not set
# CONFIG_CAN_UCAN is not set
# end of CAN USB interfaces
# CONFIG_CAN_DEBUG_DEVICES is not set
# end of CAN Device Drivers
# CONFIG_SCSI_SCAN_ASYNC is not set
# CONFIG_PHY_CAN_TRANSCEIVER is not set
mek_8q:/ $

What am I missing ? 

0 Kudos

680 Views
martin_durak
NXP Employee
NXP Employee

Hi @Lancelot ,

i noticed a little mistake in your scfw setup, the list should have 10 items

         static const sc_rsrc_t rsrc_list[12U] =

I don`t know what is your final goal, but if you would like to have CAN on Android Automotive side please check this step-by-step example.

https://community.nxp.com/t5/iMX-and-Vybrid-Support/Enable-Flexcan-in-Android-Auto-on-i-MX8QXP/ta-p/...

 

Martin

 

 

0 Kudos

672 Views
Lancelot
Contributor I

Hello Martin,

Thank you very much for replying on this.

Regarding the "sc_rsrc_t rsrc_list[12U]" list, the only change I did is comment out the highlighted elements. My goal is to enable the CAN bus, and have ifconfig -a command detect the interface. 

Regarding the link you provided, I receive 'access denied' when accessing it - maybe it's an internal resource, or perhaps it's available only to specific account tiers ? 

Lancelot

0 Kudos

652 Views
martin_durak
NXP Employee
NXP Employee

We lost a day by finding a similar mistake in SCFW when were doing  QNX/AA13 HW partition demo. Because it allocates more space than it is needed...

If you don`t have access I am including these patches, which enable CAN on the AA side. You can check it with can-utils [1].

Can-utils repo should be cloned into ../android_build/external

after that go into that folder and run mm cmd for module compilation. It may gives you errors therefore you need to add this:

diff --git a/Android.mk b/Android.mk
index 35454b6..caa1c52 100644
--- a/Android.mk
+++ b/Android.mk
@@ -2,6 +2,7 @@ LOCAL_PATH := $(call my-dir)

 PRIVATE_LOCAL_CFLAGS := -O2 -g -W -Wall                \
                        -Wno-error=unused-parameter     \
+                       -Wno-gnu-variable-sized-type-not-at-end \
                        -DSO_RXQ_OVFL=40        \
                        -DPF_CAN=29             \
                        -DAF_CAN=PF_CAN

 

after that, it should be compiled. Let me know if it doesn`t work.

 

[1] https://github.com/linux-can/can-utils.git

Martin

0 Kudos

549 Views
Lancelot
Contributor I

@martin_durak @zdenek_zadera 
My apologies for replying this late, and thank you again for your help. 

I followed Martin's guide with one exception: scfw_move_flexcan_to_acore.patch targets the board file of iMX8QuadXPlus-MEK  -- my board is iMX8QuadMax-MEK. 

So, following chapter 8.7 in this guide by using the configuration file of 8QuadMax MEK, changed like below:

            /* List of resources */
            static const sc_rsrc_t rsrc_list[7U] =
            {
                SC_R_IRQSTR_M4_1,
              SC_R_UART_2,
                SC_R_MU_6B,
                SC_R_MU_7B,
                SC_R_MU_9B,
                SC_R_GPT_3,
                //RM_RANGE(SC_R_CAN_0, SC_R_CAN_2),
                SC_R_FSPI_0
            };

            /* List of pads */

            static const sc_pad_t pad_list[6U] =
            {
                RM_RANGE(SC_P_M41_I2C0_SCL, SC_P_M41_GPIO0_01),
                RM_RANGE(SC_P_UART0_CTS_B, SC_P_UART0_RTS_B),
                //RM_RANGE(SC_P_FLEXCAN0_RX, SC_P_FLEXCAN2_TX),
                RM_RANGE(SC_P_QSPI0A_DATA0, SC_P_COMP_CTL_GPIO_1V8_3V3_QSPI0)
            };


... I was able to build the SCFW binary. I copyied it back to ${MY_ANDROID}/vendor/nxp/fsl-proprietary/
uboot-firmware/imx8q_car/mx8qm-scfw-tcm.bin, built the can utils module, and finally ran imx-make.sh -j for a full build -> it was a successful build. 

However, after flashing the board with the resulted images using uuu, nothing gets displayed on screen, the board is not detected by adb and a serial connection cannot be made with the board either. 

I am not sure what is wrong, as there are no logs for me to debug. 

0 Kudos

1,095 Views
tangjuan
Contributor I

Hi,TAug.

I have the same problem. Have you solved it? How is it debugged?

0 Kudos