Preventing stored variables in flash from being erased when reprogramming?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Preventing stored variables in flash from being erased when reprogramming?

跳至解决方案
2,092 次查看
brettutesch
Contributor II

I'm using a KL16 with MCUXpresso 10.2 and I'm able to store/write/read my variables to flash (in the last 2KB of the 64KB using Flash_Program(...)).  Is there a setting to block MCUXpresso or the debugger from erasing these variables when reprogramming new firmware?

I've tried to create a new flash region in the last 2KB using the Memory Configuration Editor but my variables get erased.

0 项奖励
回复
1 解答
1,922 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Brett,

Yes, you can use "Non-Volatile Memory Preservation" :

If you want protect 0xF800- 0xFFFF , you can configure as below:

pastedImage_1.png


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,922 次查看
brettutesch
Contributor II

Sorry, I'm using a PE Multilink Universal FX.  I've defined the two sections:

Name                        Location      Size

Program_Flash         0x0            0xF800

Variable_Flash         0xF800      0x800

You mentioned I have to ensure the flash operation does not use mass erase.  Is this through the "Edit Configuration" of the ....PE Debug.launch (under the doc folder in the Project Explorer)? 

I see there is a "Non-Volatile Memory Preservation" under Debugger, Advanced Options.

0 项奖励
回复
1,923 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Brett,

Yes, you can use "Non-Volatile Memory Preservation" :

If you want protect 0xF800- 0xFFFF , you can configure as below:

pastedImage_1.png


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
1,922 次查看
lpcxpresso_supp
NXP Employee
NXP Employee

You didn't mention which debugger you're using, but the same principles apply. The K16 sector size is 1 KB. A sector is typically the smallest programmable/erasable block of memory. In order to get this to work, you need to redefine the flash memory into two flash blocks. It sounds like you've already done this.

The memory range of the first block is now 0x00000000-0x00007FFF. The memory range of the second block is 0x00008000-0x0000FFFF.

You have to ensure the flash operation does not use mass erase. Most debuggers (e.g. MCUXpresso) allow you to erase by sector.

Thanks and regards,

MCUXpresso Support

EDIT: Sorry, you said 2 KB persistent storage. In this case, the memory range of the first flash block is 0x00000000-0x0000F7FF, and the second is 0x0000F800-0x0000FFFF.

0 项奖励
回复