Atmel Evaluation Kit AT91SAM9G25-EK AT91SAM9G25-EK Data Sheet

Product codes
AT91SAM9G25-EK
Page of 1102
67
SAM9G25 [DATASHEET]
11032C–ATARM–25-Jan-13
ONFI 2.2 Parameters 
In case no valid header has been found, the Boot Program will check if the NAND Flash is ONFI compliant, sending a 
Read Id command (0x90) with 0x20 as parameter for the address. If the NAND Flash is ONFI compliant, the Boot 
Program retrieves the following parameters with the help of the Get Parameter Page command:
z
 Number of bytes per page (byte 80)
z
 Number of bytes in spare zone (byte 84)
z
 Number of ECC bit correction required (byte 112)
z
 ECC sector size: by default set to 512 bytes, or 1024 bytes if the ECC bit capability above is 0xFF
By default, ONFI NAND Flash detection will turn ON the usePmecc parameter, and ECC correction algorithm is 
automatically activated.
Once the Boot Program retrieves the parameter, using one of the two methods described above, it will read the first page 
again, with or without ECC, depending on the usePmecc parameter. Then it looks for a valid code programmed just after 
the header offset 0xD0. If the code is valid, the program is copied at the beginning of the internal SRAM. 
Note:
Booting on 16-bit NAND Flash is not possible, only 8-bit NAND Flash memories are supported.
11.4.4.2 NAND Flash Boot: PMECC Error Detection and Correction
NAND Flash boot procedure uses PMECC to detect and correct errors during NAND Flash read operations in two cases:
z
when the usePmecc flag is set in the specific NAND header. If the flag is not set, no ECC correction is performed 
during NAND Flash page read.
z
when the NAND Flash has been detected using ONFI parameters.
The ROM code embeds the software used in the process of ECC detection/correction: the Galois Field tables, and the 
function PMECC_CorrectionAlgo(). The user does not need to embedd it in other software.
This function can be called by user software when PMECC status returns errors after a read page command.
Its address can be retrieved by reading the third vector of the ROM Code interrupt vector table, at address 0x100008.
The API of this function is: 
unsigned int PMECC_CorrectionAlgo(AT91PS_PMECC pPMECC,
                                  AT91PS_PMERRLOC pPMERRLOC,
                                  PMECC_paramDesc_struct *PMECC_desc,
                                  unsigned int PMECC_status,
                                  unsigned int pageBuffer)
pPMECC : pointer to the PMECC base address,
pPMERRLOC : pointer to the PMERRLOC base address,
PMECC_desc : pointer to the PMECC descriptor,
PMECC_status : the status returned by the read of PMECCISR register;
pageBuffer : address of the buffer containing the page to be corrected.
The PMECC descriptor structure is:
typedef struct _PMECC_paramDesc_struct {
    unsigned int pageSize;
    unsigned int spareSize;
    unsigned int sectorSize;  // 0 for 512, 1 for 1024 bytes
    unsigned int errBitNbrCapability;
    unsigned int eccSizeByte;
    unsigned int eccStartAddr;
    unsigned int eccEndAddr;