AnsweredAssumed Answered

K64 FTFE Operations Across PFlash Blocks

Question asked by Jared Evans on Nov 6, 2015
Latest reply on Dec 6, 2015 by angel gutierrez

Hello all,

 

I am working on a project very similar toKinetis Bootloader , using KDS 3.0 with KSDK 1.3 to program a FRDM-K64F board. I have followed the SD Card Bootloader :how to using SD card to update existing firmware on CodeWarriror or KDS and KSDK 1.3 flash driver example to create a bootloader, which successfully loads a binary file from an SD card and then runs the application.

 

However, I am only able to erase and program to a location on a single block of PFlash (either the lower or upper block), as opposed to, for example, relegating 0x00000-0x10000 for the bootloader and the remaining 0x10000-0x100000 for the program. I encounter the "FTFx_ERR_PVIOL" error from FlashEraseSector() whenever I cross the 0x80000 boundary.

 

I also have a TWR-K60F120M, which did not have any of these issues when I ran the provided code from SD Card Bootloader :how to using SD card to update existing firmware on CodeWarriror or KDS . I have not been able to find anything in the K64 reference manual that describes this difference between the two processors. I am unsure if I am missing something from the provided examples or if it is not possible to perform flash operations across the PFlash blocks on the K64.

 

I have also tried this change, as shown in the code snippet below, in the "main.c" of "KSDK_1.3.0\examples\frdmk64f\demo_apps\flash_demo" of KSDK 1.3 and found the same issue at the 0x80000 point. If the flash operations are possible, can anyone provide correct method of doing the following erase procedure, where I have altered the beginning address to 0x10000 and end address to 0x100000?

 

    /************************************************************************/     /* Erase several sectors on upper pflash block where there is no code */     /************************************************************************/     destination = flashSSDConfig.PFlashBase + 0x10000; // Base address to erase set to 0x10000     end = destination + 0xE0000;    /* erase and program two sectors */ //End address for erase set to 0x100000     while ((destination + (FTFx_PSECTOR_SIZE)) < end)     {         size = FTFx_PSECTOR_SIZE;         ret = FlashEraseSector(&flashSSDConfig, destination, size, g_FlashLaunchCommand);         if (FTFx_OK != ret)         {             ErrorTrap(ret);         }           /* Verify section for several sector of PFLASH */         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); //0x10,FTFx_ERR_PVIOL, being returned when trying to erase 0x7e000-0x80000             }         }           /* print message for user */         PRINTF("\r\n\tDemo:  Successfully Erased Sector 0x%x -> 0x%x", (unsigned int)destination, (unsigned int)(destination+size));           destination += (size);     }

 

 

Thanks,

 

Jared

Outcomes