KM34Z256 flash erase sector problem

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

KM34Z256 flash erase sector problem

Jump to solution
1,869 Views
wulinweng
Contributor II

Dear support:

as I used the function below to erase sector 2K for KM34Z256VLQ7 in TWR-KM34Z75M development board, from the memory watch I can't find the flash is erased sucessfully. Can you provide some information for me?

thank you.

#if defined (__ICCARM__)
  __ramfunc void _FTFA_EraseSector (const void *pDst)
#elif defined(__GNUC__) || defined(__CC_ARM)
            void _FTFA_EraseSector (const void *pDst)
#endif
{
  if ((FTFA_FSTAT & FTFA_FSTAT_FPVIOL_MASK) ||
      (FTFA_FSTAT & FTFA_FSTAT_ACCERR_MASK)) { FTFA_FSTAT |= 0x30; }
  FTFA_FCCOB0 = 0x09;
  FTFA_FCCOB1 = (uint8)((uint32)pDst>> 16);
  FTFA_FCCOB2 = (uint8)((uint32)pDst>>  8);
  FTFA_FCCOB3 = (uint8)((uint32)pDst>>  0);
  FTFA_FSTAT |= FTFA_FSTAT_CCIF_MASK;
  while (!(FTFA_FSTAT & FTFA_FSTAT_CCIF_MASK));
}

Labels (1)
1 Solution
1,407 Views
MarMi
NXP Employee
NXP Employee

Hello Wulin,

MKM34Z256 bare-metal drivers and examples disables /NMI interrupt by default in order to eliminate this non-maskable interrupt to occur. However, this is not happening in your project because your project is configured not to program flash configuration field (0x40c-0x40f) where /NMI interrupt should be disabled by writing FTFL_FOPT[2]=0.

In order to correct your existing project, you need to use attached RCM.board file (with extra parameter: --enable_config_write) and override your existing one - see below. 

pastedImage_1.png    

When you're creating new project next time please use make_project.exe utility that is delivered with bare metal drivers. This utility will create new project with all necessary links to drivers including reference to a specific board file. You might also consider using new drivers release for your new developments (release 4.1.5).

Kind regards,

Martin M.

View solution in original post

10 Replies
1,407 Views
MarMi
NXP Employee
NXP Employee

Dear Wulin,

based on the information you provided it is hard to provide any reasonable suggestion on what else to try; the problem could be in the sector definition in linker command file, debugger interaction during erase operation, etc. Therefore, please try our example called ftfa_test from the latest bare-metal drivers for MKM34Z256 device family... You can download drivers from our web KMSWDRVAPIRM_SW. The documentation for example is attached to this reply for your convenience - you can find it also in readme.html that installs together with drivers. The example source code will install in KM256SWDRV_R4_1_5/src/Projects/ftfa_test subfolder.

Please try to run this example on your board and if this one fails then we will start looking for potential problems.

Kind regards,

Martin M.

1,407 Views
wulinweng
Contributor II

Dear Martin,

the demo which you provided me is ok, it means that the hardware board is ok, but in my project is not ok, I have copy that code to the main() function at the first line, it can't erase either. So I don't know when do the flash operation is there any setting before the main() function?

thank you.

br

0 Kudos
1,407 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Wulin,

   Please disable the global interrupt before you do the flash operation.

   If it is still not ok, please upload the project, I would like to help you to check it.


Have a great day,
Jingjing

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

0 Kudos
1,407 Views
wulinweng
Contributor II

Mike-WuLin Weng

ABB Xiamen Low Voltage Equipment Company Limited

No.12-20, 3rd Chuang Xin Road Xiamen SEZ, Fujian 361006 P.R.China

Phone: +86 592 5767829

Mobile: +86 181 5089 0831

email: mike-wulin.weng@cn.abb.com<mailto:mike-wulin.weng@cn.abb.com>

0 Kudos
1,408 Views
MarMi
NXP Employee
NXP Employee

Hello Wulin,

MKM34Z256 bare-metal drivers and examples disables /NMI interrupt by default in order to eliminate this non-maskable interrupt to occur. However, this is not happening in your project because your project is configured not to program flash configuration field (0x40c-0x40f) where /NMI interrupt should be disabled by writing FTFL_FOPT[2]=0.

In order to correct your existing project, you need to use attached RCM.board file (with extra parameter: --enable_config_write) and override your existing one - see below. 

pastedImage_1.png    

When you're creating new project next time please use make_project.exe utility that is delivered with bare metal drivers. This utility will create new project with all necessary links to drivers including reference to a specific board file. You might also consider using new drivers release for your new developments (release 4.1.5).

Kind regards,

Martin M.

1,407 Views
wulinweng
Contributor II

Hello Martin,

when created the project, the project will used the default project.board, but if I change the IAR .eww file, and open the project, add the IAR .ewp file to the workspace, and it can't use the project.board in the created project foder, what I question is If I want to change the eww file name after created the project used make_project.exe, how can I make sure the project.board will be used in the new name project.

0 Kudos
1,407 Views
MarMi
NXP Employee
NXP Employee

Hello Wulin,

Please refer to this thread: Renaming in IAR Embedded Work Bench - Stack Overflow.

If you're opening new project often or see this feature useful, we can update make_project.exe to generate project files named as (project.*) or optionally ("project_name".*) where "project_name" is the information entered by the user during new project creation.

Kind regards,

Martin M.

0 Kudos
1,407 Views
wulinweng
Contributor II

Hello Martin,

Thank you for your reply and this is the reason.

I have followed your step and fix the issue, after that I have created new project with release driver 4.1.5 and transfer

my source files to this new project, it seems everything is fine.

Thank you & BR,

0 Kudos
1,407 Views
wulinweng
Contributor II

Dear all,

thank you all for so quick reply, unfortunately the problem is still exist.

I have checked the ICF file and disable the interrupt before erase the sector operation, it still not ok.

I will send the project through the email latter.

BR,

0 Kudos
1,407 Views
MarMi
NXP Employee
NXP Employee

Dear Wulin,

I think that issue might be in a linker file because the ftfa_test project uses specific linker file located in the project build subfolder named MKMxxZ256_flash_FTFA.icf .

This file, among others, defines symbol (define symbol __CONFIG_FLASH_BLOCK__ = 0x0003f800;) and place .config section at this address (place at address mem:__CONFIG_FLASH_BLOCK__   { readonly  section .config };) 

If this linker procedure is included in your code, I am afraid, I will have to look more deeply into your project to understand better the issue.

Kind regards,

Martin M.