0

I ported my project that ran on LPCXPresso version 7.9.2 to MCUXpresso 11.6. The project worked normally, however I had a failure in one feature.

In this functionality, at some point the software runs only in RAM and completely erase the flash and then write a new version to the flash. The process fails with a hard fault error when I try to erase the flash. I am using the IAP_ENTRY functions. I suspect the boot sector is protected but I can't figure out how to unlock it.

Here's the code to make it clearer:

////////////////////////////////////////////////////////////////////////////
__RAMFUNC(RAM) static uint32_t Iap_ErasePage(uint32_t strPage, uint32_t endPage)
{
    uint32_t command[5], result[5];

    command[0] = IAP_ERASE_PAGE_CMD;
    command[1] = strPage;
    command[2] = endPage;
    command[3] = SystemCoreClock >> 10;
    iap_entry(command, result);

    return result[0];
}

__RAMFUNC(RAM) static void TxByte(char aData)
{
    Chip_UART_SendByte(LPC_USART, (uint8_t) aData);
}

__RAMFUNC(RAM) void Delete()
{
    TxByte('<');
    Iap_ErasePage(12, 15);
    TxByte('1');
    Iap_ErasePage(16, 19);
    TxByte('2');
    Iap_ErasePage(20, 23);      

    TxByte('3');            // software woks fine till here
    Iap_ErasePage(0, 3);    // when we try to erase these pages, a hardfault occours
    TxByte('4');
    Iap_ErasePage(4, 7);
    TxByte('5');
    Iap_ErasePage(8, 11);
    TxByte('6');
    TxByte('>');
    TxByte('\n');
}
josefrval
  • 11
  • 4

0 Answers0