static void shuffle_oob(char *spareData, struct yaffs_packed_tags2 *pt)
{
assert(sizeof(*pt) <= spareSize);
// NAND LAYOUT: For non-trivial OOB orderings, here would be a good place to shuffle.
memcpy(spareData, pt, sizeof(*pt));
}
static int write_chunk(u8 *data, u32 id, u32 chunk_id, u32 n_bytes)
{
struct yaffs_ext_tags t;
struct yaffs_packed_tags2 pt;
char spareData[spareSize];
if (write(outFile,data,chunkSize) != chunkSize)
fatal("write");
memset(&t, 0, sizeof(t));
t.chunk_id = chunk_id;
// t.serial_number = 0;
t.serial_number = 1; // **CHECK**
t.n_bytes = n_bytes;
t.obj_id = id;
t.seq_number = YAFFS_LOWEST_SEQUENCE_NUMBER;
// added NCB **CHECK**
t.chunk_used = 1;
if (convert_endian)
{
little_to_big_endian(&t);
}
nPages++;
memset(&pt, 0, sizeof(pt));
yaffs_pack_tags2(&pt,&t,1);
memset(spareData, 0xff, sizeof(spareData));
shuffle_oob(spareData, &pt);
if (write(outFile,spareData,sizeof(spareData)) != sizeof(spareData))
fatal("write");
return 0;
}
是直接先将yaffs_packed_tags2写入的,
struct yaffs_packed_tags2 {
struct yaffs_packed_tags2_tags_only t;
struct yaffs_ecc_other ecc;
};
struct yaffs_packed_tags2_tags_only {
unsigned seq_number;
unsigned obj_id;
unsigned chunk_id;
unsigned n_bytes;
};
struct yaffs_ecc_other {
unsigned char col_parity;
unsigned line_parity;
unsigned line_parity_prime;
};
总共4*7=28字节,直接放OOB最前面了。而且从2013年的版本都是这样的。