When CONFIG_YAFFS_DISABLE_CHUNK_ERASED_CHECK is defined and yaffs_WriteNewChunkWithTagsToNAND gets a failure on the call to yaffs_WriteChunkWithTagsToNAND() it will loop over the all (free) chunks failing to write and printing "yaffs chunk %d was not erased". Well, it actually skips the second write and thinks it failed. The range of the #ifdef CONFIG_YAFFS_DISABLE_CHUNK_ERASED_CHECK needs to extend to just below the next "else". See below. I also think it would be a good idea to limit "attempts" to some sane number, perhaps chunks-per-block * 10. -imcd ======================= do{ chunk = yaffs_AllocateChunk(dev,useReserve); if(chunk >= 0) { // First check this chunk is erased... #ifndef CONFIG_YAFFS_DISABLE_CHUNK_ERASED_CHECK writeOk = yaffs_CheckChunkErased(dev,chunk); // not here #endif if(!writeOk) { T(YAFFS_TRACE_ERROR,(TSTR("**>> yaffs chunk %d was not erased" TENDSTR),chunk)); } else #endif //here { writeOk = yaffs_WriteChunkWithTagsToNAND(dev,chunk,data,tags); } attempts++; if(writeOk) { // Copy the data into the robustification buffer. // NB We do this at the end to prevent duplicates in the case of a write error. //Todo yaffs_HandleWriteChunkOk(dev,chunk,data,tags); } else { yaffs_HandleWriteChunkError(dev,chunk); } } } while(chunk >= 0 && ! writeOk);