原创文章版权所有!如需转载,请注明出处: http://hi.baidu.com/liushuiyue1/myhome谢谢合作!!!!!
4)修改drivers/mtd/nand/nand_util.c
int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, u_char *buffer) { int rval; size_t left_to_write = *length; size_t len_incl_bad; u_char *p_buffer = buffer;
#if defined(CONFIG_SYS_NAND_YAFFS_WRITE) if(nand->rw_oob==1) { size_t oobsize=nand->oobsize; size_t datasize = nand->writesize; int datapages = 0; if(((*length)%(nand->oobsize+nand->writesize))!=0) { printf("Attempt to write error lenght data!\n"); return -EINVAL; } datapages = *length/(datasize+oobsize); *length = datapages*datasize; left_to_write = *length; } #endif ........ len_incl_bad = get_len_incl_bad (nand, offset, *length); if ((offset + len_incl_bad) > nand->size) { printf ("Attempt to write outside the flash area\n"); return -EINVAL; }
#if !defined(CONFIG_SYS_NAND_YAFFS_WRITE) if (len_incl_bad == *length) { rval = nand_write (nand, offset, length, buffer); if (rval != 0) printf ("NAND write to offset %llx failed %d\n", offset, rval); return rval; } #endif while (left_to_write > 0) { size_t block_offset = offset & (nand->erasesize - 1); size_t write_size; WATCHDOG_RESET (); if (nand_block_isbad (nand, offset & ~(nand->erasesize - 1))) { printf ("Skip bad block 0x%08llx\n", offset & ~(nand->erasesize - 1)); offset += nand->erasesize - block_offset; continue; } #if defined(CONFIG_SYS_NAND_YAFFS_WRITE) if (nand->skipfirstblk==1) { nand->skipfirstblk = 0; printf("Skip the first good block%llx\n",offset&~(nand->erasesize-1)); offset+=nand->erasesize-block_offset; continue; } #endif .... left_to_write -= write_size; printf("%d%% is complete",100-(left_to_write/(*length/100))); offset += write_size;
// p_buffer += write_size; #if defined(CONFIG_SYS_NAND_YAFFS_WRITE) if(nand->rw_oob==1) { p_buffer+=write_size+(write_size/nand->writesize*nand->oobsize); } else { p_buffer+=write_size; } #else p_buffer += write_size; #endif } return 0; } |
5)修改include/linux/mtd/mtd.h
在131行添加红色字体部分 #if defined(CONFIG_SYS_NAND_YAFFS_WRITE) u_char rw_oob; u_char skipfirstblk; #endif |
文章评论(0条评论)
登录后参与讨论