Brief of the Issue
We are testing SPI slave mode communication on iMX6ULL using the Colibri Evaluation Board. The observation is that some bytes – supposed to be sent by the slave device – are missing and not seen on the MISO line.
Setup
Description of the Issue
The slave device receives all the bytes sent by the master. However, in the response data sent by the slave device, some words are missing and zeros are received instead of the actual data.
There are two observations associated with the issue:
The following table shows the first observation.
Data Put into Slave (i.MXULL) TX FIFO | Data Seen on the MISO line |
aa bb cc 01 | 00 00 00 00 |
aa bb cc 02 | 00 00 00 00 |
aa bb cc 03 | aa bb cc 03 |
aa bb cc 04 | aa bb cc 04 |
The first observation is consistent across resets, and the second one across every cycle of 256 words.
The data was analyzed from the master device, using a logic analyzer and scope.
Please note that we are not using the standard Linux driver in our case, we have a simple driver that configures the registers and fills up the TXFIFO. When there are 16 words in RXFIFO read them and fill TXFIFO with 16 words. This is the logic.
Debugging Steps Performed
Hello @j_george
I hope you are doing very well.
Please refer to the chapter 3.2.1 TXFIFO issue in slave mode of AN13633 (Using Enhanced Configurable SPI (ECSPI) as Slave in Linux). That application note describe perfectly the issue you are having:
Also the chapter 3.2.3.1:
It appears it is an issue on the TXFIFO and spi-imx driver.
I hope this can helps to you.
Best regards,
Salas.
Hello Alejandro_Salas,
Thank you. We had seen this Application Note and we ran some tests:
About 3.2.1 - The issue describes that the last data repeats after 64 words and that it happens with the TX FIFO is empty. But in our case, we ensure that TXFIFO is always at least 50% full. It is never empty and we confirmed this by monitoring the TXFIFO EMPTY status flag. The FIFO never indicates an empty. In our case, a word is just vanished. The next word is as expected.
About 3.2.3.1: This is where we have a doubt. In our case, the burst length is configured as 32Bits. And RX Threshold to 15. So the intention is that our SPI transfers are all 4bytes (1 word) and we get interrupts at 16 Words (1/4th of FIFO FULL). And in the ISR we fill the TXFIFO with next 16 words to send, to that TXFIFO is never empty. The SS is tied to Ground. So the SS is not toggling. Is that an issue? We are aware that there is an errata that says, SPI transfers cannot be ended with the SS Edge and should depend only on Burst Length. This is why we have disregarded the SS and also because this is a Point to Point link. So as per the errata, we should be safe.
I saw that the spi-imx slave driver in Linux is limiting the transactions to max 64 words and at the end, the ECSPI block is disabled and enabled. In our case, even the first 2 words are missing after disabling and enabling the block.
Hello @j_george
The SS has a different behavior when working as Slave instead of Master, are you using the dedicated SS of the ECSPI module or do you have a GPIO as SS?
Is possible to share your Device Tree related to your ECSPI configuration?
I am not sure if this weird behavior is caused from the SS signal, but you can try to to untied of ground and control it from your master device.
Best regards,
Salas.
Hello,
After a lot of testing, we seem to see that when the CS is toggled, there is ever so slight improvement but not great.
With CS: We get around 16 words of Zeroes and then the data comes out without any errors.
Without CS: The first two words are wrong and then the data comes properly. But also every other 128th word is also Zero instead of the actual data.
So can you please confirm if in the slave mode, CS toggling is an absolute necessity or not? We were planning to keep the CS held low all the time.