run Flash always restart。
run Ram is OK。
When I run your code the FTFC Read Collision Error Flag FSTAT[RDCOLERR] is set.
In the RM rev 12.1 can be seen this description:
"The RDCOLERR error bit indicates that the MCU attempted a read from an FTFC resource that was
being manipulated by an FTFC command (CCIF=0). Any simultaneous access is detected as a collision
error by the block arbitration logic. The read data in this case cannot be guaranteed."
"Do not attempt to read a flash block while the FTFC is running a command (CCIF = 0)
on that same block. The FTFC may return invalid data to the MCU with the collision
error flag (FSTAT[RDCOLERR]) set."
It seems that something interrupted the FTFC command. When I disable global interrupts "INT_SYS_DisableIRQGlobal();" before the FTFC command ("FLASH_DRV_DEFlashPartition") the code is running without an error.
However, it is up to you to find out what attempted to read a flash block while the FTFC is running a command (CCIF = 0)
I suggest checking the flags in the FSTAT register always when you have some issue related to the FTFC commands.
I hope it helps.