Return values and errors

The functions and constants described below are declared in the header file cyg/io/flash_nand_err.h.

The functions in all NAND Flash APIs return the value CYG_NAND_ERR_OK on success, and another value on failure. If a function fails, a global variable is set that indicates where the error occurred and for what reason.

The error return values are one of the following:

CYG_NAND_ERR_OK                    No error - operation complete
CYG_NAND_ERR_BOUND                 Exceed array or buffer bound
CYG_NAND_ERR_INVALID               Invalid NAND address
CYG_NAND_ERR_INVALID_DEVICE        Invalid NAND device
CYG_NAND_ERR_INVALID_COLUMN        Invalid NAND address column
CYG_NAND_ERR_INVALID_ROW           Invalid NAND address row
CYG_NAND_ERR_INVALID_CHIP          Invalid NAND chip address
CYG_NAND_ERR_INVALID_CONTROLLER    Invalid NAND controller address
CYG_NAND_ERR_DATA_SIZE             Nonmatching page data size
CYG_NAND_ERR_SPARE_SIZE            Nonmatching page spare size
CYG_NAND_ERR_ERASE                 Error trying to erase
CYG_NAND_ERR_LOCK                  Error trying to lock/unlock
CYG_NAND_ERR_PROGRAM               Error trying to program
CYG_NAND_ERR_PROTOCOL              Generic error
CYG_NAND_ERR_NOTFOUND              Not found
CYG_NAND_ERR_PROTECT               Device/region is write-protected
CYG_NAND_ERR_BAD_BLOCK             Block is marked 'bad'
CYG_NAND_ERR_OUT_OF_BLOCKS         No satisfactory block found
CYG_NAND_ERR_ECC_INTERNAL          Internal ECC error
CYG_NAND_ERR_ECC_ECC_CORRUPT       ECC itself is corrupted
CYG_NAND_ERR_ECC_ERROR             ECC error: > 1 bit error
CYG_NAND_ERR_ECC_REPAIRED          ECC repaired: 1 bit error
CYG_NAND_ERR_OUT_OF_MEMORY         Memory allocation failed
CYG_NAND_ERR_NOT_INIT              NAND info not yet initialized
CYG_NAND_ERR_UNIMPLEMENTED         Unimplemented routine
CYG_NAND_ERR_HWR                   Hardware (configuration?) problem
CYG_NAND_ERR_ERASE_SUSPEND         Device is in erase suspend mode
CYG_NAND_ERR_PROGRAM_SUSPEND       Device is in program suspend mode
CYG_NAND_ERR_DRV_VERIFY            Driver failed to verify data
CYG_NAND_ERR_DRV_TIMEOUT           Driver timed out
CYG_NAND_ERR_DRV_WRONG_PART        Driver does not support device
CYG_NAND_ERR_LOW_VOLTAGE           Not enough juice to complete job

The error value is obtained through cyg_nand_err_get(). Human-readable information about the error is obtained through cyg_nand_errmsg(). Function cyg_nand_err_reset() resets the error state. Macro cyg_nand_err_set() sets the error to one the values listed above and provides more description in the string error_message.

#define cyg_nand_err_set(error_number, error_message) ...
__externC const char *cyg_nand_errmsg(void);
__externC int cyg_nand_err_get(void);
__externC int cyg_nand_err_reset(void);