Kinetis K40 Flash Programming Failed"

cancel
Showing results for 
Search instead for 
Did you mean: 

Kinetis K40 Flash Programming Failed"

3,944 Views
gagangarg
Contributor II

Hi,

I am using Kinetis K40 Tower and Multilink Universal Debuuger to flash and debug the code in IAR. Unfortunately, I received the flashing error saying  "the flash loader program reported an error". Such flashing problem was not reported in past, It was working perfectly earlier. I tried Code Warrior to debug and flash the code but it says "Device Is secured". I have clicked YES in the pop up message to unsecure it but it failed and no code was downloaded.


In code warrior I have also tried to flash the code using the Flash Programmer  (Flash File to Target) and checked the option of Erase and Flash, somehow it completed successfully. Now when I tried the IAR again to check the debugging It shows the different error in which the "Flash Programming pop up window's bar" is not progressing and got stuck in the beginning.


I doubt that program loader in K40 gets corrupted due to  the option of erase and program the chip. I do not understand the cause of this fail in programming the flash. I request if anyone knows what has happened and how to rectify the situation. I would be grateful to you.


I have attached the screenshot of flashing error in IAR.

Thanks and regard,

Gagan

Tags (5)
0 Kudos
12 Replies

304 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

If you are using the TWR-K40X256 board, the K40 project Flash target need select to use [FLASH_256KB_PFLASH_256KB_DFLASH]. Please check attached picture for more detailed info.

For in your description, " It was working perfectly earlier", I think the P&E USB Multilink Universal driver should installed and successfully.

You also could try IAR provided Flash operation tool, you can find them at menu [Project] -> [Download].

And please check your IAR software version, if possible, you could updated it to the latest version Rev.6.50

Wish it helps.

0 Kudos

304 Views
gagangarg
Contributor II

Hi,

Very thanks for the support and time.

I have tried as you said by selecting FLASH_256KB_PFLASH_256KB_DFLASH, but still it is not flashing the target. I am using IAR V6.5 and also tried [Project] -> [Download] feature to program the flash, the process is hanged with the same error that is in "Programming the flash". It is not progressing and stuck in the beginning.

I am using the P&E USB Multilink Universal Debugger to program the Kinetis K40. The USB debugging port in TOWER is not working as the USB Connector is damaged. So, the only option I am left with is to debug using the P&E USB Multilink Universal.

I request if you can debug the error cause and help. I would be highly grateful to you.

Thanks & Regards,

Gagan Garg

0 Kudos

304 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I meet the problem with pop info "The flash loader program reported an error" when using P&E USB Multilink Universal tool debug with TWR-K40X256 board. More detailed info please check attached picture. While I could normally debug the [RAM_128KB] target project. Could you try to debug with [RAM_128KB] project and it works or not?  I need to check with IAR engineer about this issue. I will let you know when I could get any feedback.

0 Kudos

304 Views
gagangarg
Contributor II

Hi,

Very thanks for the support and concern.

Earlier I was getting error as "The flash loader program reported an error" when trying to Download & Debug in IAR using P&E USB Multilink Universal tool with TWR-K40X256 board. At that stage the Code Warrior was giving the pop info as "Device is Secure, Click to Unsecure". I have selected it to Unsecure the target in CW pop info, but the process got failed at the end. Somehow the efforts which CW made to unsecure the target caused the IAR to Successfully  Download and Debug the Flash.


But now I am facing the different error as "Programming the Flash" pop info is not progressing up in IAR with FLASH_256KB_PFLASH_256KB_DFLASH and also in Code Warrior the process is now getting hanged at the stage of  "Download Using 3rd Party Component". This type CW is not giving the error as "Device is Secure". It is trying and hang.


Please see the Console log message from the CW  when I tried to Flash the Target with Debug Configuration set to "INTERNAL_FLASH" at the end of this Message. I have attached the Debug Configuration Image and the hanged state of Code Warrior also.


Yes, the code gets downloaded with [RAM_128KB] configuration but I am not able to debug it properly and also it is not executing perfectly.  The SP and PC are pointing to a memory section which is reserved.


I am attaching the screenshot of the SP and PC state. Please have a look to it.


I highly appreciate your time and support. Please if you can help me in getting out of this I would be grateful to you.


Thanks & regards,


Gagan Garg

CW Debug Configuration.jpgProcess Hanged up CW.jpgIAR RAM DEBUG SP and PC.jpg

Console Log Messages (CW):


Executing Initialization File: F:\Work\k40_k20\KINETIS512_SC\k40-gpio/Project_Settings/Debugger/init_kinetis.tcl

radix x

thread break: Stopped, 0x0, 0x0, cpuARMLittle, k40-gpio.afx (state, tid, pid, cpu, target)

cmdwin::eclipse::config hexprefix 0x

cmdwin::eclipse::config MemIdentifier p

cmdwin::eclipse::config MemWidth 32

cmdwin::eclipse::config MemAccess 32

cmdwin::eclipse::config MemSwap off

cmdwin::reg DEMCR = 0x1000001

cmdwin::reg DWT_FUNCTION0 = 0x0

cmdwin::reg DWT_FUNCTION1 = 0x0

cmdwin::reg DWT_FUNCTION2 = 0x0

