In the function NANDConfigure you have the following:
unsigned int retVal;
retVal = E_FAIL; //You are assigning a negative number to an unsigned int. Not good!!!!
But you also have
#define E_FAIL (-1) in bl.h
You also have
#define E_FAIL (0x00000001u) in tistdtypes.h
You really need some consistency on that and it should only be defined in one place.