Can't connect to NXP's S32K322 after flashing the target

    • Can't connect to NXP's S32K322 after flashing the target

      Hello,

      I'm working on bringing up a prototype board which has S32K322 device. After writing some image to the flash memory using J-Link Flash via SWD, I'm unable to re-flash the target again. This was probably 30th time I flashed the device, before that I was able to connect, flash, erase and debug.

      I've reached out to NXP for assistance, but this did not yield any results yet: community.nxp.com/t5/S32K/Can-…t-to-S32K322/td-p/2035700


      Brief summary of the issue:
      -MCU was operational, I was able to flash the target using JFlash tool.
      -I've "managed" to brick the device by just flashing with a software image which did not do much, it was supposed to initialize the external oscillator and start some simple queries over the I2C bus.
      -"Bricked" MCU does not look like it is executing code, the external oscillator is not enabled, although it was until the MCU stopped working.
      -If the reset pin is set to low(MCU is in reset), JLink is able to read something, but fails to connect:

      Source Code

      1. J-Link>connect
      2. Device "S32K322_M7_0" selected.
      3. Connecting to target via SWD
      4. ConfigTargetSettings() start
      5. ConfigTargetSettings() end - Took 11us
      6. InitTarget() start
      7. SDA_AP detected
      8. Checking if debug access is already enabled...
      9. Debug access is not enabled yet. Performing enable debug access sequence...
      10. Debug access enabled
      11. Checking if HSE firmware is installed...
      12. HSE firmware not installed
      13. Checking if Cortex-M7_0 and Cortex-M7_1 are operating in lockstep mode
      14. Lock step mode enabled
      15. InitTarget() end - Took 27.5ms
      16. Found SW-DP with ID 0x6BA02477
      17. DPIDR: 0x6BA02477
      18. CoreSight SoC-400 or earlier
      19. AP map detection skipped. Manually configured AP map found.
      20. AP[0]: MEM-AP (IDR: Not set, ADDR: 0x00000000)
      21. AP[1]: APB-AP (IDR: Not set, ADDR: 0x00000000)
      22. AP[2]: MEM-AP (IDR: Not set, ADDR: 0x00000000)
      23. AP[3]: AHB-AP (IDR: Not set, ADDR: 0x00000000)
      24. AP[4]: AHB-AP (IDR: Not set, ADDR: 0x00000000)
      25. AP[5]: AHB-AP (IDR: Not set, ADDR: 0x00000000)
      26. AP[6]: MEM-AP (IDR: Not set, ADDR: 0x00000000)
      27. AP[7]: MEM-AP (IDR: Not set, ADDR: 0x00000000)
      28. AP[4]: Skipped ROMBASE read. CoreBaseAddr manually set by user
      29. AP[4]: Core found
      30. ConfigTargetSettings() start
      31. ConfigTargetSettings() end - Took 36us
      32. InitTarget() start
      33. SDA_AP detected
      34. Checking if debug access is already enabled...
      35. Core already enabled
      36. Checking if HSE firmware is installed...
      37. HSE firmware not installed
      38. Checking if Cortex-M7_0 and Cortex-M7_1 are operating in lockstep mode
      39. Lock step mode enabled
      40. InitTarget() end - Took 9.54ms
      41. Found SW-DP with ID 0x6BA02477
      42. DPIDR: 0x6BA02477
      43. CoreSight SoC-400 or earlier
      44. AP map detection skipped. Manually configured AP map found.
      45. AP[0]: MEM-AP (IDR: Not set, ADDR: 0x00000000)
      46. AP[1]: APB-AP (IDR: Not set, ADDR: 0x00000000)
      47. AP[2]: MEM-AP (IDR: Not set, ADDR: 0x00000000)
      48. AP[3]: AHB-AP (IDR: Not set, ADDR: 0x00000000)
      49. AP[4]: AHB-AP (IDR: Not set, ADDR: 0x00000000)
      50. AP[5]: AHB-AP (IDR: Not set, ADDR: 0x00000000)
      51. AP[6]: MEM-AP (IDR: Not set, ADDR: 0x00000000)
      52. AP[7]: MEM-AP (IDR: Not set, ADDR: 0x00000000)
      53. AP[4]: Skipped ROMBASE read. CoreBaseAddr manually set by user
      54. AP[4]: Core found
      55. ****** Error: DAP error while reading AIRCR.
      56. Error occurred: Could not connect to the target device.
      57. For troubleshooting steps visit: https://wiki.segger.com/J-Link_Troubleshooting
      Display All


      -If the reset pin is set to high, JLink is not able to read anything:

      Source Code

      1. Connecting to target via SWD
      2. ConfigTargetSettings() start
      3. ConfigTargetSettings() end - Took 12us
      4. InitTarget() start
      5. Unknown SDA AP Id detected: 0xFFFFFFFF
      6. InitTarget() end - Took 105ms
      7. Connect failed. Resetting via Reset pin and trying again.
      8. ConfigTargetSettings() start
      9. ConfigTargetSettings() end - Took 14us
      10. InitTarget() start
      11. Unknown SDA AP Id detected: 0xFFFFFFFF
      12. InitTarget() end - Took 105ms
      13. Error occurred: Could not connect to the target device.
      14. For troubleshooting steps visit: https://wiki.segger.com/J-Link_Troubleshooting
      Display All

      -The issue occurs on two pieces of hardware, of which one was in factory state, and I was unable to connect once I flashed the target with offending binary.
      -I've attached the logs I've created, there's a Saleae's logic analyzer files which contains dumps of SWD traffic.

      My questions:
      -How is it possible the JLink is unable to connect to the target, even if it is held in reset state? Does that mean that MCU is broken/bricked/locked-out somehow?
      -Does it look like MCU problem, or perhaps JLink's?
      -Is there a way to "unbrick" the devices?

      If something is unclear, please let me know.

      Thank you
      Files
      • logs.zip

        (21.46 kB, downloaded 422 times, last: )
    • Hi,

      We had same issue with S32K324.

      Our fix was to connect on another core (i.e. S32K324_M7_1) and erase from there.

      After that, we could connect to S32K324_M7_0 again.

      In our case HSE was not installed.