internal flash write problem in frdmk64f120

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

internal flash write problem in frdmk64f120

ソリューションへジャンプ
1,288件の閲覧回数
sudhakarp
Contributor V

Hi,

     i am using FRDMK64f120 controller. i am using KDS2.0 and ksdk 1.1.0. MQX. i tried internal flash read/write program. its working fine. after i interfaced flash Demo project into ethernet_to_serial project,now  i am getting some error i dnt know what problem. if i reduce my code size its working fine. if i increase my code size its not working fine.

          in my code i am using more "const char * static_array[ ]" is any problem? because if i comment some "const char * " (its mean reduce some parameter(data)) at that time its working fine. in internal flash i am saving 200 or 500byte data only. at address 0xfa000

text data  bss  dec  hex    filename
528504 2884      23912     555300      87924    eth_to_serial.elf

this is my code size .BIN file size was nearly 519KB.

what is the solution for this? is i want to change any internal flash writing address?  i am not get any idea give some solution.

is any option to save data in NVM (without external interface) .

regards,

sudhakar p

ラベル(1)
0 件の賞賛
返信
1 解決策
987件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

Hi Sudhakar,

I was able to integrate eth_to_serial example with flash_demo using KSDK1.2 and KDS3.0. You can find it attached.

At the beginning I had problems because application was returning to the flash_demo start (not resetting) and I thought it was because of stack. But at the end the problem was that is is required to disable interrupts. You can see the following code in demo.c.

_int_disable();

flash_main();

_int_enable();

Actually it looks like there is also problem with printf as mentioned previously by

Best regards,

Carlos

元の投稿で解決策を見る

0 件の賞賛
返信
7 返答(返信)
987件の閲覧回数
sergeisharonov
Contributor III

As a hunch I would check stack. Adding more variables and crashing kind of points to blowing up the stack. Also check if you printf is flushing. Normal behavior is NOT to flush. That means that printf may/will return before all the data has hit the wire. In that case you may crash after printf and do not see any output from it.

Regards,

Sergei

0 件の賞賛
返信
987件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

Hi Sudhakar,

can you let us have a screenshot of the error and also the code snippet that is causing the problem?

Regards,

Carlos

0 件の賞賛
返信
987件の閲覧回数
sudhakarp
Contributor V

hi carlos.

     and also what is block-0 and block-1 flash program.each are 512 kb .so this place i want to change anything?

and flash demo example swap is there is anything i want to change. i attached my flash write,read,erase code.

void internal_flash_write()

{

      uint32_t ret;                  /* Return code from each SSD function */

      uint32_t destination;          /* Address of the target location */

      uint32_t size;

      uint32_t end;

      uint8_t  securityStatus;       /* Return protection status */

      uint16_t number;               /* Number of longword or phrase to be program or verify*/

      uint32_t *p_data;

      uint32_t margin_read_level;    /* 0=normal, 1=user - margin read for reading 1's */

      uint8_t sudha_data[200];

      uint8_t sudha_data_2[10];

      uint32_t i=0, FailAddr;

      unsigned char *dst;

      unsigned char addr;

      unsigned char adj_size;

        uint32_t FlashValueAtFA00=0;

        uint32_t FlashValueAtFA04=0;

        CACHE_DISABLE

        /**************************************************************************

             * Set CallBack to callback function

           ***************************************************************************/

           flashSSDConfig.CallBack = (PCALLBACK)RelocateFunction((uint32_t)__ram_for_callback , CALLBACK_SIZE , (uint32_t)callback);

           g_FlashLaunchCommand = (pFLASHCOMMANDSEQUENCE)RelocateFunction((uint32_t)__ram_func , LAUNCH_CMD_SIZE ,(uint32_t)FlashCommandSequence);

        //**************************************************************************

    destination = flashSSDConfig.PFlashBase + (flashSSDConfig.PFlashSize - 6*FTFx_PSECTOR_SIZE);

        internal_flash_erase();

        exist_params=new_params;

        size=sizeof(exist_params);//size of flash program must be multiple of 8 so adjust the size   

        size-=8;// here i am mincing(-) dnt_remove parameter size (confg parameter) because that variable for adjusting purpose only

        if((size%8)!=0)//checking size is multiple of 8 or not if not it will adjust

        {

            adj_size=(size%8);

            adj_size=8-adj_size;

            size=size+adj_size;

        }

       ret = FlashProgram(&flashSSDConfig, destination, size, \

         &exist_params, g_FlashLaunchCommand);       

         if (FTFx_OK != ret)

         {

             ErrorTrap(ret);

         }

      

}

