Confused with flash's erasing and programing

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

Confused with flash's erasing and programing

1,663 Views
ayanosun
Contributor II

I'm using KEAZ128 and S32DS, and below are my main functionmain.PNG

linker filememory.PNG

section setting

section.PNG

and data defination.data.PNG

What my problem is that I can erase and program the sector after 0x4000 when there is no flash_data's defination and .mytext section setting. And once I allocate flash_data in the .mytext section, I can't erase and program the sector after 0x4000 anymore. Please help. Project attached.

Labels (1)
0 Kudos
Reply
8 Replies

1,288 Views
peter308
Contributor II

My problem is how to read the flash value when the power is turned on after the power is turned off.

0 Kudos
Reply

1,288 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Peter,

  Read the flash is very simple, just read the address, and get the address data is OK.

  If you still have question about it, please create the new question post for yourself, don't follow other's question post.

   If you still want I to reply you, in your own post, you can add assign to kerry zhou, thank you!


Have a great day,
Kerry

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

1,288 Views
peter308
Contributor II

Hi Kerry :

I am running this program no problem but I delete it.
FLASH_EraseSector(VERIFIED_SECTOR*FLASH_SECTOR_SIZE);

Read flash but read 0

My problem is how to read the flash value when the power is turned off after the power is turned off.

0 Kudos
Reply

1,288 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Yan Sun,

     How do you test it, do you just debug the code and check the memory data?

    If yes, it's the IDE's problem, when you use the __attribute__ ((section(".mysection1"))) uint32_t flash_data[128]; The IDE seems protect the memory according address.

  Actually, I also use the printf to see the data, I find the flash erase and program all works.

   Please check my test result and the attached code:

1. Erase

pastedImage_1.png

You can find the memory still 0 after erase, but the printf data is 0XFF, it's correct.

2. Program.

pastedImage_2.png

Please use my attached project.

In the optimization, please don't select the data section, do it like the following code:

pastedImage_3.png

1,288 Views
ayanosun
Contributor II

我在每个节点前后用数组都出来试了一下,结果如下:

擦除前

擦除前.PNG

擦除后

擦除后.PNG

写入后

写后.PNG

就结果来看好像擦除是可以的,但是写入并没有成功。

0 Kudos
Reply

1,288 Views
kerryzhou
NXP TechSupport
NXP TechSupport

楼主,你测试我给你的代码呢。

然后你用串口接收打印就知道了,我的代码我昨天已经测试过了,其实就是比你多了打印功能,不能光相信IDE的debug信息查看。我个人认为S32DS不够成熟,之前这种功能我在CW, KDS, MCUXpressoIDE上面都没遇到过。


Have a great day,
Kerry

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

0 Kudos
Reply

1,288 Views
ayanosun
Contributor II

这个我再多验证一下。还请教一个问题,就是将函数拷到RAM运行是怎么实现的,还是说就是直接将函数用__attribute__分配到ram中就行了?谢谢

0 Kudos
Reply

1,288 Views
kerryzhou
NXP TechSupport
NXP TechSupport

对的,其实和flash的操作一样,就是在ld文件中分配的区域是RAM区域。


Have a great day,
Kerry

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

0 Kudos
Reply