N
N
Nikolay Nozdrin-Plotnitsky2014-05-22 09:12:18
ARM
Nikolay Nozdrin-Plotnitsky, 2014-05-22 09:12:18

Why does it not flash the processor flash when using the IAP command in ARM?

LCP2478 processor with ARM7TDMI-S core. I'm trying to make a bootloader for updating software from a program using IAP commands.
The prepare phase returns a success result. At the stage of erasing - hangs. And not because of while: it simply does not return to the program after calling the IAP command. If the erase step is skipped, the CopyRAMtoFLASH command returns 0x0D (13 in decimal). There are only 11 return values ​​in UserManual starting from 0. Nothing is actually written to flash. In which direction to dig?

#define USER_APPLICATION_START_SECTOR 8
#define USER_APPLICATION_END_SECTOR   27
...
int main(void){
...
while (IAP_PrepareSector(USER_APPLICATION_START_SECTOR, USER_APPLICATION_END_SECTOR));
while (IAP_EraseSector  (USER_APPLICATION_START_SECTOR, USER_APPLICATION_END_SECTOR));
...
while (IAP_PrepareSector(USER_APPLICATION_START_SECTOR, USER_APPLICATION_END_SECTOR));
a = IAP_CopyRAM_ToFlash(iap_flash_address, (uint32_t) TerminalBuffer(UART_0), BINARY_DATA_BLOCK_SIZE);
buf[0] = a/10 + '0';
buf[1] = a%10 + '0';
TerminalOutput(UART_0, buf,2);
...
}
...
uint32_t IAP_CopyRAM_ToFlash (const uint32_t destination, const uint32_t source, const uint32_t length)
{
  char exmpl[300] = {0};
  command[0] = IAP_CMD_COPY_RAM_TO_FLASH;
  command[1] = destination;
  command[2] = source;
  command[3] = length;
  command[4] = IAP_CLK / 1000;	// Fcclk in KHz
  IAP_ENTRY(command, result);
  return result[0];
}

uint32_t IAP_EraseSector (const uint32_t start_sector, const uint32_t end_sector)
{
  if (start_sector > end_sector)
    return IAP_RESULT_INVALD_PARAM;

  command[0] = IAP_CMD_ERASE_SECTOR;
  command[1] = start_sector;
  command[2] = end_sector;
  command[3] = IAP_CLK / 1000;

  IAP_ENTRY(command, result);

  return result[0];
}

uint32_t IAP_PrepareSector (const uint32_t start_sector, const uint32_t end_sector)
{
  if (start_sector > end_sector)
    return IAP_RESULT_INVALD_PARAM;

  command[0] = IAP_CMD_PREPARE_SECTOR;
  command[1] = start_sector;
  command[2] = end_sector;

  IAP_ENTRY(command, result);

  return result[0];
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay Nozdrin-Plotnitsky, 2014-05-23
@scientistnik

I got rid of unknown errors)). Just needed to disable VIC interrupts:

save_VicInt = VICIntEnable;              // save interrupt enable status
VICIntEnClr = 0xFFFFFFFF;                // disable all interrupts
IAP_ENTRY(command, result);
VICIntEnable = save_VicInt;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question