Enable CAN IMX8QM-MEK A cores (Linux 5.4.70_2.3.0​)

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

Enable CAN IMX8QM-MEK A cores (Linux 5.4.70_2.3.0​)

4,726 Views
rdeushane
Contributor II

Is it not possible to use the CAN peripherals on the MEK board from Linux?

I've confirmed that I have the kernel modules installed, however from Linux I can't see any CAN interfaces through ip addr or ifconfig -a.

From other threads such as this one, i've narrowed down that the CAN resources may not be assigned to the A cores via SCFW. This might be supported by these messages I noticed U-BOOT printing on boot:

 

## Flattened Device Tree blob at 83000000
Booting using the fdt blob at 0x83000000
Using Device Tree in place at 0000000083000000, end 0000000083024fff
Disable jr@40000 rsrc 502 not owned
Disable mu@31580000 rsrc 505 not owned
Disable i2c@3b230000 rsrc 308 not owned
Disable clock-controller@3b630000 rsrc 308 not owned
Disable intmux@3b400000 rsrc 309 not owned
Disable clock-controller@5a480000 rsrc 59 not owned
Disable can@5a8d0000 rsrc 105 not owned
Disable can@5a8e0000 rsrc 106 not owned
Disable can@5a8f0000 rsrc 107 not owned
Disable clock-controller@5acd0000 rsrc 105 not owned
Disable clock-controller@5ace0000 rsrc 106 not owned
Disable clock-controller@5acf0000 rsrc 107 not owned
Disable clock-controller@5b260000 rsrc 253 not owned
Disable spi@5d120000 rsrc 237 not owned
Disable imx8qm_cm4@0 rsrc 278 not owned
Disable imx8qm_cm4@0 rsrc 297 not owned
Disable imx8x_cm4@1 rsrc 298 not owned
Disable imx8x_cm4@1 rsrc 317 not owned

 


I am guessing that I may need to assign these peripherals/pads to the A cores by recompiling the SCFW, However none of the solutions I've found online are applicable to the current SCFW porting kit (imx-scfw-porting-kit-1.7.1). I've poked around at the SCFW firmware and compiled with a bunch of variations to try to make this work, but the resources still claim to be not owned.

Are there up to date instructions on how to get the CAN peripherals working in Linux?

0 Kudos
Reply
15 Replies

4,719 Views
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi rdeushane

I think this four docs will help you.

https://source.codeaurora.org/external/imx/imx-test/tree/test/can/doc?h=imx_5.4.70_2.3.0

 

BR

Zhiming

0 Kudos
Reply

4,702 Views
rdeushane
Contributor II

Thanks for the response, I've read through these docs however and they won't help me. 

I can't bring up the CAN interface because the CAN device isn't populated in Linux. It seems like CAN is disabled by U-boot from the beginning, because it isn't "owned" by the A cores:

Disable can@5a8d0000 rsrc 105 not owned
Disable can@5a8e0000 rsrc 106 not owned
Disable can@5a8f0000 rsrc 107 not owned
0 Kudos
Reply

4,683 Views
rdeushane
Contributor II

I've seen these but they don't seem to be relevant in the latest porting kit: https://www.nxp.com/webapp/Download?colCode=L5.4.70_2.3.1_SCFWKIT-1.7.1&appType=license

I've found the board.c for IMX8QM, but the mentioned lines do not exist. The only relevant bits to CAN I've found are:

