Skip to content

nxp: lpspi: regression accessing spi flash #94237

@sgfeniex

Description

@sgfeniex

Describe the bug

Recent changes in the LPSPI driver #93523 have broken communications with a SPI Flash device on my custom board.

[00:00:00.071,000] <err> littlefs: can't open flash area 1, err -19
[00:00:00.071,000] <err> fs: fs mount error (-19)
[00:00:00.071,000] <err> littlefs: Automount /lfs2 failed: -19

Regression

  • This is a regression.

Steps to reproduce

Configure a spi nor flash on lpspi

Relevant log output

[00:00:00.071,000] <err> littlefs: can't open flash area 1, err -19
[00:00:00.071,000] <err> fs: fs mount error (-19)
[00:00:00.071,000] <err> littlefs: Automount /lfs2 failed: -19

Impact

Major – Severely degrades functionality; workaround is difficult or unavailable.

Environment

OS: Ubuntu
Toolchain: Zephyr SDK 0.17
Zephyr main
Processor: MIMXRT1062
Peripheral: LPSPI4

Additional Context

I bisected to this commit:

commit 860f9c8 (HEAD)
Author: Martin Stumpf [email protected]
Date: Tue Jul 22 17:40:20 2025 +0200

spi_nxp_lpspi: Fix underflow in lpspi sck calculation

If `desired_delay_ns` is `0`, it is much saner to set the delay to `0x00`
than to underflow and set it to `0xff`, which is the current behavior.

Signed-off-by: Martin Stumpf <[email protected]>
❯ git bisect log
# bad: [8e5e9922c5c428d457568e317256894efccce078] Bluetooth: ISO: Fix sonarcloud issues in valid_chan_qos
# good: [413b789deb391d3a37d06b463288a5fe765ee57e] release: Zephyr v4.2.0
git bisect start 'HEAD' 'v4.2.0'
# good: [d9395d8502f6010455483f9ba775c330555d132f] net: lwm2m: json: Check for int64_t overflow when parsing integer
git bisect good d9395d8502f6010455483f9ba775c330555d132f
# bad: [814ed6803f329b5d8ca151e21ae25cddd9b143c5] tests: fix arm_irq_vector_table fail on Ambiq platforms
git bisect bad 814ed6803f329b5d8ca151e21ae25cddd9b143c5
# bad: [321ccb8889358cfd3e9f4c4f2b125d4142417951] led_strip: ws2812_spi: place buffer in __nocache for DMA
git bisect bad 321ccb8889358cfd3e9f4c4f2b125d4142417951
# bad: [b6b7b6759d020885ed9934ba91bf35b41e65af31] include: zephyr: dt-bindings: clock: stm32mp13_clock
git bisect bad b6b7b6759d020885ed9934ba91bf35b41e65af31
# bad: [b90cb5b773e8c49c140fb57791c306692d71eab5] maintainer: hal_nxp: align names to new management process
git bisect bad b90cb5b773e8c49c140fb57791c306692d71eab5
# good: [b633f3a9de85ac97ab5693b04ad8c08b3e90e113] net: lwm2m: Verify pmin for updated resource on notify check
git bisect good b633f3a9de85ac97ab5693b04ad8c08b3e90e113
# bad: [e5988398e37d9fe6f84c56faa498a85e829e81d3] doc: coding guidelines: add reference to MSC01-C for rule 15.7
git bisect bad e5988398e37d9fe6f84c56faa498a85e829e81d3
# good: [be38568577cd760d506b081b6de1bbe2a71c2a05] net: openthread: Fix build with CONFIG_OPENTHREAD_INTERFACE_EARLY_UP
git bisect good be38568577cd760d506b081b6de1bbe2a71c2a05
# bad: [64131856199342d0cb6507e5c57355c82f24dd69] drivers: flash: nordic: fix nrf-mramc indentation
git bisect bad 64131856199342d0cb6507e5c57355c82f24dd69
# bad: [860f9c8ef58766842229375300754f13e8181137] spi_nxp_lpspi: Fix underflow in lpspi sck calculation
git bisect bad 860f9c8ef58766842229375300754f13e8181137
# first bad commit: [860f9c8ef58766842229375300754f13e8181137] spi_nxp_lpspi: Fix underflow in lpspi sck calculation

I have confirmed that removing delay_cycles = MAX(delay_cycles, min_cycles); results in desired operation.

See related symptoms in #91015 but a different cause.

Metadata

Metadata

Labels

RegressionSomething, which was working, does not anymorebugThe issue is a bug, or the PR is fixing a bugplatform: NXPNXP

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions