SEGGER J-Link script ResetTarget error: Invalid flash header detected

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

SEGGER J-Link script ResetTarget error: Invalid flash header detected

Contributor V


I am using a SEGGER J-Link to debug a target board based on the RT1021-EVK.

I have created a J-Link script based on the one in the SDK: SDK_2_12_0_EVK-MIMXRT1020\boards\evkmimxrt1020\demo_apps\hello_world

The problem is that when the J-Link server attempts to reset the target I see this error in the MCUXpresso console output for the J-Link Server:

Received monitor command: reset
ResetTarget() start
Invalid flash header detected.
Target halted on flash header read.
ResetTarget() end
AfterResetTarget() start
MPU was enabled and is now disabled.
AfterResetTarget() end
Resetting target
Downloading 16016 bytes @ address 0x81000000 - Verify failed
Downloading 16096 bytes @ address 0x81003E90 - Verify failed

If I add the empty function ResetTarget() to my script, so that the reset does nothing, the script runs fine. Without the dummy ResetTarget() I get the above error.

So what does the error 'Invalid flash header detected.' actually mean? Presumably it is referring to the flash on the target board?

I should point out that the flash on our target board is connected to the FlexSPI secondary pinmux option of the RT1021, not the default one. Would that make a difference?

If that is the problem, how do I fix it please? For example, do I need to add to the J-Link script the pin routing, config and pad settings for the FlexSPI secondary pinmux? I don't remember having to do anything like this for the LinkServer/LPC-Link2 equivalent.

Why does the ResetTarget() function need to read the flash?

Also why does the hello_world script need RestoreFlexRAM()? My equivalent script seems to work fine without it. What is the purpose of this please?

Many thanks,

Ronnie Shipman

Labels (1)
0 Kudos
1 Reply

NXP TechSupport
NXP TechSupport

Hi @rshipman,


The issue is most definately referring to the flash on the target board. The pinmux option shouldnt be a major difference, like to cause this issue. I advice you to take a look into the following community post about flash headers. I believe it will prove very useful for your inquiry:

With respect to the RestoreFlexRAM function, could you specify where this function is used?




0 Kudos