How do I write data flash when FTFL_FCCOBn only provides 24-bits of address, and data flash is at 0x1000_0000?
I have a bare metal bootloader that needs to access three sectors of data flash, which start at 0x1000_0000.
The K40 reference manual says that the FTFL_CCOBn registers are used to write to program and data flash.
These registers work fine for program flash, but since FTFL_CCOB0 has 8-bits for the command and only 24-bits
for address, it cannot access data flash properly.
What is the correct method to write to data flash on a bare metal embedded system?
Don dT
已解决! 转到解答。
Hi,
In fact, the 24 bit Flash internal address Flash address bit [23] indicate the program Flash block is program flash block or data flash block. If customer want to program data flash, it just need to add 0x800000 with converted FTFL internal flash address. More detailed info, please check below code:
/* check for valid range of the target addresses */
if((endAddress >= PSSDConfig->PFlashBlockBase) && \
(endAddress <= (PSSDConfig->PFlashBlockBase + BYTE2WORD(PSSDConfig->PFlashBlockSize))))
{
/* Convert System memory address to FTFx internal memory address */
#if DSC_56800EX == CPU_CORE
destination = (2*(destination - PSSDConfig->PFlashBlockBase));
#else
destination -= PSSDConfig->PFlashBlockBase;
#endif
sectionAlign = PPGMSEC_ALIGN_SIZE;
}
else if((endAddress >= PSSDConfig->DFlashBlockBase) || \
(endAddress <= (PSSDConfig->DFlashBlockBase + BYTE2WORD(PSSDConfig->DFlashBlockSize))))
{
/* Convert System memory address to FTFx internal memory address */
#if DSC_56800EX == CPU_CORE
destination = (2*(destination - PSSDConfig->DFlashBlockBase)+ 0x800000);
#else
destination = destination - PSSDConfig->DFlashBlockBase + 0x800000;
#endif
sectionAlign = DPGMSEC_ALIGN_SIZE;
}
else /* end address does not fall within Pflash or Dflash range */
{
/* return an error code FTFx_ERR_RANGE */
returnCode = FTFx_ERR_RANGE;
goto EXIT;
}
Customer could dowload Kinetis Flash driver from below link:
http://cache.freescale.com/files/32bit/software/C90TFS_FLASH_DRIVER.exe
Wish it helps.
Thank you! I knew there must be some little trick to make this work. This has resolved my problem. :-)
I didn’t notice this in the documentation. I was using the K40P144M100SF2RM Reference Manual, mainly.
Hi,
In fact, the 24 bit Flash internal address Flash address bit [23] indicate the program Flash block is program flash block or data flash block. If customer want to program data flash, it just need to add 0x800000 with converted FTFL internal flash address. More detailed info, please check below code:
/* check for valid range of the target addresses */
if((endAddress >= PSSDConfig->PFlashBlockBase) && \
(endAddress <= (PSSDConfig->PFlashBlockBase + BYTE2WORD(PSSDConfig->PFlashBlockSize))))
{
/* Convert System memory address to FTFx internal memory address */
#if DSC_56800EX == CPU_CORE
destination = (2*(destination - PSSDConfig->PFlashBlockBase));
#else
destination -= PSSDConfig->PFlashBlockBase;
#endif
sectionAlign = PPGMSEC_ALIGN_SIZE;
}
else if((endAddress >= PSSDConfig->DFlashBlockBase) || \
(endAddress <= (PSSDConfig->DFlashBlockBase + BYTE2WORD(PSSDConfig->DFlashBlockSize))))
{
/* Convert System memory address to FTFx internal memory address */
#if DSC_56800EX == CPU_CORE
destination = (2*(destination - PSSDConfig->DFlashBlockBase)+ 0x800000);
#else
destination = destination - PSSDConfig->DFlashBlockBase + 0x800000;
#endif
sectionAlign = DPGMSEC_ALIGN_SIZE;
}
else /* end address does not fall within Pflash or Dflash range */
{
/* return an error code FTFx_ERR_RANGE */
returnCode = FTFx_ERR_RANGE;
goto EXIT;
}
Customer could dowload Kinetis Flash driver from below link:
http://cache.freescale.com/files/32bit/software/C90TFS_FLASH_DRIVER.exe
Wish it helps.
Is there any initiative to put this in documentation, specifically the reference manuals? A year later, I still do not see this anywhere in K60P144M150SF3RM either, which probably means it is not included in the common manual section that keeps getting pasted into many Kinetis reference manuals. Seems a like a pretty important thing to include.
Hi
I believe that the details have always been there:
Regards
Mark
Kinetis: µTasker Kinetis support
K60: µTasker Kinetis TWR-K60N512 support / µTasker Kinetis TWR-K60D100M support / µTasker Kinetis TWR-K60F120M support
For the complete "out-of-the-box" Kinetis experience and faster time to market
Haha. Got me. Maybe if I had read that chapter three more times I would have noticed that.
Thanks for pointing that out. You don't have to call a "wambulance" to come pick me up. Yes technically it's there... technically. *sigh*