From: 孙春阳 Date: Tue, 16 Dec 2025 07:55:57 +0000 (+0800) Subject: 修复烧录后,第一次mount 慢的问题 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=03cd13caa116d31622847de141ddaba334f62752;p=mirrors%2FFD230.git 修复烧录后,第一次mount 慢的问题 --- diff --git a/code/sdk/tools/bin/platform_tool/mkyaffs2image/mkyaffs2image b/code/sdk/tools/bin/platform_tool/mkyaffs2image/mkyaffs2image index 086d8c50f..aa49b9ec4 100644 Binary files a/code/sdk/tools/bin/platform_tool/mkyaffs2image/mkyaffs2image and b/code/sdk/tools/bin/platform_tool/mkyaffs2image/mkyaffs2image differ diff --git a/code/sdk/tools/bin/platform_tool/mkyaffs2image/mkyaffs2image.c b/code/sdk/tools/bin/platform_tool/mkyaffs2image/mkyaffs2image.c index 66e2a0f60..77d10d502 100644 --- a/code/sdk/tools/bin/platform_tool/mkyaffs2image/mkyaffs2image.c +++ b/code/sdk/tools/bin/platform_tool/mkyaffs2image/mkyaffs2image.c @@ -62,6 +62,24 @@ unsigned int chunkSize, spareSize, pagesPerBlock; #define NANDIP_V100 0x100 +#define CHUNKS_PER_SUMMARY 63 +#define YAFFS_OBJECTID_SUMMARY 0x10 +#define YAFFS_SUMMARY_VERSION 1 + +/* Summary tags don't need the sequence number because that is redundant. */ +struct yaffs_summary_tags { + unsigned obj_id; + unsigned chunk_id; + unsigned n_bytes; +}; + +/* Summary header */ +struct yaffs_summary_header { + unsigned version; /* Must match current version */ + unsigned block; /* Must be this block */ + unsigned seq; /* Must be this sequence number */ + unsigned sum; /* Just add up all the bytes in the tags */ +}; /* this follow must be consistent with fastboot !!! */ enum ecc_type @@ -311,6 +329,9 @@ static objItem obj_list[MAX_OBJECTS]; static int obj_id = YAFFS_NOBJECT_BUCKETS + 1; static int n_obj, nDirectories, nPages; +static int summary_index; +static int current_chunk; +static struct yaffs_summary_tags *sum_tags; static int outFile; @@ -444,6 +465,65 @@ static void shuffle_oob(char *spareData, struct yaffs_packed_tags2 *pt) memcpy(spareData, pt, sizeof(*pt)); } +static unsigned yaffs_summary_sum(void) +{ + unsigned sum = 0; + u8 *sum_tags_tmp = (u8 *)sum_tags; + int length = CHUNKS_PER_SUMMARY * sizeof(struct yaffs_summary_tags); + + while (length > 0) { + sum += *sum_tags_tmp; + sum_tags_tmp++; + length--; + } + + return sum; +} + +static int yaffs_do_summary(void) +{ + struct nand_oob_free *oobfree = sel_oob_info->freeoob; + + struct yaffs_summary_header hdr; + hdr.version = YAFFS_SUMMARY_VERSION; + hdr.block = 0; + hdr.seq = YAFFS_LOWEST_SEQUENCE_NUMBER; + hdr.sum = yaffs_summary_sum(); + + char data[chunkSize]; + memset(data, 0xff, chunkSize); + memcpy(data, &hdr, sizeof(hdr)); + memcpy(data + sizeof(hdr), sum_tags, CHUNKS_PER_SUMMARY * sizeof(struct yaffs_summary_tags)); + + if (write(outFile, data, chunkSize) != chunkSize) + fatal("write"); + + struct yaffs_ext_tags t; + memset(&t, 0, sizeof(struct yaffs_ext_tags)); + t.chunk_id = 1; + t.serial_number = 1; + t.n_bytes = CHUNKS_PER_SUMMARY * sizeof(struct yaffs_summary_tags) + sizeof(hdr); + t.obj_id = YAFFS_OBJECTID_SUMMARY; + t.seq_number = YAFFS_LOWEST_SEQUENCE_NUMBER; + t.chunk_used = 1; + nPages++; + + struct yaffs_packed_tags2 pt; + memset(&pt, 0, sizeof(struct yaffs_packed_tags2)); + yaffs_pack_tags2(&dummy_dev, &pt, &t, 1); + + char spareData[spareSize]; + memset(spareData, 0xff, spareSize); + spareData[oobfree->length] = 0; + spareData[oobfree->length + 1] = 0; + + shuffle_oob(&spareData[2], &pt); // use 2bit to mark bad block + + if (write(outFile, spareData, spareSize) != spareSize) + fatal("write"); + return 0; +} + static int write_chunk(u8 *data, u32 id, u32 chunk_id, u32 n_bytes) { struct yaffs_ext_tags t; @@ -451,6 +531,23 @@ static int write_chunk(u8 *data, u32 id, u32 chunk_id, u32 n_bytes) char spareData[spareSize]; struct nand_oob_free *oobfree = sel_oob_info->freeoob; + current_chunk++; + if ((current_chunk % (CHUNKS_PER_SUMMARY + 1)) == 0) { + error = yaffs_do_summary(); + if (error < 0) { + printf("Yaffs2 write summary info failure.\n"); + return error; + } + memset(sum_tags, 0x0, CHUNKS_PER_SUMMARY * sizeof(struct yaffs_summary_tags)); + current_chunk = 1; + summary_index = 0; + } + + sum_tags[summary_index].chunk_id = chunk_id; + sum_tags[summary_index].n_bytes = n_bytes; + sum_tags[summary_index].obj_id = id; + summary_index++; + if (write(outFile,data,chunkSize) != chunkSize) fatal("write"); @@ -942,7 +1039,14 @@ int main(int argc, char *argv[]) chunkSize = get_pagesize(g_pagetype); spareSize = sel_oob_info->oobsize; - printf("chunkSize %d spareSize %d\n",chunkSize,spareSize); + printf("fix mount slow after burn, chunkSize %d spareSize %d\n",chunkSize,spareSize); + int sum_tags_bytes = CHUNKS_PER_SUMMARY * sizeof(struct yaffs_summary_tags); + sum_tags = (struct yaffs_summary_tags *)malloc(sum_tags_bytes); + if (sum_tags == NULL) { + printf("Alloc sum_tags failure.\n"); + exit(1); + } + memset(sum_tags, 0x0, sum_tags_bytes); printf("Processing directory %s into image file %s\n",argv[1],argv[2]);