Sector of Program Flash Bank B erase issue

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

Sector of Program Flash Bank B erase issue

965 Views
JpTBM
Contributor II

Hi,

We are using LPC4357 microcontroller. 

Flash bank A is used for storing executable(hex file) and Flash bank B is used for storing our user defined data. We are not using any external Eeprom and instead using Flash bank B as an Eeprom to store and retain our user data. 

We have observed that, some sectors of Flash bank B gets erased (0xFF) while we access sector from Flash bank A for reading.

 

best regards, 

 

 

Labels (1)
0 Kudos
Reply
3 Replies

944 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello JpTBM

Thank you for your interest in NXP Semiconductor products and the opportunity to serve you, I will gladly help you with this. Do you have enabled a security feature? You may want to check the CRP, if this is enabled some sectors cannot be read.

Can you describe me in detail the procedure you are using to read the flash?

 

I will be on the awaiting of your reply. If you have more questions do not hesitate to ask me.

Best regards,

Omar

0 Kudos
Reply

920 Views
JpTBM
Contributor II

Hi Sorry for the later reply as i was not on duty due to sickness.

Have tried providing the requested details

Function 1 and 2 are used for initializing IAP.

Function 3 is used for writing into flash bank B

Function 4 is used for reading flash 

 

I hope I have provided all the details, if not, please do ask specfically.

 

thanks and regards,

Jagdish

 

/ Function - 1 ***************************************************************/

* Function : Init_Iap()

* Purpose  : IAP initialization

 

short Init_Iap(void)

{

                short return_status = ERROR;

               

                paramin[0] = IAP_INIT;

                iap_entry(paramin, paramout);

                return_status = paramout[0];

 

                return( return_status );

}

 

 

/ Function - 2 ***************************************************************/

  

#define IAP_ENTRY_LOCATION                                 (*((uint32_t *) 0x10400100))

 

/* IAP_ENTRY API function type */

typedef void (*IAP_ENTRY_T)(unsigned long[5], unsigned long[4]);

 

static INLINE void iap_entry(unsigned long cmd_param[], unsigned long status_result[])

{

                ((IAP_ENTRY_T) IAP_ENTRY_LOCATION)(cmd_param, status_result);

}

 

 

 

 

 

/ Function - 3 ***************************************************************/

 

/*--------------------------------------------------------------------------------

 * Function : RamTo_Flash()

* Purpose  : IAP operation copy data from RAM to flash ,command code 51

* Inputs   : dest addr(flash)

 *           src  addr(RAM)

 *           Number of Bytes

* Outputs  :

 * Returns  : Return configuration status

*-------------------------------------------------------------------------------*/

short RamTo_Flash(unsigned long dst, unsigned long src, unsigned long byteswrt)

{

                short return_status = VAL_ZERO;

 

                paramin[0] = IAP_RAMTOFLASH;

                paramin[1] = dst;

                paramin[2] = src;

                paramin[3] = byteswrt;

                paramin[4] = SystemCoreClock / 1000;

                paramin[5] = IAP_FLASH_BANK_B;

                iap_entry(paramin, paramout);

                return_status = paramout[0];

 

                return(return_status);

}

 

 

 

 

 

 

/ Function - 4 ***************************************************************/

 

/*--------------------------------------------------------------------------------

 * Function :          Read_From_Flash (unsigned long int Flash_u16ByteAddress, unsigned long int Sector_Start_Add,

 *             unsigned char *Flash_arri8ReadBytes, unsigned long int Offset_Address, unsigned int Flash_i16NumberOfBytes)

* Purpose  :          Reads multiple Data bytes from the Flash

* Accepts  :           Flash_u16ByteAddress       - Starting Read Address from where the data is to be read

Sector_Start_Add                                - Starting Address of the secor form where the data is to be Read

 Flash_arri8ReadBytes        - Pointer to the Array where data is to be copied

Offset_Address                    - Offest address of the data

Flash_i16NumberOfBytes  - No of bytes to be Read

* Returns  :           None

 *-------------------------------------------------------------------------------*/

void Read_From_Flash (unsigned long int Flash_u16ByteAddress, unsigned long int Sector_Start_Add,

                                                                                                unsigned char *Flash_arri8ReadBytes, unsigned long int Offset_Address, unsigned int Flash_i16NumberOfBytes)

{

                unsigned char *destination;

                unsigned int Temp_Byte_Count = 0;

                unsigned int Byte_count = 0;

                unsigned int Max_Byte_Count = 0;

 

#if DISABLE_INTERRUPT_DURING_IAP

                __disable_irq();

#endif

                Temp_Byte_Count = Flash_i16NumberOfBytes;

                while (Temp_Byte_Count != 0)

                {

                                destination = &Temp_Data[0];

                                memcpy((void *)destination, ((const void *)(Sector_Start_Add + Flash_u16ByteAddress - Offset_Address)), BYTES_512);

                                if (Temp_Byte_Count >= BYTES_512)

                                {

                                                Max_Byte_Count = BYTES_512;

                                                Temp_Byte_Count = Temp_Byte_Count - BYTES_512;

                                }

                                else

                                {

                                                Max_Byte_Count = Temp_Byte_Count;

                                                Temp_Byte_Count = Temp_Byte_Count - Temp_Byte_Count;

                                }

                                for (Byte_count = 0; Byte_count < Max_Byte_Count; Byte_count++)

                                {

                                                *Flash_arri8ReadBytes = Temp_Data[Byte_count];

                                                Flash_arri8ReadBytes++;

                                }

                }

#if DISABLE_INTERRUPT_DURING_IAP

                __enable_irq();

#endif

}

 

 

 

 

 

0 Kudos
Reply

895 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello JpTBM

 

Hope you're feeling better.

Before writing to flash you need to prepare first the affected sectors with the command "Prepare Sector for Write Operation". Also before writing the sector must be erased, not erasing a Flash location between successive writes causes incorrect readings from this memory location later on.

 

Let me know if this is helpful, if you have more questions do not hesitate to ask me.

Best regards,

Omar

0 Kudos
Reply