IMX8M Mini EVK,How does spi work in slave mode

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

IMX8M Mini EVK,How does spi work in slave mode

1,694 Views
Joshua2
Contributor I

We need to use the spi1 port to communicate with peripherals and configure it in slave mode. How to configure it in slave mode?

Labels (1)
0 Kudos
Reply
3 Replies

1,689 Views
igorpadykov
NXP Employee
NXP Employee

Hi Joshua

 

one can try guidelines below as i.MX8M Mini has the same ecspi module :

https://www.digi.com/resources/documentation/digidocs/90001547/reference/bsp/v4-1_6ul/r_spi_v4-1.htm...

 

Best regards
igor

0 Kudos
Reply

1,649 Views
Joshua2
Contributor I

Hi igor,

Thank you for your reply!
I tried but failed. Please help to check what went wrong.
1) dts modification
pinctrl_spi1: spi1 {
fsl,pins = <
MX8MM_IOMUXC_ECSPI1_SCLK_ECSPI1_SCLK 0x1d0
MX8MM_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI 0x1d0
MX8MM_IOMUXC_ECSPI1_MISO_ECSPI1_MISO 0x1d0
MX8MM_IOMUXC_ECSPI1_SS0_GPIO5_IO9 0x1d0
>;
};
&ecspi1 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_spi1>;
spi-slave;

/*
* Unique slave node. Property'compatible' must be set to the
* slave driver that will be registered by default.
*/
slave@0 {
reg = <0>; /* must match the used CS line */
compatible = "spidev";
spi-max-frequency = <1000000>;
};
};
2) echo spidev >/sys/class/spi_slave/spi0/slave, you can find the spidev0.0 device.
3) Run spidev_test
root@okmx8mm:/usr/bin/cmd# spidev_test /dev/spidev0.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)
transfer size 1
4) The master starts to send data, and the oscilloscope can capture the waveform and send it normally. But the slave cannot receive it.

The attachment is the file modified by DTS.

 

Thanks,

Joshua

0 Kudos
Reply

1,647 Views
Joshua2
Contributor I

Hi igor,

Thank you for your answer!

I tried it but it didn't work, and the slave did not receive the data. The following is my modification, please help analyze the error.

Linux kernel version: Linux version 4.14.78

:1) dts modification

/***********************************************/

pinctrl_spi1: spi1 {
fsl,pins = <
MX8MM_IOMUXC_ECSPI1_SCLK_ECSPI1_SCLK 0x1d0
MX8MM_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI 0x1d0
MX8MM_IOMUXC_ECSPI1_MISO_ECSPI1_MISO 0x1d0
MX8MM_IOMUXC_ECSPI1_SS0_GPIO5_IO9 0x1d0
/*
MX8MM_IOMUXC_SPDIF_TX_GPIO5_IO3 0x159
*/
>;

&ecspi1 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_spi1>;
spi-slave;

/*
* Unique slave node. Property 'compatible' must be set to the
* slave driver that will be registered by default.
*/
slave@0 {
reg = <0>; /* must match the used CS line */
compatible = "spidev";
spi-max-frequency = <1000000>;
};
};

/***********************************************/

2) echo spidev > /sys/class/spi_slave/spi0/slave, the device of /dev/spidev0.0 can be found.

3)Run the spidev_test test program 

root@okmx8mm:/usr/bin/cmd# spidev_test /dev/spidev0.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)
transfer size 1

4)The master starts to send data, but the slave does not receive any data.

The attachment is the dts file.

 

Thanks,

Joshua

Tags (1)
0 Kudos
Reply