cmdwin::reg DWT_FUNCTION3 = 0x0

cmdwin::reg FP_COMP0 = 0x0

cmdwin::reg FP_COMP1 = 0x0

cmdwin::reg FP_COMP2 = 0x0

cmdwin::reg FP_COMP3 = 0x0

cmdwin::reg FP_COMP4 = 0x0

cmdwin::reg FP_COMP5 = 0x0

cmdwin::reg DWT_CTRL = 0x40000000

cmdwin::reg DWT_CYCCNT = 0x0

cmdwin::reg DWT_CPICNT = 0x0

cmdwin::reg DWT_EXCCNT = 0x0

cmdwin::reg DWT_SLEEPCNT = 0x0

cmdwin::reg DWT_LSUCNT = 0x0

cmdwin::reg DWT_FOLDCNT = 0x0

cmdwin::reg DWT_COMP0 = 0x0

cmdwin::reg DWT_COMP1 = 0x0

cmdwin::reg DWT_COMP2 = 0x0

cmdwin::reg DWT_COMP3 = 0x0

cmdwin::reg DWT_MASK0 = 0x0

cmdwin::reg DWT_MASK1 = 0x0

cmdwin::reg DWT_MASK2 = 0x0

cmdwin::reg DWT_MASK3 = 0x0

cmdwin::reg ITM_LAR = 0xc5acce55

cmdwin::reg ITM_TER = 0x0

cmdwin::reg ITM_TPR = 0x0

cmdwin::reg ITM_TCR = 0x0

cmdwin::reg ITM_LAR = 0x1

cmdwin::reg ETF_FCR = 0x300

cmdwin::reg MCM_ETBCC = 0x0

cmdwin::reg MCM_ETBRL = 0x0

cmdwin::reg SCB_VTOR = 0x20000000

cmdwin::reg SP = 0x20007FF8

0 Kudos

304 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I get the feedback from IAR engineer.

First, please check the General Options -> Target -> Device settings.

TWR-K40X256 board, please select * MK40DX256Zxxx10 product.

Then, Disable Debugger -> Download -> Override default .board file.

Please refer attached picture for detailed info.

After that, I could use P&E USB Multilink tool to debug the Flash target project.

When you debug the SRAM target, the correct PC address should be 0x1FFF0410.

I am quite doubt your TWR-K40X256 board status.

Do you have another Kinetis tower board? If yes, Could you try with that board.

0 Kudos

304 Views
gagangarg
Contributor II

Hi,

I have done as per the configuration you said, but still it is not working properly. The program is downloaded on the RAM but executing unexpectedly. The SP is pointing in reserved memory section and the PC is 0x1FFF0410 only in the beginning.

Do you think the processor is locked accidental and restricting in writing to Flash?

No, I don't have the other Tower kit.

Thanks,

Gagan


0 Kudos

304 Views
hesane
Contributor I

Hi gagan garg,

My custom application has the same issue that you reported here and I already tried to fix follow all orientations posted here but the issue continue happening.

I checked that K40 is not secured and I run the mass erase in CW. The code is loaded perfectly in my reference design of the Freescale but when I try to load the same code with the same IAR configurations and debugger PE Micro Multilink in my custom board the code keep "locked" in the crt0.s in debug mode running step by step (like your print screen of the crt0.s file that you attached here). The solution is not posted but did you solve this problem?

Could you help me?

Thanks!

Hesane

0 Kudos

304 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I don't think the K60 chip is secured.

If the K60 chip is secured, the debugger tool access internal memory is disabled.

If the K60 is secured, you also could not debug the RAM target.

Thank you for the attention.

0 Kudos

304 Views
gagangarg
Contributor II

Hi,

Thanks for the response and guidance.

I request If you can please help me in checking the Chip security and Flash Protection bits and what could be done to mass erase the chip or reset the chip to factory setting?

I appreciate your time and help.

Hope to hear from you soon.

Thanks,

Gagan

0 Kudos

304 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Have you tried with Freescale provided Kinetis 100MHz product example, you can download that example from below link:

KINETIS512_SC : Kinetis family example projects.

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=K40_100&nodeId=01624698C9DE2DDDAB&fps...

You can modify the <vectors.h> line 293 CONFG_4 vaule :

#define CONFIG_4 (pointer*)0xfffffffe

That could make sure the FTFL_FSEC registe with unsecure setting.

You also could upload your used example code, I could help you to check the chip secure configuration.

Wish it helps.

0 Kudos

304 Views
gagangarg
Contributor II

Hi,

I have downloaded the example codes from the site KINETIS512_SC.

The default value of CONFIG_4 in <vectors.h> is

#define CONFIG_4 (pointer*)0xfffffffe

Can you tell me what value to be assigned to CONFIG_4 and what does it will done?


Thanks,

Gagan

0 Kudos

304 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

CONFIG_4 value (0xfffffffe) will be put to flash configuration filed, located at 0x40C to 0x40F.

The 0xFE value will be programed to 0x40C address, which will be loaded to FTFL_FSEC register after chip reset.

FTFL_FSEC value is 0xFE, [SEC] bits are 0b10, which means MCU security status is unsecure.

You can refer reference manual Flash Security Register (FTFL_FSEC) for more detailed info.

Wish it helps.

0 Kudos