This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM6442: Incomplete SPI-NOR writes in Direct Access Mode on Linux

Part Number: AM6442

On our AM64-based SoM/board TQMa64xxL/MBaX4XxL, we are occasionally seeing incomplete writes to SPI-NOR flash. It looks like it's always the last bytes of a 512-byte block somewhere in a larger write that are missing:

Usually, only 8 bytes are missing, but sometimes larger parts of a write are affected, like the 128 bytes seen in the above diff. Our test setup uses "mtd_debug write" to write blocks of random data to the flash.

We found that disabling use_direct_mode makes this issue disappear. Only disabling DMA (as it is done on AM64 SR1.0 by default now) is not sufficient to work around the issue.

We're seeing this issue on AM6442 SR1.0 and 2.0. The SPI-NOR flash is a Macronix MX25U51245G QSPI flash. The driver uses 1-4-4 write operations.

Our kernel is based on ti-linux-kernel 5.10 cicd.2022.11.02.13.24.41-rt, with additional mainline backports of a few improvements to the SPI driver:

  • spi: cadence-quadspi: fix incorrect supports_op() return value
  • spi: cadence-quadspi: fix protocol setup for non-1-1-X operations
  • spi: cadence-quadspi: drop cqspi_set_protocol()
  • spi: cadence-quadspi: allow operations with cmd/addr buswidth >1

The parameters set by our Device Tree are fairly similar to the AM642 EVM:

spi-max-frequency = <84000000>;
cdns,tshsl-ns = <60>;
cdns,tsd2d-ns = <60>;
cdns,tchsh-ns = <60>;
cdns,tslch-ns = <60>;
cdns,read-delay = <2>;

Should we just keep Direct Access Mode disabled as a workaround, or is there anything else we can try?