void internal_flash_read()

{

    unsigned char *dst;

    unsigned char *exitparam_dst;

    uint32_t FlashValueAtFA00=0;

    uint32_t FlashValueAtFA04=0;

    uint32_t i=0;

     dst=flashSSDConfig.PFlashBase + (flashSSDConfig.PFlashSize - 6*FTFx_PSECTOR_SIZE);

   

    exitparam_dst=&exist_params;   

    for (i = 0; i <sizeof(exist_params); i++)

     {

     *exitparam_dst=*dst;   

     dst++;exitparam_dst++;

     }   

}

void internal_flash_erase()

{

      uint32_t ret;                  /* Return code from each SSD function */

      uint32_t destination;          /* Address of the target location */

     uint32_t size;

      uint32_t end;

      uint16_t number;               /* Number of longword or phrase to be program or verify*/

      uint32_t *p_data;

      uint32_t margin_read_level;

      //on 21-5-15 printf("\n\n\r---->Demo: Running FlashEraseSector() and FlashVerifySection()...");

    //***********************************************************************

    // Erase several sectors on upper pflash block where there is no code

    //***********************************************************************

   destination = flashSSDConfig.PFlashBase + (flashSSDConfig.PFlashSize - 6*FTFx_PSECTOR_SIZE);

   end = destination + 3*FTFx_PSECTOR_SIZE;    // erase and program two sectors 

    while ((destination + (FTFx_PSECTOR_SIZE)) < end)

    {

        size = FTFx_PSECTOR_SIZE;

        ret = FlashEraseSector(&flashSSDConfig, destination, size, g_FlashLaunchCommand);

        if (FTFx_OK != ret)

        {

            ErrorTrap(ret);

        }

     

        number = FTFx_PSECTOR_SIZE/FSL_FEATURE_FLASH_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT;

        for(margin_read_level = 0; margin_read_level < 0x2; margin_read_level++)

        {

            ret = FlashVerifySection(&flashSSDConfig, destination, number, margin_read_level, g_FlashLaunchCommand);

            if (FTFx_OK != ret)

            {

                ErrorTrap(ret);

            }

        }      

        destination += (size);

    }

}

regards,

sudhakar p

0 件の賞賛
返信
987件の閲覧回数
sudhakarp
Contributor V

Hi,

     i find exactly where my code was hanging. i added image just see and give some solution.

inside FlashEraseSector() API function one while loop there, here my code was looping.Untitled.png

so i debug through serial its outing only "Before flash command" its not outing "After flash command"

string.

0 件の賞賛
返信
988件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

Hi Sudhakar,

I was able to integrate eth_to_serial example with flash_demo using KSDK1.2 and KDS3.0. You can find it attached.

At the beginning I had problems because application was returning to the flash_demo start (not resetting) and I thought it was because of stack. But at the end the problem was that is is required to disable interrupts. You can see the following code in demo.c.

_int_disable();

flash_main();

_int_enable();

Actually it looks like there is also problem with printf as mentioned previously by

Best regards,

Carlos

0 件の賞賛
返信
987件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

Hi Sudhakar,

Sorry for the delay.

I am trying to reproduce this behavior. But it is not clear for me how you interfaced flash_demo with ethernet_to_serial. What process you followed? What changes you did in the project?

Regards,

Carlos

0 件の賞賛
返信
987件の閲覧回数
sudhakarp
Contributor V

Hi carlos,

  i am not getting any build error.   i am writing some configuration parameter to internal flash. when i call flashproram API function its was hanging. i dnt know why.  

    
i am using MK64FN1M0VLL12 controller. is flash size is 1MB or 512 KB. i thought is 1-MB. because when my *.bin size was going more than 512 KB only i am facing this problem. i think is related to FLASH write address. in my code i am using

flash demo example code address only(0xfa000). i am not changed any think in flash demo code. is any flash address problem.

give some idea to solve this problem. you just suggest what are possibilities may be (to occur this problem). if you  want i will send my full project.

0 件の賞賛
返信