Use the internal flash to save data at runtime with MCUXpresso

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

Use the internal flash to save data at runtime with MCUXpresso

跳至解决方案
1,778 次查看
AndreVB
Contributor III

Hi NXP Team,

I have an KINETIS-based application being developed with MCUXpresso (MCU-Link debug probe). Of 64k FLASH I use 4k to save data. FLASH_LOWER for the code and FLASH_HIGHER to save data (see next image). Two questions:

1. Whenever I debug the whole Flash is erase. But I want to preseve FLASH_UPPER (my data) during the debbuging process. How can I do that? 

AndreVB_0-1642355149541.png

2.  In the final product, I want to protect my code (FLASH_LOWER). Don' t care about FLASH_LOWER (my data). How do I do that?

I have read these articles:

17.8.2 Kinetis MCUs – Flash Config Blocks

https://community.nxp.com/t5/Kinetis-Design-Studio-Knowledge/Relocating-Code-and-Data-Using-the-MCUX...

https://mcuoneclipse.com/2014/05/31/configuration-data-using-the-internal-flash-instead-of-an-extern...

I’ve looked through the documentation but I haven’t understood how I could use the MCUXpresso IDE to configure the flash accordingly. Any help is very welcome.

Thank you, Andre.

 

 

 

 

 

 

 

 

 

 

 

0 项奖励
1 解答
1,761 次查看
ErichStyger
Senior Contributor V

Hi @AndreVB ,

About 1): I don't see (at least with my IDE 11.4.1) the the LinkServer connection is erasing first all memory. I do have in many projects reserved a region at the end of the flash. But I simply reduce the flash size in the MCU settings:

ErichS_0-1642419844457.png

I can confirm that way for all debug connections I use (Segger J-Link, LinkServer McuLink & P&E Multilink) the FLASH that way does not get touched, showing with MinINI and McuFlash below (from https://mcuoneclipse.com/2021/12/19/key-value-pairs-in-flash-memory-file-system-less-minini/ )

ErichS_1-1642419986116.png

Maybe the thing you see is because you are using an older IDE? I remember (I think it was starting with 11.4) the LinkServer flashing has been optimized, not programming untouched sectors by default (something what J-Link always did, and P&E does now too, at least when I last checked). You could verify the flash operations in the Console view:

ErichS_2-1642420220729.png

 

About 2): on the KL25Z there are the FPROTx registers which can be used to protect each of the 32 regions of the flash memory (see chapter 27.4.1 Flash Protection) in the KL25Z reference manual.

 

I hope this helps,

Erich

在原帖中查看解决方案

0 项奖励
4 回复数
1,762 次查看
ErichStyger
Senior Contributor V

Hi @AndreVB ,

About 1): I don't see (at least with my IDE 11.4.1) the the LinkServer connection is erasing first all memory. I do have in many projects reserved a region at the end of the flash. But I simply reduce the flash size in the MCU settings:

ErichS_0-1642419844457.png

I can confirm that way for all debug connections I use (Segger J-Link, LinkServer McuLink & P&E Multilink) the FLASH that way does not get touched, showing with MinINI and McuFlash below (from https://mcuoneclipse.com/2021/12/19/key-value-pairs-in-flash-memory-file-system-less-minini/ )

ErichS_1-1642419986116.png

Maybe the thing you see is because you are using an older IDE? I remember (I think it was starting with 11.4) the LinkServer flashing has been optimized, not programming untouched sectors by default (something what J-Link always did, and P&E does now too, at least when I last checked). You could verify the flash operations in the Console view:

ErichS_2-1642420220729.png

 

About 2): on the KL25Z there are the FPROTx registers which can be used to protect each of the 32 regions of the flash memory (see chapter 27.4.1 Flash Protection) in the KL25Z reference manual.

 

I hope this helps,

Erich

0 项奖励
1,746 次查看
AndreVB
Contributor III

Hi Erich,

That´s works fine. Simpler than I thought. I was using IDE 11.4.1 and jut moved to IDE 11.5.0. Both working fine. For some reason using IDE 11.4.1, if I do not reduce the Flash size the appliction was mass erasing the memory prior debugging. With IDE 11.5.0, either reducing the flash size or keep it untouched the last sectors are preserved from one debug session to another.

Thank you,

AndreVB

标记 (1)
0 项奖励
1,767 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi @AndreVB ,

The MCUXpresso IDE will only erase erase affected sector when downloading code by default. You data will not be erased if the last sector is not overlapped by code. If you want to erase everything when programming, you can set in GUI Flash Tool.

jingpan_0-1642414699180.png

 

 

Regards,

Jing

0 项奖励
1,760 次查看
ErichStyger
Senior Contributor V

Hi @jingpan ,

If I'm not wrong: the settings you show are not used for the download/programming/debugging operation. They are only used if you press that 'Run' button in that dialog, otherwise I think these settings are ignored.

Let me know if I have that wrong?

Erich

0 项奖励