By default, the uboot source code does not support the yaffs file system, so we need to modify the source code for support.
First, go to the U-boot source code directory to add support for yaffs image burning.
Write some yaffs content in common/cmd_nand.c following jffs2:
In:
U_boot_cmd (nand, 5, 1, do_nand,
"NAND-NAND sub-system \ n ",
"Info-show available NAND devices \ n"
"NAND device [Dev]-show or set current device \ n"
"NAND read [. jffs2]-ADDR off | partition size \ n"
"NAND write [. jffs2]-ADDR off | partition size-read/write 'SIZE' bytes starting \ n"
"At offset 'off' to/from memory address 'addr '\ n"
Then add the use instructions for NAND read. yaffs:
"NAND read. yaffs-ADDR off | partition size \ n"
"NAND write. yaffs-ADDR off | partition size-read/write 'SIZE' bytes starting \ n"
Then add write. yaffs support to do_nand in the processing function of the NAND command. do_nand is implemented in common/mongo_nand.c:
In:
If (s! = NULL &&
(! Strcmp (S, ". jffs2") |! Strcmp (S, ". e") |! Strcmp (S, ". I "))){
.......
The judgment is followed:
Else if (s! = NULL &&
(! Strcmp (S, ". yaffs") |! Strcmp (S, ". e") |! Strcmp (S, ". I "))){
If (read ){
/* Read */
Nand_read_options_t opts;
Memset (& opts, 0, sizeof (OPTs ));
Opts. Buffer = (u_char *) ADDR;
Opts. Length = size;
Opts. offset = off;
Opts. readoob = 1;
Opts. Quiet = quiet;
Ret = nand_read_opts (nand, & opts );
} Else {
/* Write */
Nand_write_options_t opts;
Memset (& opts, 0, sizeof (OPTs ));
Opts. Buffer = (u_char *) ADDR;
Opts. Length = size;
Opts. offset = off;
/* Opts. forcejffs2 = 1 ;*/
// Opts. Pad = 1;
Opts. noecc = 1;
Opts. writeoob = 1;
Opts. blockalign = 1;
Opts. Quiet = quiet;
Ret = nand_write_opts (nand, & opts );
}
}
Since opts. noecc = 1 is set in the previous step and the ECC verification code is not used, this information will be prompted during the write process:
Writing data without ECC to NAND-FLASH is not recommended
Writing data without ECC to NAND-FLASH is not recommended
Writing data without ECC to NAND-FLASH is not recommended
Writing data without ECC to NAND-FLASH is not recommended
Writing data without ECC to NAND-FLASH is not recommended
You can modify the nand_write_page function of the driver/MTD/NAND/nand_base.c file and remove it. The modification is as follows:
Case nand_ecc_none:
// Printk (kern_warning "writing data without ECC to NAND-FLASH is not ecommended \ n ");
This-> write_buf (MTD, this-> data_poi, MTD-> oobblock );
Break;
After these modifications, the U-BOOT can support the burning of the yaffs file image.
(4)
U-boot-1.1.6 is available through "NAND write... "," NAND write. jffs2... "and other commands to download the cramfs and jffs2 file system image files. Add" NAND write. yaffs... "command to achieve the burning of the yaffs file system image.
1. Add "NAND write. yaffs..." To commom/cmd_nand.c and add the following code:
U_boot_cmd (nand, 5, 1, do_nand,
"NAND-NAND sub-system \ n ",
"Info-show available NAND devices \ n"
"NAND device [Dev]-show or set current device \ n"
"NAND read [. jffs2]-ADDR off | partition size \ n"
"NAND write [. jffs2]-ADDR off | partiton size-read/write 'SIZE' bytes starting \ n"
"At offset 'off' to/from memory address 'addr '\ n"
"NAND read. yaffs ADDR off size-read the 'SIZE' byte yaffs image starting \ n"
"At offset 'off' to memory address 'addr '\ n"
"NAND write. yaffs ADDR off size-Write the 'SIZE' byte yaffs image starting \ n"
"At offset 'off' from memory address 'addr '\ n"
"NAND erase [clean] [off size]-erase 'SIZE' bytes from \ n"
"Offset 'off' (entire device if not specified) \ n"
"NAND bad-show bad blocks \ n"
........................
........................
Then, add support for "NAND yaffs..." to the handler function do_nand of the NAND command. The do_nand function is still implemented in commom/javas_nand.c. The code is modified as follows:
........................
........................
Opts. Quiet = quiet;
Ret = nand_write_opts (nand, & opts );
}
}
Else if (s! = NULL &&! Strcmp (S, ". yaffs ")){
If (read ){
Nand_read_options_t opts;
Memset (& opts, 0, sizeof (OPTs ));
Opts. Buffer = (u_char *) ADDR;
Opts. Length = size;
Opts. offset = off;
Opts. readoob = 1;
Opts. Quiet = quiet;
Ret = nand_read_opts (nand, & opts );
} Else {
Nand_write_options_t opts;
Memset (& opts, 0, sizeof (OPTs ));
Opts. Buffer = (u_char *) ADDR;
Opts. Length = size;
Opts. offset = off;
Opts. noecc = 1;
Opts. writeoob = 1;
Opts. blockalign = 1;
Opts. Quiet = quiet;
Opts. skipfirstblk = 1;
Ret = nand_write_opts (nand, & opts );
}
} Else {
If (read)
Ret = nand_read (nand, off, & size, (u_char *) ADDR );
Else
Ret = nand_write (nand, off, & size, (u_char *) ADDR );
}
.....................
.....................
2. Modify include/NAND. h to add the skipfirstblk member:
Struct nand_write_options {
U_char * buffer;
..................
..................
Int pad;
Int blockalign;
Int skipfirstblk;
};
3. Modify the nand_write_opts function in drivers/NAND/nand_util.c to support skipfirstblk members:
Int nand_write_opts (nand_info_t * meminfo, const nand_write_options_t * opts)
{
Int imglen = 0;
..................
..................
Int result;
Int skipfirstblk = opts-> skipfirstblk;
..................
..................
} While (offs <blockstart + erasesize_blockalign );
}
If (skipfirstblk ){
Mtdoffset + = erasesize_blockalign;
Skipfirstblk = 0;
Continue;
}
Readlen = meminfo-> oobblock;
..................
After the above transplantation, U-boot supports the burning of the yaffs file system image. noecc = 1 "if you do not use the ECC verification code, a large number of prompts will be prompted During writing. You can modify the nand_write_page function in the drivers/NAND/nand_base.c file and comment it out.
Case nand_ecc_none:
// Printk (kern_warning "writing data without ECC to NAND-FLASH is not recommended \ n ");