AnsweredAssumed Answered

Flash Swap - Swap Control Command

Question asked by Jason Philippi on Oct 17, 2016
Latest reply on Oct 18, 2016 by Hui_Ma

Hello Everybody,


I am trying to use the Swap Control Command as used in AN4533 from an Uninitialized State.

In PFlashSwap.c:

/* Report current swap state */
ret = PFlashSwapCtl(pSSDConfig,addr,FTFx_SWAP_REPORT_STATUS,&currentSwapMode, \
&currentSwapBlockStatus, &nextSwapBlockStatus ,pFlashCommandSequence);

I get

ret = FTFx_OK

currentSwapMode = 0x00 (Uninitialized)

currentSwapBlockStatus = 0x00 (Block 0 at 0x0_0000)

nextSwapBlockStatus = 0x00 (Block 0 at 0x0_0000)

Which that is all fine with me.

Next I go into this in PFlashSwap.c:

/* If current swap mode is Uninitialized */
if (FTFx_SWAP_UNINIT == currentSwapMode)
/* Initialize Swap to Initialized/READY state */
ret = PFlashSwapCtl(pSSDConfig, addr, FTFx_SWAP_SET_INDICATOR_ADDR,&currentSwapMode, \
&currentSwapBlockStatus, &nextSwapBlockStatus , pFlashCommandSequence);

This time I am Initializing the Swap System to UPDATE-ERASED, but this where I run into problems.

I get back



Based on the FTFE Chapter in my manual, there are 4 errors I could be having.

  1. Command not available in current mode/security
  2. Flash Address is not in the lower half of program flash memory
  3. Flash address is in the Flash Configuration Field
  4. Flash address is not 128-bit aligned


I'm not sure what my problem is, but I'll throw in some snippets of information that might help.


Memory Segments in my linker file

m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_interrupts_ram (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00000400
m_text (RX) : ORIGIN = 0x00002000, LENGTH = 0x0007E000
m_data (RW) : ORIGIN = 0x1FFF0400, LENGTH = 0x0000FC00
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00030000
m_swap (RX) : ORIGIN = 0x00001000, LENGTH = 0x00001000

I added a separate section called m_swap to hold my SWAP_INDICATOR.

That block is 128 bit or double phrase aligned.



#define FLASH_SWAP_INDICATOR_ADDR 0x1000 //!<Address for the Flash Swap Indicator
#define LAUNCH_CMD_SIZE 0x600
#define CALLBACK_SIZE 0x100

Also, I have defined the address for the swap indicator address.

I went a little overboard on the Ram size for the Launch Command Size, but I checked my map file and found out I needed more room.



flash1_InitConfig0.CallBack = (PCALLBACK)RelocateFunction((uint32_t)ramForCallback , CALLBACK_SIZE , (uint32_t)flash_callback);
flashLaunchCommand = (pFLASHCOMMANDSEQUENCE)RelocateFunction((uint32_t)ramFunctions, LAUNCH_CMD_SIZE, (uint32_t)FlashCommandSequence);

Putting the functions into RAM.


I manually removed program flash protection in debug and I still error out.


I think I am having trouble with either 1 or 3.

I am using KSDK 1.3.0 and FreeRTOS on a K24.


Any ideas would be appreciated.


Thank you,

Jason Philippi