Jtag flashing issue: Not able to flash device, Erase/read back works sometime.

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

Jtag flashing issue: Not able to flash device, Erase/read back works sometime.

4,272 Views
Ankit_Rana
Contributor II

Hi Support team,

Setup environment: 
Using s32k144 MCU with JTAG and Jflash tool. 
Able to connect with the MCU. connections are fine. having two device. In one everything is working. 
Before erasing we unsecure the device and performed mass erase. see the attached snip.
in second device consider below behavior: 

flash operation:
Erase/read chip or sector -> working only when after connecting with MCU immediately erase, 
program and verifying -> not working (If we fire only program command, pop for success is coming, when read the chip everything is FF only. not flashing)

please go through the logs attached here. showcases the connect, erase, program and verify and read back operation logs. 

Suspect list: 
As whole chip is erased, flash configuration is 0xFF(so the device is unsecure), interrupt/vector table address are 0xff, text segment or code flash is 0xff. 

Ankit_Rana_0-1705068118117.png

I have tried to write the configuration registers manually using jlink commander CLI interface, using memory write and read commands as shown below. values of flash configuration registers are taken from .s (startup file)

/* Flash Configuration */
.section .FlashConfig, "a"
.long 0xFFFFFFFF /* 8 bytes backdoor comparison key */
.long 0xFFFFFFFF /* */
.long 0xFFFFFFFF /* 4 bytes program flash protection bytes */
.long 0xFFFF7FFE /* FDPROT:FEPROT:FOPT:FSEC(0xFE = unsecured) */

.text
.thumb

manual_configuartion_reg_set.PNG

MDM-AP status register value: 0x0001003B. Please interpret the value and help me to understand if the device can be fixed. 
Please provide your inputs to find the root cause of the issue and fix the device. 
@Jiri @ZhangJennie @BlackNight @Robin_Shen @VaneB  @mariuslucianand @jingpan @jay_heng 
@danielmartynek @Alexis_A 

Attached Jflash error snips below and Jlash tool logs.  

Ankit_Rana_1-1705069884523.png


Performed unlocking sequence:

Ankit_Rana_2-1705070432689.png

 

erase_working.PNG

fail_to_program.PNG

faiuled_to_target_program.PNG

flashing_issue.PNG





0 Kudos
Reply
4 Replies

4,252 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Ankit_Rana,

As discussed in this (Solved: Re: How to unlock S32K148 Chip - NXP Community) community post, writing to this register without taking care of the bits written will lock the MCU without the recovery option, please try these steps as well. 

You can look into this in-depth guide for the S32K1: S32K1xx Series MCU Application Guide - Chip Lockup Reset Cause Analysis and Recovery Methods Explain... for steps in how to determine whether the MCU can be unlocked or restored, as well as MDM-AP Status registers explanations.

Best regards,
Julián

 

0 Kudos
Reply

4,209 Views
Ankit_Rana
Contributor II

Hi Support team,

I was able to resolve the issue and was able to flash the chip. It was working as expected. 
But again, when I tried it is giving the same readout protection set error.

I have read MDM_AP status register. the value is 0x00000037. as per the status register table. 
bit_0(flash memory mass erase ack) is SET
bit_1(flash memory ready) is SET
bit_2(system security) is SET
bit_3(system reset ) is 0 
bit_5 (mass erase enable) is SET. 
bit_6(back door access key) is 0 (disabled) 

it seems now the security bit is set, and mass erase is not completing, it has started the mass erase operation as per bit_0. 
Is there any way to disable the security and do the mass erase. 

Ankit_Rana_0-1705466690074.png

 

 

0 Kudos
Reply

4,168 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Ankit_Rana,

Disabling security is not needed if a mass erase is requested, as invoking the mass erase will cause the entire flash to be erased even if security is enabled or regions are protected (AN12130: Production Flash Programming Best Practices for S32K1xx MCUs). Only situation where security enable is a problem is when mass erased is disabled and no backdoor key is set.

Is mass erase not completing even when trying the "Emergency Kinetis Device Recover by Full Chip Erase" option in Debug configuration through S32DS?

Julin_AragnM_0-1705694834560.png

Best regards,
Julián.

0 Kudos
Reply

3,981 Views
Ankit_Rana
Contributor II

Hello there Geeks, 

I was facing flash protection issues, I was able to understand the root cause. 
in earlier problems mass erase was enabled and protection was set. 
So I was able to unsecure the device using Jlink command line interface and procedure shown in one thread of NXP community. I made one document of the process and attached here. 

I have attached document please go through it. it is showing my understanding on this issue and how to recover. please let me know if anything is wrong in my understanding. 
Now I'm having device in below state: 

It says :Protection is set but mass erase is disabled. J-Link cannot unprotect the device.Ankit_Rana_0-1710850883555.png
Device went into this state while working on boot loader and application. 
(as mentioned in attached document I'm not modifying startup file/.S file) , So all flash configuration fields are as it is. startup file of boot loader and startup file of application is not modified at all. 

Ankit_Rana_1-1710851102399.png

Please let me know if there is any way out and get the device back in normal state. 
Please go through attached document and let me know what I should take care so other device will not get damaged.


Tags (1)
0 Kudos
Reply