NXP MKV30F128xxx10 芯片RAM运行工程 擦除FLASH 扇区不成功

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

NXP MKV30F128xxx10 芯片RAM运行工程 擦除FLASH 扇区不成功

2,078 Views
yaoXin
Contributor II

您好,第一次使用NXP MKV30F128xxx10芯片,模仿pflash例程编写一个简单工程,pflash例程readme.txt文档如下:

pastedImage_1.png

工程在RAM中执行,使用IAR软件编译,ICF配置如下:

pastedImage_2.png

工程使用UART外设,自定义协议,UART通讯正常。

扇区擦除代码如下:

pastedImage_3.png

StartAddr地址设置过0x00000000, 0x00004000 ,FLASH_Erase函数 反馈均为错误。

查看FTFA_FSTAT寄存器,FLASH_Erase函数调用前为0x80,FLASH_Erase函数调用后为0xA0,位ACCERR变成1,

请帮忙分析一下原因,谢谢

4 Replies

1,947 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello,

Hope you are doing well. From my understanding , you are having trouble executing the flash erase command. Is this correct?

Could you confirm if you are able to execute the example without any modifications.

Best Regards,

Sabina

0 Kudos

1,947 Views
yaoXin
Contributor II

    另外在芯片地址0x400~0x40F中,如果原来这16个字节全部为0xFF,或者为其它任意值,但还允许Mass Erase,当更改启动文件Flash_Config中的值后,通过Jtag下载程序到芯片中后,能将地址0x400~0x40F中的配置值更新吗,如果不能更新,会是什么原因?

0 Kudos

1,947 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello,

First, any attempts to execute a flash command while in HSRUN mode it will be trapped with the ACCERR bit. Please refer to section 28.4.9.1 of the reference manual.

The original startup configuration is FE

pastedImage_1.pngThis means 

  • MCU security status is unsecure (The standard shipping condition of the flash memory module is unsecure)
  • NXP factory access granted
  • Mass erase is enabled
  • Backdoor key access disabled

If you change it to EC, then

  • MCU security status is secure
  • NXP factory access granted
  • Mass erase is disabled
  • Backdoor key access disabled

During the reset sequence, the register is loaded with the contents of the flash security byte in the Flash Configuration Field located in program flash memory.

1,947 Views
yaoXin
Contributor II

多谢回复!

    目前问题定位到,之所以擦除时出现ACCERR,是因为芯片处于HSRUN模式,此时Flash操作不生效,更改为RUN模式后擦除正常。

另外还有一个问题没有理解:

    FTFA_FSEC寄存器的值是上电后从Flash地址0x40C中读出来的,默认情况下这个地址的值在工程中设置为0xFE,

如果在工程里面将配置值改为0xEC,即MEEN位是0b10,SEC位是0b00,当这个程序下载进入芯片后,是不是意味着

程序再也无法正常启动了。在启动文件startup_mkv30f12810.c中配置如下所示:

pastedImage_1.png

0 Kudos