MPC5634M Flash erase Problem

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

MPC5634M Flash erase Problem

1,958 Views
dennisyuan
Contributor III

Hi ,

There's  a problem about the MPC5634M Flash erase blocks in my MPC5634M project. I have integrated the SSD flash driver which is :Standard Software Driver v1.0.3 (xPC56xx_C90LC) in my code ,and the program running process is:  

(1)Firstly ,erase the block 2 (address ;0x00008000),then write 96 bytes from address 0x00008000 ,write success.

(2)secondly,erase the block 3 (address ;0x00010000),then write  from address 0x00010000 ,write success.

(3)I want to erase the block 2 (address ;0x00008000),and write 96 bytes from address 0x00008000 again   ,the erase result  seems is ok ,but I feel this erase operation is fail.

This fail case is : the return value of the Erase  function is C90FL_OK ,but actually the block 2 which I want to erase  is not erased . that means the last value still in the block 2. the all value didn't change to 0xFF .

I use the API is C-array FlashErase_C, which in the path : Freescale\Standard Software Driver v1.0.3\xPC56xx_C90LC\Driver\cw\vle\c-array_driver  ,and the call function like this :

pastedImage_1.png

and the debug register I can see the block is unlock correct :

pastedImage_2.png

after executed the erase operation ,the returnCode is C90FL_OK ,but in the flash block 2 ,the value didn't be erased.

so I have 4 question about this case :

1.whether the SSD C-array FlashErase_C which I used is right ? what's the difference in BookE and vle.

2.The parameter like shadowFlag, lowEnabledBlocks, midEnabledBlocks, highEnabledBlocks of the function ,is  it correct ?

pFlashErase( &ssdConfig, shadowFlag, lowEnabledBlocks, midEnabledBlocks, highEnabledBlocks, (tpfNullCallback)NULL_CALLBACK );

3.What circumstances will appear this kind of failure?

4.what do you have some suggestion to me ?

Tags (2)
0 Kudos
7 Replies

1,142 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

do not write to ssdConfig like this:

pastedImage_1.png

During initialization phase, you are supposed to initialize the ssdConfig in this way (copied from demo code):

/* CFlash */
SSD_CONFIG ssdConfig = {
    C_REG_BASE,             /* Flash control register base */
    C_ARRAY_BASE,           /* base of main array */
    0,                      /* size of main array */
    SHADOW_ROW_BASE,        /* base of shadow row */
    SHADOW_ROW_SIZE,        /* size of shadow row */
    0,                      /* block number in low address space */
    0,                      /* block number in middle address space */
    0,                      /* block number in high address space */
    C90FL_PAGE_SIZE_08,     /* flash page size selection */
    FALSE                   /* debug mode selection */
};

That's mentioned in user manual:

pastedImage_2.png

Then call FlashInit(). This function will read the flash configuration information from flash registers and it will initialize the rest of the parameters: mainArraySize, lowBlockNum, midBlockNum and highBlockNum.

You are not supposed to modify the ssdConfig anymore.

Then it should work.

Regards,

Lukas

1,142 Views
dennisyuan
Contributor III

Hi Lukas,

otherwise ,I use  the following c_array:

QQ图片20170305001344.jpg

I don't know what's the root cause ,and what about you ?

0 Kudos

1,142 Views
dennisyuan
Contributor III

Hi Lukas,

I tried it on in accordance with your method,but still failed.

Following is my change point :

1. I have changed the SHADOW_ROW_BASE to 0x00FFC000 and SHADOW_ROW_SIZE to 0x00004000 follow the MPC5634M datasheet.

pastedImage_1.png

pastedImage_2.png

2. Remove the ssdConfig information ,and set the  lowEnabledBlocks = 0x00000004uL;because I want to erase the block 1b(base address is 0x00008000) .

There is a problem :when set the  lowEnabledBlocks = 0x00000004uL, the erase function pFlashErase will run away .

but I set the lowEnabledBlocks = 0x00000002uL, the erase function pFlashErase will return C90FL_OK, but still can't erase success  .

pastedImage_3.png

From the above ,I am confused what value  should set about the lowEnabledBlocks  parameter ?

I check the MPC5634M manual ,there is a example :

pastedImage_13.png

the example erase blocks 2a and 1b ,the LMS=0x00000006;

but form the LMS register description if erase the blocks 2a and 1b,the LMS Should be equal to  0x0000000C.

is it right about my understanding ?

pastedImage_16.png

0 Kudos

1,142 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

where the code is running from? Notice that Read-While-Write is supported only between banks. For example, if you want to erase or program bank 0, the code must be executed either from bank1 or from RAM. That could be the reason.

Next thing - there are three flash arrays. If you want to program all of them, you need three instances of ssdConfig. Take a look at attached code. Notice that this example must be executed from RAM because it erase/program all arrays for test purposes. 

To erase block 0, you need to set lowEnabledBlocks = 1;

To erase block 1a, you need to set lowEnabledBlocks = 2;

To erase block 1b, you need to set lowEnabledBlocks = 4;

To erase all these blocks, you need to set lowEnabledBlocks = 7;

That's a good point - there seems to be a typo in Example 10-2. I agree, there should be 0xC.

Regards,

Lukas

1,142 Views
dennisyuan
Contributor III

Hi Lukas,

I have found the root cause of my problem ,it's the watchdog.Disable the watchdog when erase the blocks the erase result is ok.Your example is correct .

Thank for your great support!

0 Kudos

1,142 Views
dennisyuan
Contributor III

Hi ,

Today I Transplant the example code to my project ,and I close the other function .it means the project just the transplanted code .in the code I erase block 3(0x0001c000-0x00020000). The result seems same as my code .That means when erase the block ,the program will runway.And I check the memory the value is 0x00000000,seems not correct.you can see it in the following :

pastedImage_1.png

the code  as the follow:

pastedImage_2.png

we can know the pFlashErase runing in the RAM ,right?

pastedImage_6.png

and the register:

pastedImage_3.pngpastedImage_4.png

LCF configuration:

pastedImage_5.png

In my thinking ,all the above information is ok ,but I don't know why the result is not correct ?

Could you help me double check the example code ,and if you have other ideas ,please let me know ,thank you !

0 Kudos

1,142 Views
dennisyuan
Contributor III

Hi Lukas,

 Thanks for your quick response,and I am sorry I forgot to tell you what  's my design idea.

1.The LCF configuration as follow :

This is the bootloader field :

QQ图片20170306224737.png

2. As you said ,I  have defined three instances of ssdConfig which like the example ..

3.And the code running from the RAM .I  re-define the  C-array drivers as variables (just delete “const”) and they will be automatically copied to RAM by startup code.

QQ图片20170306223024.png

Here just the  C-array drivers locate the Ram area , whether need to define the function which called the  C-array drivers in the Ram area? For example ,in my project the function ;EraseFlash().

QQ图片20170306222303.png

I will have a try with your example project if still erase failed .

Thank you very much !

Best Regards,

Dennis

0 Kudos