Commit c9494866df835bcee68e17339aec1090faa704da

Authored by Ben Gardiner
Committed by Scott Wood
1 parent 169d54d8b3

cmd_nand: add nand write.trimffs command

Add another nand write. variant, trimffs. This command will request of
nand_write_skip_bad() that all trailing all-0xff pages will be
dropped from eraseblocks when they are written to flash as-per the
reccommended behaviour of the UBI FAQ [1].

The function that implements this timming is the drop_ffs() function
by Artem Bityutskiy, ported from the mtd-utils tree.

[1] http://www.linux-mtd.infradead.org/doc/ubi.html#L_flasher_algo

Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
CC: Artem Bityutskiy <dedekind1@gmail.com>
CC: Detlev Zundel <dzu@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>

Showing 2 changed files with 26 additions and 0 deletions Side-by-side Diff

... ... @@ -575,6 +575,16 @@
575 575 else
576 576 ret = nand_write_skip_bad(nand, off, &rwsize,
577 577 (u_char *)addr, 0);
  578 +#ifdef CONFIG_CMD_NAND_TRIMFFS
  579 + } else if (!strcmp(s, ".trimffs")) {
  580 + if (read) {
  581 + printf("Unknown nand command suffix '%s'\n", s);
  582 + return 1;
  583 + }
  584 + ret = nand_write_skip_bad(nand, off, &rwsize,
  585 + (u_char *)addr,
  586 + WITH_DROP_FFS);
  587 +#endif
578 588 #ifdef CONFIG_CMD_NAND_YAFFS
579 589 } else if (!strcmp(s, ".yaffs")) {
580 590 if (read) {
... ... @@ -689,6 +699,12 @@
689 699 "nand write - addr off|partition size\n"
690 700 " read/write 'size' bytes starting at offset 'off'\n"
691 701 " to/from memory address 'addr', skipping bad blocks.\n"
  702 +#ifdef CONFIG_CMD_NAND_TRIMFFS
  703 + "nand write.trimffs - addr off|partition size\n"
  704 + " write 'size' bytes starting at offset 'off' from memory address\n"
  705 + " 'addr', skipping bad blocks and dropping any pages at the end\n"
  706 + " of eraseblocks that contain only 0xFF\n"
  707 +#endif
692 708 #ifdef CONFIG_CMD_NAND_YAFFS
693 709 "nand write.yaffs - addr off|partition size\n"
694 710 " write 'size' bytes starting at offset 'off' with yaffs format\n"
... ... @@ -78,6 +78,16 @@
78 78 should work well, but loading an image copied from another flash is
79 79 going to be trouble if there are any bad blocks.
80 80  
  81 + nand write.trimffs addr ofs|partition size
  82 + Enabled by the CONFIG_CMD_NAND_TRIMFFS macro. This command will write to
  83 + the NAND flash in a manner identical to the 'nand write' command
  84 + described above -- with the additional check that all pages at the end
  85 + of eraseblocks which contain only 0xff data will not be written to the
  86 + NAND flash. This behaviour is required when flashing UBI images
  87 + containing UBIFS volumes as per the UBI FAQ[1].
  88 +
  89 + [1] http://www.linux-mtd.infradead.org/doc/ubi.html#L_flasher_algo
  90 +
81 91 nand write.oob addr ofs|partition size
82 92 Write `size' bytes from `addr' to the out-of-band data area
83 93 corresponding to `ofs' in NAND flash. This is limited to the 16 bytes