Giovanni wrote:It is like the DMA is setup for 16bits destination, so you will get 2 bytes for each byte. Strange, the SPI driver should select 16 bits destinations only if the selected frame size is greater than 8. Verify your SPI configuration.
If I show the rx DMA config just at the point where it sets CSTART in spi_lld_exchange then I see this:
(gdb) p (void*)spip->rx->dma->stream->CR
$5 = (void *) 0x10417
(gdb) p (void*)spip->rx->dma->stream->NDTR
$8 = (void *) 0x13
The SPI config loaded into the peripheral is:
(gdb) p (void*)spip->spi->CFG1
$11 = (void *) 0x2000c007
(gdb) p (void*)spip->spi->CFG2
$13 = (void *) 0x20400000
which looks like a normal MODE0 transfer of 8 bit data with DMA.
which looks correct for a 19 byte transfer with byte transfer and memory increment. Yet this is what I see:
7f 00 7f 00 7f 00 7f 00 7f 00 7f 00 c2 00 22 00 08
a correct transfer, of 9 bytes, should give this:
7f 7f 7f 7f 7f 7f c2 22 08
(that is the ID area of a ramtron fram part)
hmm, following the suggestion from bluuu I tried polled mode. I hadn't actually noticed the spiPolledExchange() function before! I switched to using that and SPI does indeed work correctly. I had to fix some bugs in the SPIv3 spi_lld_polled_exchange() function though. Patch is attached.
So it is definitely a DMA issue, though I have no idea what it is.