Skip to content

Using the LPSPI driver on MCXA156 with the generic "jedec,spi-nor" driver and a external flash memory only works with optimizations disabled #85081

@ehughes

Description

@ehughes

I am tracking an obscure bug with the shim based driver for LPSPI on the MCXA156. Even though the LPSPI driver passes the spi loopback test, I was able to get it to fail when using it with real devices.

Setup:

I have a FRDM-MCXA156 with a W25q64 SPI Flash memory wired to LPSPI1.

I am using the "spi_flash" sample as a basis for the my test.

Note: As a control, I also tested the same flash chip wired to a FRDM-MCX947 (which also uses LPSPI) and a LPC55S69Xpresso (which has flexcomm). The spi_flash sample runs OK on both of them. I narrowed it down to some interaction w/ the MCXA156 / LPSPI

I created an overlay :

image

The nor flash driver driver works through boot and most of the test. It can read the the JEDEC flash ID, issue erase commands, etc. However, I noticed that writes would fail. After some debugging I observed this on my logic analyzer:

image

The specific transaction for the flash write had the chip select active >200mS, most of that idle. The transaction after that was a command to shut down the flash as the SPI transaction for the write returned a timeout from the driver.

The flash write is successful if all optimizations are disabled.

image

Looking through the spi_nor driver and LPSPI Flash driver, I found this:

image

If you follow the spi_transcieve_dt function:

image

I noticed when optimizations are on, This if statement never evaluates to true. (Using Segger Ozone to single step and evaluate)

image

With optimizations off, it will evaluate to true for the write transcations.

This does appear to be timing related. If I turn on the SPI log dbg messages, the sample will work.

I noticed that MCXN driver instance had a fifo size of 8 while MCXA had a size of 4. If I reduce this size, the MCXA156 version works

image

Values of 1,2,3 yield a successful result with optimizations enabled. A value of 4 (the dts default) will result in the timeout error.

Let me know if there is a test I can run, etc.

  • OS: Windows
  • Toolchain : zephyr-sdk-0.17.0
  • Commit : 491bbcf

Metadata

Metadata

Labels

bugThe issue is a bug, or the PR is fixing a bugplatform: NXPNXPpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions