2425175_en-US

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2425175_en-US

2425175_en-US

S32K358: Flash programming fails / CPU cannot be halted (PEmicro & J-Link)

Hi NXP Team / Community,

I am experiencing an issue where I cannot flash or recover my S32K358 board using either PEmicro (in S32 Design Studio) or SEGGER J-Link Commander. The debuggers are able to communicate with the ARM CoreSight DAP, but flash programming fails, and the CPU cannot be halted.

1. Environment:

  • MCU: NXP S32K358
  • IDE: S32 Design Studio for S32 Platform v3.6.6
  • Debug Probes:
    1. PEmicro Multilink / OpenSDA (Plugin version 6.2.4)
    2. SEGGER J-Link Lite V9 (DLL v9.90)
  • Interface: SWD (500 kHz / 1000 kHz)
  • Project: FreeRTOS Toggle LED Example

2. Symptoms & Observed Behavior:

A. PEmicro in S32 Design Studio:

When launching the debug session, PEmicro connects to the SWD interface, verifies the DAP ID (0x6BA02477), but flash programming fails:

           INFO: DAP IDCODE = 0x6BA02477
           PEmicro GDB Launch Failure : Error during flash programming. Terminating debug                       session.
           PE-ERROR: Error downloading to the device. Terminating debug session.
 
  • If I attempt to use the "Device Recovery by Full Chip Erase" option in S32DS, PEmicro returns:

    "Warning - mass erase not supported. Please contact PEmicro for support."

B. SEGGER J-Link Commander:

In J-Link Commander, the probe detects the DAP and unlocks the device:

InitTarget() start
SDA_AP detected
Unlocking device if necessary...
Locked device detected. Proceeding with the unlock procedure...
Device successfully unlocked
Found SW-DP with ID 0x6BA02477
CPUID register: 0x411FC272
Found Cortex-M7 r1p2, Little endian.

However, when attempting to halt the CPU or run erase:

SetupTarget() start
WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.
Initializing ECC RAM...
Timeout while initializing ECC RAM
WARNING: CPU could not be halted
****** Error: Could not start CPU core. (ErrorCode: -1)
Cannot read register 0 (R0) while CPU is running

J-Link> erase
'erase': Performing implicit reset & halt of MCU.
WARNING: CPU could not be halted
****** Error: Failed to halt CPU.
Erasing device...
WARNING: CPU could not be halted
Cannot access the watchdog SWT0 instance.
****** Error: Failed to preserve target RAM @ 0x20000000-0x20007FFF.
ERROR: Erase returned with error code -1.


3. What Has Been Checked:

  1. The hardware SWD connections and power are functional (DAP ID = 0x6BA02477 and CPUID = 0x411FC272 are read correctly).
  2. The device is not permanently secured (J-Link confirms device unlock with default passwords).
  3. PEmicro default algorithm nxp_s32k358_1x32x2036k_hse_disabled.arp is selected.

4. Questions:

  1. What is the recommended recovery procedure to halt an S32K358 whose flash contents trigger an immediate HardFault/Lockup or watchdog reset loop?
  2. Since mass erase is unsupported on S32K3, how can we force-erase the flash sectors via PEmicro or J-Link when the core refuses to halt into RAM?
  3. Is there a specific reset sequence or script needed for S32K358 to bypass early application execution and restore flash access?

Thank you for your assistance.

 

Re: S32K358: Flash programming fails / CPU cannot be halted (PEmicro & J-Link)

Hi @shreevalya135,

Can you try the solution from this thread:
https://community.nxp.com/t5/S32-SDK/failed-to-power-up-dap-after-program-s32k312-with-pll0-equal/td...

The log is different, but I'm wondering whether using JTAG instead of SWD and keeping the MCU in reset could resolve the issue.


Regards,

Daniel

Re: S32K358: Flash programming fails / CPU cannot be halted (PEmicro & J-Link)

Hi @shreevalya135,

Thank you for the details.

2 & 3.

The debuggers use proprietary SEGGER and PEmicro algorithms. You could also contact them for more details about the logs.

1.

It is difficult to say. The onboard debugger is also a PEmicro debugger. Theoretically, the SRAM could be damaged, preventing the debugger from loading the data and programming routines required to erase and program the MCU.

4 & 5.

We do not have any recommended scripts. Can you access the MDM-AP status and control registers using J-Link Commander?

// Select MDM-AP
SWDWriteDP 2, 0x06000000

// Read MDMAPSTTS and MDMAPCTL
SWDReadAP 0
SWDReadAP 0
SWDReadAP 1
SWDReadAP 1

// Write MDMAPCTL
SWDWriteAP 1 0x100 // Cortex-M7_0 debug request

Best regards,

Daniel

Re: S32K358: Flash programming fails / CPU cannot be halted (PEmicro & J-Link)

Hi @danielmartynek ,

Thank you for your suggestions. We tested both JTAG and SWD interfaces at 1000 kHz, with the reset line both asserted (r0) and released (r1).

Hardware and Debug Configuration:

  • Board: FRDM-S32K358 EVK

  • MCU/Core: S32K358 / S32K358_M7_0

  • IDE: S32 Design Studio 3.6.6

  • Onboard debugger: J11 USB-C

  • External debugger: SEGGER J-Link Lite V9 (V8.88)

  • External connection: J9 (JP11 removed)

  • Target voltage: 3.3 V

Test Results:

Configuration Result

JTAG + Reset assertedFailed
SWD + Reset assertedFailed (DAP power-up error)
JTAG + Reset releasedFailed
SWD + Reset releasedSuccessful SW-DP and Cortex-M7 detection

Although SWD detects the target successfully, ECC RAM initialization fails.

Additional Tests:

  1. NoDTCM0Init script: ECC RAM initialization still times out at 0x20000010, followed by CPU halt failure.

  2. NoRAMInit script: Target initialization completes, but the CPU cannot be halted. The reported PC is 0x200002B8.

  3. Memory access: Internal flash read at 0x00400000 succeeds, but SRAM read at 0x20400000 fails.

  4. Original Programming Failure Through J11 USB-C

    Programming through the onboard debugger fails with the following errors:

    • CRC Command Timed Out

    • Current content of flash does not match application to be programmed

    • Error Erasing flash of device

    We tested both HSE-disabled and HSE-enabled .arp flash programming algorithms, but the issue persists.

Support Required:

We would appreciate your guidance on the following:

  1. Why did the previously working board suddenly stop supporting flash programming through the onboard J11 debugger?

  2. What could cause the CRC Command Timed Out and flash erase errors?

  3. Why does ECC RAM initialization fail even with the NoDTCM0Init script?

  4. Why can the debugger initialize the target with NoRAMInit but cannot halt the CPU?

  5. Are there any recommended S32K358-specific J-Link scripts or debugger configurations for this EVK?

Is there a recommended recovery procedure to restore the onboard debugger and normal flash programming?

Thank you for your support. We look forward to your suggestions.

Re: S32K358: Flash programming fails / CPU cannot be halted (PEmicro & J-Link)

Hi @danielmartynek,

Thank you for your response and suggestions.

I am using an external SEGGER J-Link Lite V9 connected to the J9 connector of the FRDM-A-S32K358 board. I have performed the suggested debugging and MDM-AP access tests. Below are the complete connection details and results.

1. Complete J-Link Connection Output

Commands executed:

exec ForceAttachTarget=1
device S32K358_M7_0
si SWD
speed 800
connect

Connection output:

Device "S32K358_M7_0" selected.

Connecting to target via SWD
ConfigTargetSettings() start
ConfigTargetSettings() end - Took 63us
InitTarget() start
SDA_AP detected
Unlocking device if necessary...
  Device is not locked. Proceeding without the unlock procedure.
Checking if debug access is already enabled...
  Debug access is not enabled yet. Performing enable debug access sequence...
  Debug access enabled
Checking if HSE firmware is installed...
  HSE firmware not installed
Checking if Cortex-M7_0 and Cortex-M7_1 are operating in lockstep mode
  Lock step mode enabled
InitTarget() end - Took 144ms

Found SW-DP with ID 0x6BA02477
DPIDR: 0x6BA02477

CoreSight SoC-400 or earlier
AP map detection skipped. Manually configured AP map found.

AP[0]: MEM-AP (IDR: Not set, ADDR: 0x00000000)
AP[1]: APB-AP (IDR: Not set, ADDR: 0x00000000)
AP[2]: MEM-AP (IDR: Not set, ADDR: 0x00000000)
AP[3]: AHB-AP (IDR: Not set, ADDR: 0x00000000)
AP[4]: AHB-AP (IDR: Not set, ADDR: 0x00000000)
AP[5]: AHB-AP (IDR: Not set, ADDR: 0x00000000)
AP[6]: MEM-AP (IDR: Not set, ADDR: 0x00000000)
AP[7]: MEM-AP (IDR: Not set, ADDR: 0x00000000)

AP[4]: Skipped ROMBASE read. CoreBaseAddr manually set by user
AP[4]: Core found

CPUID register: 0x411FC272
Found Cortex-M7 r1p2, Little endian.

CoreBaseAddr manually set by user: 0x40250400

SetupTarget() start
-- Attach mode active. Skipping halting core & work RAM init (https://kb.segger.com/NXP_S32K3xx#ECC_RAM).
SetupTarget() end - Took 87us

Memory zones:
  Zone: "Default" Description: Default access mode

Cortex-M7 identified.

2. CPU and Memory Access Results

After connection, executing h and regs shows invalid CPU register values:

PC   = CDCDCDCD
SP   = FFFFFFFD
XPSR = CDCDCDCD
IPSR = 00D (Reserved)

Memory access tests:

Address Result

0x00400000Successful
0x00402000Failed
0x20000000Successful
0x20400000Failed

3. MDM-AP Register Access Results

I also tried the suggested MDM-AP operations:

SWDWriteDP 2, 0x06000000
SWDReadAP 0
SWDReadAP 1
SWDWriteAP 1, 0x100

All operations returned ERROR, including MDM-AP register reads and writes.

4. Additional Observation

Without attach mode, J-Link fails during ECC RAM initialization and reports:

Could not start CPU core. (ErrorCode: -1)

5. Recovery Guidance Required

Could you please advise on the following?

  1. Why does MDM-AP access fail even though SW-DP detection and debug access enablement are successful?

  2. How can I recover the Cortex-M7_0 core when ECC RAM initialization fails?

  3. Can internal flash be erased and reprogrammed through a hardware-level recovery mechanism without successfully starting the CPU?

  4. Is there a recommended procedure to restore normal debugging and flash programming functionality without replacing the board?

Our objective is to recover the FRDM-A-S32K358 board and restore normal debugging and flash programming functionality.

We would kindly request your support and guidance in identifying the cause of this issue and recommending the appropriate recovery procedure. Any assistance or suggestions would be greatly appreciated.

Thank you for your time and support.

Best regards,
Shreevalya

Re: S32K358: Flash programming fails / CPU cannot be halted (PEmicro & J-Link)

Hi @danielmartynek,

Thank you for your suggestions and continued support. We kindly request your further assistance in recovering our FRDM-A-S32K358 board.

For clarification, I am using an external SEGGER J-Link Lite Cortex-M debugger.

Product link: https://www.segger.com/products/debug-probes/j-link/models/j-link-lite/j-link-lite-cortex-m/

The J-Link is connected to the J9 connector, with the JP11 jumper removed, and I am using the SWD interface.

I have tried J-Flash Lite V8.88 and J-Link Commander V9.90.

Using J-Flash Lite, I programmed the SDK LED Blinky example .bin file. It reported successful erase and programming ("Application dumped successfully"), but the LED Blinky application does not execute on the board.

Additionally, I tried the MDM-AP commands suggested in your previous response:

SWDWriteDP 2, 0x06000000
SWDReadAP 0
SWDReadAP 1
SWDWriteAP 1, 0x100

However, all commands returned errors, and I could not access the MDM-AP registers.

However, the issue persists even with the external J-Link. The debugger detects the target, but ECC RAM initialization fails and the CPU cannot be halted.

Could you please suggest any recommended J-Link model or alternative external debugger suitable for recovering the S32K358? Also, is there any alternative recovery procedure available when the CPU cannot be halted and MDM-AP access fails?

Thank you for your continued support.

Re: S32K358: Flash programming fails / CPU cannot be halted (PEmicro & J-Link)

Hi @shreevalya135,

I cannot explain why you are able to load an image but cannot read the MDM-AP registers.

I can run the script successfully on the S32K358.

device S32K358
si SWD
speed 4000

connect
sleep 100

// Select MDM-AP, bank 0
SWDWriteDP 2, 0x06000000
sleep 20

// Read MDMAPSTATUS and MDMAPCTL
SWDReadAP 0
SWDReadAP 0
SWDReadAP 1
SWDReadAP 1

Can you measure the RESET_B pin to determine whether it is being asserted periodically?


Thank you,

Daniel

Re: S32K358: Flash programming fails / CPU cannot be halted (PEmicro & J-Link)

Hi @danielmartynek,

Thank you for your response and continued support.

I have measured the RESET_B pin voltage on the FRDM-A-S32K358 board. The measured voltage is 0.0 V when the reset button is pressed and 3.3 V when released.

Additionally, I connected the external SEGGER J-Link to the board and repeated the same measurements to check whether the debugger connection was causing any reset-related issue. The results remained the same: 0.0 V when pressed and 3.3 V when released.

Could you please guide us on the next steps to further diagnose and recover the board?

Thank you.

Best regards,
Shreevalya

Re: S32K358: Flash programming fails / CPU cannot be halted (PEmicro & J-Link)

Hello @shreevalya135,

At this point, we cannot determine the exact root cause from the available information. The debugger can identify the SW-DP and Cortex-M7, but it cannot halt the CPU, initialize ECC RAM, or access the MDM-AP.

The debugger reset sequence should return the MCU to its reset state before programming. Therefore, an application previously programmed into the device, even if it configured an incorrect system clock or reconfigured the JTAG/SWD pins, should not permanently prevent recovery, provided that RESET_B and the debug interface are functioning correctly. The measurements also do not indicate that the MCU is repeatedly asserting RESET_B after power-on reset.

Since the same behavior is observed with both PEmicro and SEGGER J-Link, and MDM-AP access is unavailable, we suspect that the MCU. Based on the current evidence, we cannot recommend a further software or debugger procedure to recover this device.

If the issue cannot be reproduced on multiple S32K358 boards using the same debuggers, connections, configuration, and application images, we can reasonably exclude the debugger, image, and common configuration as the primary causes. In that case, the affected MCU should be considered damaged. Theoretically, this damage could have been caused by an ESD event or another electrical overstress event.


Regards,

Daniel

Tags (1)
No ratings
Version history
Last update:
Saturday
Updated by: