Flash Signature Generation LPC43Sxx issues

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flash Signature Generation LPC43Sxx issues

831 Views
javiervallori
Contributor III

Hi,

I'm trying to use the Flash Signature Generation on a LPC43Sxx, getting unsuccessful results. I get signatures values with singulars values, and does not changes with the flash values.

After an erase flash sector (using IAP functions), I checked in the memory tab of the debug perspective that the flash values of the corresponding flash_address and size change to 0xFFFFFFFF. Then I call the Signature Generation function becoming the following value:

         0 80000000 aaaaaaaa aaaaaaaa

Later I proceed to write differents values in the same sector (using IAP functions), checking again in the changes in the memory tab, and calling the Signature Generation function becoming the same value:

         0 80000000 aaaaaaaa aaaaaaaa

Sometimes, only when I run it in step by step in debug mode I get a diferent value, but just happens once, and can not repeat periodically.

I run the Signature Generation function in RAM2 out of the flash as the datasheet suggested and with the IRQ disabled.

The code I use is the following:

void hardSig(FLASH_SIG_Type * hard_sign) {

    ram_hardSig();

    hard_sign->word0 = Chip_FMC_GetSignature(SECTOR_BANK, 0);
    hard_sign->word1 = Chip_FMC_GetSignature(SECTOR_BANK, 1);
    hard_sign->word2 = Chip_FMC_GetSignature(SECTOR_BANK, 2);
    hard_sign->word3 = Chip_FMC_GetSignature(SECTOR_BANK, 3);

    DEBUGOUT("Hard_sign: %x ", hard_sign->word0);
    DEBUGOUT("%x ", hard_sign->word1);
    DEBUGOUT("%x ", hard_sign->word2);
    DEBUGOUT("%x\r\n", hard_sign->word3);
}

__RAMFUNC(RAM2) void ram_hardSig()  {

   /* Start signature address of the last sector*/
   #define START_ADDR_LAST_SECTOR                 0x1B070000
   #define START_AHB_ADDR_LAST_SECTOR               (START_ADDR_LAST_SECTOR & 0x001FFFF0)

   #define SECTOR_BANK            IAP_FLASH_BANK_B

   /* Size of each sector */
   #define SECTOR_SIZE                            65536

   /* LAST SECTOR */
   #define IAP_LAST_SECTOR                        14

   /* Number of bytes to be written to the last sector */
   #define IAP_NUM_BYTES_TO_WRITE                 512

    /* Start the signature generator for the last sector */
    //Chip_FMC_ComputeSignatureBlocks(SECTOR_BANK, START_ADDR_LAST_SECTOR, (SECTOR_SIZE / 16));
    Chip_FMC_ComputeSignature(SECTOR_BANK, START_AHB_ADDR_LAST_SECTOR, START_AHB_ADDR_LAST_SECTOR + IAP_NUM_BYTES_TO_WRITE);


    /* Check for signature geenration completion */
    while (Chip_FMC_IsSignatureBusy(SECTOR_BANK)) {}
    
}

One other strange data is that I can not read in the memory tab of the debug perspective the FMSW0/1/2/3 values of the Flash bank A (0x4000 C02C address) or B (0x4000 D02C address), but I can read on address of others modules like timers or uarts:

pastedImage_7.png

Besides, in the Peripheral tab of the debug perspective does not appear the FMC peripheral, but appears of the others peripherals:

pastedImage_8.png

It seems like this model hasn't this Flash Signature Generation Module. But that is very rarely. Has anyone any experience with this module in this MCU model? Any other suggestions?

Thank you.

Labels (1)
0 Kudos
5 Replies

580 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Javier Vallori,
Thank you for your interest in NXP Semiconductor products and
the opportunity to serve you.
I'd highly recommend you to refer to the periph_flashiap demo which demonstrates programming a FLASH block during run-time and generating a FLASH signature.
Peripheral tab doesn't contain FMC module, however, you can review these register in the memory tab.

pastedImage_1.png
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

580 Views
javiervallori
Contributor III

Hi Jeremy,

thank you for the answer. I try again on a new and simple test on periph_flashiap demo.

I start running just the periph_flashiap, getting exactly the same result you get:

   

 Generated signature for the last sector is: c283c8a8

