AnsweredAssumed Answered

IAP RAM to Flash Not Working

Question asked by Nicholas Hunn on May 20, 2018
Latest reply on May 23, 2018 by jeremyzhou

Hi, I'm trying to implement a boot loader based on the one in AN10995 for the LPC11U68. 
I read in the data fine but when I write it, nothing is written to flash. 

Here's the code, the copy ram to flash command returns success, however nothing is written to flash. Flash inspection shows nothing is written and the comparison operation returns that they aren't the same. What am I missing?

 

/* Define flash memory address at which user application is located */
#define APP_START_ADDR (0x00001000UL)
#define APP_END_ADDR (0x00040000UL)

 

/* Define the flash sectors used by the application */
#define APP_START_SECTOR 1
#define APP_END_SECTOR 28

 

static uint32_t u32BootLoader_ProgramFlash(uint8_t *pu8Data, uint16_t u16Len)
{
uint32_t u32Result = 0;

static uint32_t u32NextFlashWriteAddr = APP_START_ADDR;

if ((pu8Data != 0) && (u16Len != 0))
{
   /* Prepare the flash application sectors for reprogramming */
   if (Chip_IAP_PreSectorForReadWrite(APP_START_SECTOR, APP_END_SECTOR) == IAP_CMD_SUCCESS)
   {

      /* Write the data to flash */
      if (Chip_IAP_CopyRamToFlash(u32NextFlashWriteAddr, (uint32_t *) pu8Data, u16Len) == IAP_CMD_SUCCESS)
      {
            /* Check that the write was successful */
            if (Chip_IAP_Compare(u32NextFlashWriteAddr, (uint32_t) pu8Data, u16Len) == IAP_CMD_SUCCESS)
            {
               /* Write was successful */
               u32NextFlashWriteAddr += u16Len;
               u32Result = 1;
            }
         }
      }
   }
return (u32Result);
}

Outcomes