/* Create M4 1 partition */
        if (rm_is_resource_avail(SC_R_M4_1_PID0) != SC_FALSE)
        {
            sc_rm_mr_t mr;
            /* 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)
            };
            /* List of memory regions */
            static const sc_rm_mem_list_t mem_list[2U] =
            {
                {0x088800000ULL, 0x08FFFFFFFULL},
                {0x008181000ULL, 0x008280FFFULL}
            };
            /* Create partition */
            BRD_ERR(rm_partition_create(pt_boot, &pt_m4_1, SC_FALSE,
                SC_TRUE, SC_FALSE, SC_TRUE, SC_FALSE, SC_R_M4_1_PID0,
                rsrc_list, ARRAY_SIZE(rsrc_list),
                pad_list, ARRAY_SIZE(pad_list),
                mem_list, ARRAY_SIZE(mem_list)));
0 Kudos
Reply

4,677 Views
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi

 

You can try to del these CAN code.They add CAN resource into M4

0 Kudos
Reply

4,669 Views
rdeushane
Contributor II

Was able to make some progress on this, CAN peripherals are not warned as "not owned" after removing the CAN assignments to M4.

Disable jr@40000 rsrc 502 not owned
Disable mu@31580000 rsrc 505 not owned
Disable i2c@3b230000 rsrc 308 not owned
Disable clock-controller@3b630000 rsrc 308 not owned
Disable intmux@3b400000 rsrc 309 not owned
Disable clock-controller@5a480000 rsrc 59 not owned
Disable clock-controller@5b260000 rsrc 253 not owned
Disable spi@5d120000 rsrc 237 not owned
Disable imx8qm_cm4@0 rsrc 278 not owned
Disable imx8qm_cm4@0 rsrc 297 not owned
Disable imx8x_cm4@1 rsrc 298 not owned
Disable imx8x_cm4@1 rsrc 317 not owne


Seems like I'm in the same position as this commenter from that thread. Is the I2C peripheral required for CAN operation?

0 Kudos
Reply

4,657 Views
rdeushane
Contributor II

Reverted back to mostly stock bitbake settings. The "not-owned" warnings are resolved, but still no CAN peripheral with "ifconfig -a" or "ip addr". 

0 Kudos
Reply

4,641 Views
BiyongSUN
NXP Employee
NXP Employee

It is binary release  5.4.70_2.3.0 running on i.MX8QM MEK +  Base board 

 

Embedded Linux for i.MX Applications Processors | NXP Semiconductors

 

Untitled.png

 

 

 

0 Kudos
Reply

4,640 Views
BiyongSUN
NXP Employee
NXP Employee

Different bootloader flash.bin has different hardware partition. 

If you want to use the can on A code side, please don't not use the flash.bin with m4.

for example:

imx-boot-imx8qmmek-sd.bin-flash_linux_m4  

the  flash_linux_m4  behind dash(-1) is the imx-mkimage use to pack option.

0 Kudos
Reply

4,626 Views
rdeushane
Contributor II

Hi BiyongSUN,

Thanks for the response. I am using 5.4.70_2.3.0, I will try this.

0 Kudos
Reply

4,406 Views
ShivM
Contributor II

Hi rdeushane,

Were you able to solve this problem? if so Pls let me know I am facing same issue in IMX8QXP.

 

Regards,

Shiv

Tags (1)
0 Kudos
Reply

4,383 Views
BiyongSUN
NXP Employee
NXP Employee

repeat  reply on ‎04-01-2021 for  i.MX8QXP MEK

say "repeat" is for this can demo, i.MX8QM MEK and i.MX8QXP MEK are exactly the same.


for the can enable demo 

1. need  i.MX8QXP MEK + Base Board.

2. use the flash without M4. 

Untitled.png

 

0 Kudos
Reply

4,376 Views
ShivM
Contributor II

Hi BiyongSUN,

Pls help me out as I am struck for few weeks already. I have downloaded the prebuilt binaires for 

Linux 5.10.35_2.0.0.

I do not have base board but we have connected the CAN transceiver to J13 and PINS based on the schematics.

I am using MCIMX8QXP_CPU with some details as given below on board.

SCH-29683 REV D4

700-29683 REV C2 

I flashed the board below images:

imx-image-full-imx8qxpc0mek.wic and imx-boot-imx8dxmek-sd.bin-flash

I don't need M4 so I am using imx-boot-imx8dxmek-sd.bin-flash. As per SCFW porting guide if I use flash image(without m4) all the resources should be assigned to A35.

Pls refer attached log

U-Boot 2021.04-5.10.35-2.0.0+g3463140881 (Jun 08 2021 - 01:39:44 +0000)

CPU: NXP i.MX8QXP RevC A35 at 1200 MHz at 25C

Linux version 5.10.35-lts-5.10.y+gef3f2cfc6010

NXP i.MX Release Distro 5.10-hardknott imx8qxpc0mek ttyLP0

Pls look at my ifconfig and demesg outout

root@imx8qxpc0mek:~# ifconfig -a
eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:04:9f:06:a5:88 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 92 bytes 7826 (7.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 92 bytes 7826 (7.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

root@imx8qxpc0mek:~#
root@imx8qxpc0mek:~# [ 33.859133] usb_otg1_vbus: disabling

root@imx8qxpc0mek:~#
root@imx8qxpc0mek:~# dmesg | grep can
[ 2.497905] imx-lpi2c 37230000.i2c: can't get the TX DMA channel, error -19!
[ 2.646404] imx-lpi2c 5a810000.i2c: can't get the TX DMA channel, error -19!
[ 2.827831] imx-lpi2c 58226000.i2c: can't get the TX DMA channel, error -19!
[ 3.314531] imx-lpi2c 56226000.i2c: can't get the TX DMA channel, error -19!
[ 3.454722] imx-lpi2c 56246000.i2c: can't get the TX DMA channel, error -19!
root@imx8qxpc0mek:~#
root@imx8qxpc0mek:~#

Can you let me know which DTB file is loaded with this prebuilt binary imx-image-full-imx8qxpc0mek.wic?

Your response is greatly appreciated.

0 Kudos
Reply

4,365 Views
BiyongSUN
NXP Employee
NXP Employee

If you don't have the base board, you have to modify the code. Because the can regulator is controlled by the pca6416. 

The BSP is for the i.MX8QXP/i.MX8QM MEK + base board. 

It is sample demo code, you need to change according to the hardware change. 

That is the most of the case for customer board. In your case, should be the rework for the i.MX8QXP MEK. 

If you check the debug log, error is from the pca6416

2.504977] imx-lpi2c 37230000.i2c: error -ENODEV: dma setup error -19, use pio
[ 2.516125] pca953x 16-0020: error -ENODEV: reg get err
[ 2.521381] pca953x 16-0020: using no AI
[ 2.525482] pca953x 16-0020: failed writing register
[ 2.530476] pca953x: probe of 16-0020 failed with error -5
[ 2.553075] ov5640 16-003c: supply DOVDD not found, using dummy regulator
[ 2.560057] ov5640 16-003c: supply AVDD not found, using dummy regulator
[ 2.566824] ov5640 16-003c: supply DVDD not found, using dummy regulator
[ 2.621025] ov5640 16-003c: ov5640_read_reg: error: reg=300a
[ 2.626711] ov5640 16-003c: ov5640_check_chip_id: failed to read chip ide

imx8x-mek.dtsi

&cm40_i2c {
#address-cells = <1>;
#size-cells = <0>;
clock-frequency = <100000>;
pinctrl-names = "default", "gpio";
pinctrl-0 = <&pinctrl_cm40_i2c>;
pinctrl-1 = <&pinctrl_cm40_i2c_gpio>;
scl-gpios = <&lsio_gpio1 10 GPIO_ACTIVE_HIGH>;
sda-gpios = <&lsio_gpio1 9 GPIO_ACTIVE_HIGH>;
status = "okay";

pca6416: gpio@20 {
compatible = "ti,tca6416";
reg = <0x20>;
gpio-controller;
#gpio-cells = <2>;
};

 

linux/drivers/gpio/gpio-pca953x.c:1255: { .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), },

 

 

Untitled.png

here is the dts changes for using only i.MX8QXP MEK board to do the can enable test.

imx8qxp-mek-can-test-wo-bb.dts

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
* Copyright 2019-2020 NXP
*/


/*LF_v5.10.35_2.0.0*/


/dts-v1/;

#include "imx8qxp-mek.dts"


&flexcan1 {

/delete-property/ xceiver-supply;

};

&flexcan2 {

/delete-property/ xceiver-supply;

};

 

This the test. 

Untitled1.png

 

 

0 Kudos
Reply

4,348 Views
ShivM
Contributor II

Thanks BiyongSUN this helps

0 Kudos
Reply