After that, I made a very simple modification on that project. Apart of Erase and the CopyRamToFlash opertation on the last sector (sector #14), I just erase the penultimate sector WITHOUT the CopyRamToFlash operation. The result of the signature generation in both sector should be different, but I get the same:

 

  Generated signature for the penultimate sector is: c283c8a8
 Generated signature for the last sector is: c283c8a8

The code I executed is the same one as in the periph_flashiap with few modifications marked in red :

/* Start signature address of the last sector*/
#define START_ADDR_LAST_SECTOR                 0x1A070000
#define START_ADDR_PENULTIMATE_SECTOR          0x1A060000

/* Size of each sector */
#define SECTOR_SIZE                            65536

/* LAST SECTOR */
#define IAP_LAST_SECTOR                        14
#define IAP_PENULTIMATE_SECTOR                 13

/* Number of bytes to be written to the last sector */
#define IAP_NUM_BYTES_TO_WRITE                 512

/* Number elements in array */
#define ARRAY_ELEMENTS          (IAP_NUM_BYTES_TO_WRITE / sizeof(uint32_t))

/* Data array to write to flash */
static uint32_t src_iap_array_data[ARRAY_ELEMENTS];

/*****************************************************************************
 * Public functions
 ****************************************************************************/

int main(void)
{
    int i;
    uint8_t ret_code;
    uint32_t part_id;

    /* Generic Initialization */
    SystemCoreClockUpdate();
    Board_Init();
    Board_LED_Set(0, false);

    /* Enable SysTick Timer */
    SysTick_Config(SystemCoreClock / TICKRATE_HZ);

    DEBUGSTR("\r\n\r\n");
    DEBUGSTR("Signature Test\r\n");
    DEBUGSTR("==============\r\n");

    /* Initialize the array data to be written to FLASH */
    for (i = 0; i < ARRAY_ELEMENTS; i++) {
        src_iap_array_data[i] = 0x11223340 + i;
    }

    /* Read Part Identification Number*/
    part_id = Chip_IAP_ReadPID();
    DEBUGOUT("Part ID is: %x\r\n", part_id);

    /* Disable interrupt mode so it doesn't fire during FLASH updates */
    __disable_irq();

    /* Initialize the IAP */
    ret_code = Chip_IAP_Init();

    /* Error checking */
    if (ret_code != IAP_CMD_SUCCESS) {
        DEBUGOUT("Command failed to execute, return code is: %x\r\n", ret_code);
    }

    /* IAP Flash programming */
    /* Prepare to write/erase the last sector */
    ret_code = Chip_IAP_PreSectorForReadWrite(IAP_PENULTIMATE_SECTOR, IAP_PENULTIMATE_SECTOR, IAP_FLASH_BANK_A);

    /* Error checking */
    if (ret_code != IAP_CMD_SUCCESS) {
        DEBUGOUT("Command failed to execute, return code is: %x\r\n", ret_code);
    }

    /* Erase the last sector */
    ret_code = Chip_IAP_EraseSector(IAP_PENULTIMATE_SECTOR, IAP_PENULTIMATE_SECTOR, IAP_FLASH_BANK_A);

    /* Error checking */
    if (ret_code != IAP_CMD_SUCCESS) {
        DEBUGOUT("Command failed to execute, return code is: %x\r\n", ret_code);
    }

    /* Prepare to write/erase the last sector */
    ret_code = Chip_IAP_PreSectorForReadWrite(IAP_LAST_SECTOR, IAP_LAST_SECTOR, IAP_FLASH_BANK_A);

    /* Error checking */
    if (ret_code != IAP_CMD_SUCCESS) {
        DEBUGOUT("Command failed to execute, return code is: %x\r\n", ret_code);
    }

    /* Erase the last sector */
    ret_code = Chip_IAP_EraseSector(IAP_LAST_SECTOR, IAP_LAST_SECTOR, IAP_FLASH_BANK_A);

    /* Error checking */
    if (ret_code != IAP_CMD_SUCCESS) {
        DEBUGOUT("Command failed to execute, return code is: %x\r\n", ret_code);
    }

    /* Prepare to write/erase the last sector */
    ret_code = Chip_IAP_PreSectorForReadWrite(IAP_LAST_SECTOR, IAP_LAST_SECTOR, IAP_FLASH_BANK_A);

    /* Error checking */
    if (ret_code != IAP_CMD_SUCCESS) {
        DEBUGOUT("Command failed to execute, return code is: %x\r\n", ret_code);
    }

    /* Write to the last sector */
    ret_code = Chip_IAP_CopyRamToFlash(START_ADDR_LAST_SECTOR, src_iap_array_data, IAP_NUM_BYTES_TO_WRITE);

    /* Error checking */
    if (ret_code != IAP_CMD_SUCCESS) {
        DEBUGOUT("Command failed to execute, return code is: %x\r\n", ret_code);
    }

    /* Re-enable interrupt mode */
    __enable_irq();

    /* Start the signature generator for the last sector */
    Chip_FMC_ComputeSignatureBlocks(0, START_ADDR_PENULTIMATE_SECTOR, (SECTOR_SIZE / 16));

    /* Check for signature geenration completion */
    while (Chip_FMC_IsSignatureBusy(0)) {}

    /* Get the generated FLASH signature value */
    DEBUGOUT("Generated signature for the penultimate sector is: %x \r\n", Chip_FMC_GetSignature(0, 0));

    /* Start the signature generator for the last sector */
    Chip_FMC_ComputeSignatureBlocks(0, START_ADDR_LAST_SECTOR, (SECTOR_SIZE / 16));

    /* Check for signature geenration completion */
    while (Chip_FMC_IsSignatureBusy(0)) {}

    /* Get the generated FLASH signature value */
    DEBUGOUT("Generated signature for the last sector is: %x \r\n", Chip_FMC_GetSignature(0, 0));

    while (1) {
        __WFI();
    }
}

0 Kudos

580 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Javier Vallori,
Please show the value of Signature generation result registers as I did previously.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

580 Views
javiervallori
Contributor III

Hi Jeremy,

I show you the signature of the sector 13 (IAP_PENULTIMATE_SECTOR) as you did:

sceern1.png

and the signature of the sector 14 (IAP_LAST_SECTOR, the one of the demo example):

sceern2.png

As is previously indicated in the code I copied, the IAP_LAST_SECTOR has a copy of the src_iap_array_data array, but not the IAP_PENULTIMATE_SECTOR, wich has simply been erase. So the signature should be different, but it isn't.

Obviously I do something wrong, but I don't know were, and I would appreciated any suggestion.

0 Kudos

580 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Javier Vallori,
I've replicated the phenomenon, it seems so weird.
I'll do more testing later to dig much deeper.
You can also use the software way to generate the flash signature instead of this hardware way and please learn the more information via the below link.
https://os.mbed.com/forum/mbed/topic/4557/
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos