Can't program or erase flash of S32K148 using ULINKpro and Keil IDE

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

Can't program or erase flash of S32K148 using ULINKpro and Keil IDE

2,217 Views
tomasfrcek
Contributor III

Hello,

I have a S32K148EVB-Q144 board with which I have been toying for some time. I'm using Keil IDE and ULINKpro to develop and download/debug software. Up until now, everything was working fine.

But today I tried to configure the CLKOUT pin to mirror the clock signal from PLL. After that, I could no longer download or erase the program flash in Keil IDE using ULINKpro programmer. I tried every available SW clock, but no luck.

I remember a similar problem with a LPC1769 MCU, where the chip entered an unstable state right after reset and I could no longer reprogram it nor erase it either. I was able to solve this by erasing the entire flash using the FlashMagic software. However, FlashMagic does not support the S32K148.

I looked into the manual and found the following:

In addition, the entire flash memory can be erased from the external SWJ-DP debug port
according to this sequence:
1. Set MDM-AP Control[0].
2. MDM-AP Status[0] sets to indicate the mass erase command has been accepted.
3. MDM-AP Status[0] clears when the mass erase completes.

But I have no idea how to perform these steps.

Please, help me solve this issue!

Thanks!

0 Kudos
1 Reply

1,146 Views
robertboys
Contributor IV

Hello

I do not know about the CLKOUT pin and how it would affect flash programming but here is some information that may be useful:

1)  Keil uVision programs registers such as MDM-AP "under the hood" to program the target flash.  You should be careful using these registers yourself in case you inadvertently secure the processor and disable Mass Erase.

2)  The flash components (aka macrocells) are provided by the chip manufacturer and not Arm. Therefore, it is possible that NXP LPC and Freescale Kinetis and S32K flash are different. You would have to look this up.

3)  You must be careful to not put unknown data into the register in the FSEC register if you develop your own flash algorithms else your processor can be turned into a brick.  Any program in it will still run but access with a debug probe is futile.  This is to prevent someone hacking into your processor.

4)  Here is the S32K Flash config in the CMSIS file startup_SK32K148.s.  Click on the Configuration Wizard tab at the bottom and you can see how you can set the configuration:  Kinetis parts have a similar window.

TIP: you can create Config Wizards for your own sources:  µVision User's Guide: Configuration Wizard 

pastedImage_1.png

5)  How to do a Mass Erase in Keil uVision:

a) When entering debug mode, uVision detects device is secure and asks you if you want target mass erased.

b)  In main menu, select Flash / Erase. Mass Erase is used to accomplish this.

c)  In the Utilities tab, select Settings and this window opens: selecting Erase Full Chip uses Mass Erase when the uVision Flash programming is done with the Load icon/ selection or you enter Debug mode.  See below:

Note:  A Mass Erase without programming the FSEC option locks the device.  uVision will automatically perform this function.

6)  A Kinetis flash appnote has parts that might be useful:  Application Note 220: Memory Configuration on Freescale Kinetis devices 

I hope this helps

Bob Boys

Arm/Keil

San Jose, California

pastedImage_3.png