imx8mnevk-ddr4 SPI data transfer issues

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

imx8mnevk-ddr4 SPI data transfer issues

723 Views
joe05
Contributor I

I am attempting to test SPI functionality on the i.MX 8M Nano DDR4 EVK using the Linux tool spidev_test with the MISO and MOSI pins connected on the J1003 connector. When using 8 bits per word I can specify a transfer size of 63 bytes, 64 bytes results in an error. If I change bits per word to 32, I can only send 16 bytes.

Why can I only send up to 63 bytes when using 8 bits per word and why does this drop to 16 bytes when using 32 bits per word.

The output I get from spidev_test is as follows:

spidev_test -D /dev/spidev1.0 -b 8 -S 63 -I 1 -s 8000000 -v
spi mode: 0x0
bits per word: 8
max speed: 8000000 Hz (8000 KHz)
TX | 67 C6 69 73 51 FF 4A EC 29 CD BA AB F2 FB E3 46 7C C2 54 F8 1B E8 E7 8D 76 5A 2E 63 33 9F C9 9A |g.isQ.J.)......F|.T.....vZ.c3...|
TX | 66 32 0D B7 31 58 A3 5A 25 5D 05 17 58 E9 5E D4 AB B2 CD C6 9B B4 54 11 0E 82 74 41 21 3D DC __ |f2..1X.Z%]..X.^.......T...tA!=.|
RX | 67 C6 69 73 51 FF 4A EC 29 CD BA AB F2 FB E3 46 7C C2 54 F8 1B E8 E7 8D 76 5A 2E 63 33 9F C9 9A |g.isQ.J.)......F|.T.....vZ.c3...|
RX | 66 32 0D B7 31 58 A3 5A 25 5D 05 17 58 E9 5E D4 AB B2 CD C6 9B B4 54 11 0E 82 74 41 21 3D DC __ |f2..1X.Z%]..X.^.......T...tA!=.|
total: tx 0.1KB, rx 0.1KB

It appears that the ioctl call fails for a 64 byte transfer size:

spidev_test -D /dev/spidev1.0 -b 8 -S 64 -I 1 -s 8000000 -v

spi mode: 0x0

bits per word: 8

max speed: 8000000 Hz (8000 KHz)

can't send spi message: Invalid argument

Aborted

Now if I try using 32 bits per word I get the following output for a 16 byte transfer size:

spidev_test -D /dev/spidev1.0 -b 32 -S 16 -I 1 -s 8000000 -v

spi mode: 0x0

bits per word: 32

max speed: 8000000 Hz (8000 KHz)

TX | 67 C6 69 73 51 FF 4A EC 29 CD BA AB F2 FB E3 46 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  |g.isQ.J.)......F|

RX | 67 C6 69 73 51 FF 4A EC 29 CD BA AB F2 FB E3 46 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  |g.isQ.J.)......F|

total: tx 0.0KB, rx 0.0KB

 

If I increase the transfer size above 16 bytes using 32 bits per word I get the same error as seen for 8 bits per word with a 64 byte transfer size:

spidev_test -D /dev/spidev1.0 -b 32 -S 17 -I 1 -s 8000000 -v
spi mode: 0x0
bits per word: 32
max speed: 8000000 Hz (8000 KHz)
can't send spi message: Invalid argument
Aborted

I’m not sure in both cases if the limitation is the hardware, the Linux Kernel/driver or a configuration issue.

 

I am using the i.MX Linux release 5.4.3 and building the Yocto core-image-base image. In order to enable SPI on the imx8mnevk DDR4 variant, I took the SPI configuration from the LPDDR4 variant and created a patch file for the dts file with the following contents:

--- a/arch/arm64/boot/dts/freescale/imx8mn-ddr4-evk.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mn-ddr4-evk.dts
@@ -151,6 +151,20 @@
>;
};

+ pinctrl_ecspi2: ecspi2grp {
+ fsl,pins = <
+ MX8MN_IOMUXC_ECSPI2_SCLK_ECSPI2_SCLK 0x82
+ MX8MN_IOMUXC_ECSPI2_MOSI_ECSPI2_MOSI 0x82
+ MX8MN_IOMUXC_ECSPI2_MISO_ECSPI2_MISO 0x82
+ >;
+ };
+
+ pinctrl_ecspi2_cs: ecspi2cs {
+ fsl,pins = <
+ MX8MN_IOMUXC_ECSPI2_SS0_GPIO5_IO13 0x82
+ >;
+ };
+
pinctrl_i2c1: i2c1grp {
fsl,pins = <
MX8MN_IOMUXC_I2C1_SCL_I2C1_SCL 0x400001c3
@@ -438,6 +452,22 @@
};
};

+&ecspi2 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ fsl,spi-num-chipselects = <1>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_ecspi2 &pinctrl_ecspi2_cs>;
+ cs-gpios = <&gpio5 13 GPIO_ACTIVE_LOW>;
+ status = "okay";
+
+ spidev0: spi@0 {
+ reg = <0>;
+ compatible = "rohm,dh2228fv";
+ spi-max-frequency = <8000000>;
+ };
+};
+
&i2c2 {
clock-frequency = <400000>;
pinctrl-names = "default", "gpio";
--
2.25.0

I am using a maximum SPI frequency of 8 MHz rather than the 500 KHz default configuration. However if I use a 500 KHz maximum SPI frequency in the patch file I still see the same behaviour.

Update: I have enabled function tracing in the Linux Kernel which shows the spidev_test calls that result in an error do not reach the i.MX SPI driver. Using the tracing I can see the i.MX SPI driver calls for the calls using 8 bits per word and up to 63 bytes but not for the spidev_test calls I have issues with. Could this be a Linux Kernel configuration issue or is it hardware related as the i.MX driver is not called?

 

Any comments or suggestions regarding the observed behaviour would be appreciated.

Labels (2)
0 Kudos
0 Replies