nandwrite requires the image to be a multiple of the block size. (nandwrite has an option to pad, but this only works when the image does not include OOB.) Pad the final block of the image with 0xff. Index: mkyaffs2image/mkyaffs2image.c =================================================================== --- mkyaffs2image.orig/mkyaffs2image.c 2010-08-26 16:50:46.000000000 -0600 +++ mkyaffs2image/mkyaffs2image.c 2010-08-26 17:15:39.000000000 -0600 @@ -18,7 +18,7 @@ * makeyaffs2image.c * * Makes a YAFFS2 file system image that can be used to load up a file system. - * Uses default Linux MTD layout - change if you need something different. + * Uses default Linux MTD layout - search for "NAND LAYOUT" to change. */ #include @@ -41,8 +41,10 @@ #define MAX_OBJECTS 10000 +// Adjust these to match your NAND LAYOUT: #define chunkSize 2048 #define spareSize 64 +#define pagesPerBlock 64 const char * mkyaffsimage_c_version = "$Id: mkyaffs2image.c,v 1.5 2010-01-11 21:43:18 charles Exp $"; @@ -175,7 +177,7 @@ static void shuffle_oob(char *spareData, yaffs_PackedTags2 *pt) { assert(sizeof(*pt) <= spareSize); - // For non-trivial OOB orderings, here would be a good place to shuffle. + // NAND LAYOUT: For non-trivial OOB orderings, here would be a good place to shuffle. memcpy(spareData, pt, sizeof(*pt)); } @@ -349,6 +351,21 @@ } +static void pad_image() +{ + __u8 data[chunkSize + spareSize]; + int padPages = (nPages % pagesPerBlock); + + if (padPages) + { + memset(data, 0xff, sizeof(data)); + for (padPages = pagesPerBlock-padPages; padPages; padPages--) + { + if (write(outFile, data, sizeof(data)) != sizeof(data)) + fatal("write"); + } + } +} static int process_directory(int parent, const char *path) { @@ -555,6 +572,8 @@ if(write_object_header(1, YAFFS_OBJECT_TYPE_DIRECTORY, &stats, 1,"", -1, NULL) == 0) process_directory(YAFFS_OBJECTID_ROOT,argv[1]); + pad_image(); + close(outFile); if(error)