We entered the NAND command file CMD/NAND.C, in the Do_nand function, there is the NAND read or write code, and there is support for JFFS2, but there is no support for YAFFS2. The old version of Uboot was supported for Yaffs file system burning, so we refer to the old version of the Uboot code, in the Do_nand function of the NAND write/read part plus a piece of code, as follows:
1 #ifdef config_cmd_nand_trimffs 2 } else if (!strcmp (S, ". Trimffs")) {3 if (read) {4 printf ("Unknown NAND C Ommand suffix '%s ' \ n ', s); 5 return 1; 6 } 7 ret = Nand_write_skip_bad (NAND, off, &rwsize, NULL, 8 maxsize, (U_char *) addr, 9
with_drop_ffs | with_wr_verify); #endif
#ifdef CONFIG_CMD_NAND_YAFFS12 } else if (!strcmp (S, ". YAFFS2")) {( read) { Unknown nand command suffix '%s ' \ n ', s); return 1;16 }17 ret = Nand_write_skip_bad ( NAND, off, &rwsize,null,//here parameters and older version than to modify the next maxsize, (U_char *) addr,19 with_yaffs_oob); #endif
Add NAND write.yaffs help information in nand_help_text[]:
"Nand read.raw-addr off|partition [count]\n" "NAND write.raw-addr off|partition [count]\n" "Use Read.raw /write.raw to avoid ECC and access the Flash as-is.\n "#ifdef config_cmd_nand_yaffs " NAND write.yaffs2-addr off|p Artition size\n " " write ' size ' bytes starting at offset ' off ' with yaffs format\n " " from memory address ' addr ', skipping bad blocks.\n "#endif
The Nand_write_skip_bad function must also be modified inside:
1 if (actual) 2 *actual = 0; 3 #ifdef config_cmd_nand_yaffs 4 if (Flags & With_yaffs_o OB) {5 if (Flags & ~with_yaffs_oob) 6 return-einval; 7 8 int pages; 9 pages = nand->erasesize/nand->writesize; Ten blocksize = (pages * nand->oobsize) + nand->erasesize; if (*length% (nand->writesize + nand->oobsize)) {printf ("attemp T to write incomplete page "yaffs mode\n"); Return-einvAL; +} else #endif 18 { BlockSize = nand->erasesize; 20} 21 22 ... if (Left_to_write < (blocksize-block_offset)) write_size = Left_to_write; + Else Write_size = Blocksize-block_offset; 28 #ifdef config_cmd_nand_yaffs if (Flags & With_yaffs_oob) {int page, pages; size_t pagesize = nand->writesize; size_t Pagesize_oob = pagesize + nand->oobsize; Mtd_oob_ops ops, struct; Ops.len = pagesize; Ops.ooblen = nand->oobsize; Panax Notoginseng ops.mode = Mtd_ops_raw; This is to be changed to raw ops.ooboffs = 0; 39 pages = Write_size/pagesize_oob; (page = 0; page < pages; page++) {watchdog_reset (); 43 Ops.datbuf = P_buffer; Ops.oobbuf = Ops.datbuf + pagesize; Rval = Nand->_write_oob (NAND, Offset, &ops); if (rval! = 0); -offset + = pagesize; P_buffer + = Pagesize_oob; 53} 54} -Else #endif57 {//Add an opening brace here Truncated_write_size = write_size; 60 Config_cmd_nand_trimffs #ifdef if (Flags & with_drop_ffs) Truncated_write_size = Drop_ffs (NAND, P_buffer, &write_size); #endif 64 Rval = Nand_write (NAND, offset, &trun Cated_write_size, P_buffer); if (Flags & WI th_wr_verify) &&!rval) Rval = nand_verify (NAND, offset, Truncated_write_size, P_buffer); Write_size offset + = +; P_buffer + = Write_size; 74}//Add a closing brace hereif (rval! = 0) {
Also, add the definition of the WITH_YAFFS_OOB macro in Include/nand.h,
#define WITH_YAFFS_OOB (1 << 0) #define With_drop_ffs (1 << 0)
Finally add the Config_cmd_nand_yaffs macro definition in the configuration file, compile burn write, successfully burn write YAFFS2 file system and mount successfully, this uboot already support YAFFS2 file system's burning write.
u-boot-2016.03 supports YAFFS2 file system burning to add NAND WRITE.YAFFS2 commands