Hi Toradex Team,
We are testing SPI slave mode comunication on Colibri iMX6ULL using the Colibri Evaluation Board. This query is to seek help on an observation that some bytes – supposed to be sent by the slave device – are missing and not seen on the MISO line.
Introduction
Platform info (from tdx-info)
Software (custom Yocto-based image):
- Bootloader : U-Boot
- Kernel version : 6.1.55-00020-g9dccaf40e612 #1 SMP Sat Sep 23 09:11:13 UTC 2023
- Distro version : VERSION_ID=6.4.0-devel-20240403095552-build.0
Hardware (Colibri iMX6ULL on Colibri Evaluation Board):
- Toradex version : 0044 V1.1A
- Serial number : 14985046
- Processor arch : armv7l
Setup
- An ESP8266 is configured as the SPI master, with a clock frequency of 125kHz. The master simply sends a set number of bytes over SPI.
- The Colibri device contains an image that has a custom device driver which configures the SPI registers (slave mode), and just sends response to the master with some valid data (loop-back or pre-defined values). The TX FIFO is filled with 32 words of data initially.
- The SPI bus only contains one slave. CS pin on the Colibri is connected to GND so that the device is always active.
SPI Configuration on Colibri iMX6ULL
ECSPI1 is used as the slave device.
Pins:
CS : SODIMM 86
CLK : SODIMM 88
MISO : SODIMM 90
MOSI : SODIMM 92
Registers:
/* Control Register */
(0x1f << 20) // Burst Length
(0x00 << 18) // Channel Select
(0x00 << 16) // DRCTL
(0x00 << 12) // Pre Divider
(0x00 << 8) // Post Divider
(0x00 << 4) // CH Mode
(0x00 << 3) // SMC
(0x00 << 2) // XCH
(0x00 << 1) // HT
(0x01 << 0) // Enable
/* Configuration Register */
(0x00 << 20) // Reserved
(0x00 << 24) // HT Length
(0x00 << 20) // SCLK CTL
(0x00 << 16) // Data CRL
(0x01 << 12) // SS POL
(0x00 << 8) // SS CTL
(0x00 << 4) // SCLK_POL
(0x00 << 0) // SCLK_PHA
/* Interrupt Control Register */
(0x00 << 8) // Reserved
(0x00 << 7) // Transfer Completed
(0x01 << 6) // RX Overflow
(0x00 << 5) // RX FIFO Full
(0x01 << 4) // RX Data Threshold
(0x00 << 3) // RX Ready
(0x00 << 2) // TX FIFO Full
(0x00 << 1) // TX Data Threshold
(0x00 << 0) // TX Empty
/* DMA Control Register */
(0x00 << 31) // RXTDEN Disable
(0x00 << 30) // Reserved
(0x00 << 24) // RX DMA Len
(0x00 << 23) // RX DMA Disable
(0x00 << 22) // Reserved
(0x10 << 16) // RX Threshold
(0x00 << 8) // Reserved
(0x00 << 7) // TEDEN
(0x00 << 6) // Reserved
(0x10 << 0) // TX Threshold
Issue
Statement
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 those words are received as all-zeros instead of the actual data.
To be specific, there is a pattern. After a reset, the very first two words sent from the slave device are missed, and zeros are received instead. And after that, every next 256th word is missing and zero is received. This pattern continues.
The observation is represented in the following table.
Word Sent by Master | Word Received from Slave | Note |
---|---|---|
0 | 0x00000000 | Valid data expected |
1 | 0x00000000 | Valid data expected |
2 | Valid data | |
3 | Valid data | |
… | … Valid data … | |
255 | Valid data | |
256 | Valid data | |
257 | 0x00000000 | Valid data expected |
258 | Valid data | |
259 | Valid data | |
… | … Valid data … | |
513 | 0x00000000 | Valid data expected |
… | … Valid data … | |
769 | 0x00000000 | Valid data expected |
… | … | Pattern continued |
Methods of Observation
- Primarily, the data received on the master device is used to find the observation.
- To confirm the observation, a logic analyser was used and the signals showed the same behavior.
Debugging Steps Performed
With an aim to see if there will be a change in the observation (such as a deviation in the figure 256 which seems like a sort of cycle), we had tried out a few things.
- Changing the SPI clock frequency (no difference).
- Tweaking some of the SPI register values (no difference).
- Running the experiment at varied CPU loads, including 100% load (no difference).
Please provide a solution for this issue if it is a straight one, or share your suggestions to go forward. Also, please let me know if you need more details to work on this.
Expecting a fast response.
Thanks and regards,
Ajith