Repository: zephyrproject-rtos/zephyr

Issue #87768: spi_nxp_lpspi: Hardfault regression
Created: 2025-03-27T15:41:24Z
Describe the bug

There is some hard fault in the LPSPI driver during device init on some platforms.. This is new since 4.1.0 release
To Reproduce

west build -b frdm_ke17z -p always tests\drivers\spi\spi_loopback
west flash -r jlink
Expected behavior

Test pass
Impact

Driver does not work for some platform due to hard fault in init
Logs and console output

E: ***** HARD FAULT *****
E: r0/a1:  0x4002c000  r1/a2:  0x00008d28  r2/a3:  0x00000303
E: r3/a4:  0x00000002 r12/ip:  0x00000753 r14/lr:  0x00002c6b
E:  xpsr:  0x21000000
E: Faulting instruction address (r15/pc): 0x0000824e
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Current thread: 0x20004688 (main)
E: Halting system

Additional context

I did not bisect but I did debug and it is hard fault on LPSPI_Reset in the init of the device, likely introduced on this commit: 9f10418

Duplicate issue #87894: tests: spi:  multiply NXP platform spi cases failure
Created: 2025-03-31T10:05:10Z
Describe the bug
meet hard fault for multiply NXP platforms:
2025-03-31 17:49:30,098 - twister - DEBUG - DEVICE: E: ***** HARD FAULT *****
2025-03-31 17:49:30,104 - twister - DEBUG - DEVICE: E: r0/a1:  0x4002c000  r1/a2:  0x00007288  r2/a3:  0x00000303
2025-03-31 17:49:30,109 - twister - DEBUG - DEVICE: E: r3/a4:  0x00000002 r12/ip:  0x00000753 r14/lr:  0x0000227f
2025-03-31 17:49:30,111 - twister - DEBUG - DEVICE: E:  xpsr:  0x21000000
2025-03-31 17:49:30,116 - twister - DEBUG - DEVICE: E: Faulting instruction address (r15/pc): 0x000069ce
2025-03-31 17:49:30,120 - twister - DEBUG - DEVICE: E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
2025-03-31 17:49:30,124 - twister - DEBUG - DEVICE: E: Current thread: 0x20000480 (main)
2025-03-31 17:49:30,125 - twister - DEBUG - DEVICE: E: Halting system
2025-03-31 17:49:30,142 - twister - DEBUG - -- west flash: using runner jlink
-- runners.jlink: reset after flashing requested
-- runners.jlink: JLink version: 8.12b


Please also mention any information which could help others to understand
the problem you're facing:

What target platform are you using?

frdm_kc17z
frdm_ke17z512
frdm_mcxa156


What have you tried to diagnose or workaround this issue?
git bisect
Is this a regression? If yes, have you been able to "git bisect" it to a
specific commit?

9f10418b8ae708e34e13410720cdf16635fc80ec is the first bad commit
commit 9f10418b8ae708e34e13410720cdf16635fc80ec
Author: Peter van der Perk <peter.vanderperk@nxp.com>
Date:   Mon Mar 24 10:50:57 2025 +0100

    spi_nxp_lpspi: Reset peripheral on startup

    Ensure that LPSPI is in POR state when initializing

    Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>

 drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_common.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)


To Reproduce
west update
scripts/twister --device-testing --hardware-map /home/ubuntu/nxp/frdm_ke17z/map.yaml -T tests/drivers/spi/dt_spec/

Expected behavior
run PASS
Impact
SPI features
Logs and console output
see above
Environment (please complete the following information):

OS: (e.g. Linux, MacOS, Windows):
Toolchain (e.g Zephyr SDK, ...)
Commit SHA or Version used: v4.1.0-1511-g19c6240b6865

Closing comment (2025-03-31T16:37:12Z): duplicate of #87768