Commit fb3659ac422801ea18f36ef62926df70beeada4c

Authored by Marek Vasut
Committed by Scott Wood
1 parent 6d41419f0b
Exists in master and in 57 other branches 8qm-imx_v2020.04_5.4.70_2.3.0, emb_lf-6.6.52-2.2.0, emb_lf_v2022.04, emb_lf_v2023.04, emb_lf_v2024.04, imx_v2015.04_4.1.15_1.0.0_ga, pitx_8mp_lf_v2020.04, smarc-8m-android-10.0.0_2.6.0, smarc-8m-android-11.0.0_2.0.0, smarc-8mp-android-11.0.0_2.0.0, smarc-emmc-imx_v2014.04_3.10.53_1.1.0_ga, smarc-emmc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx-l5.0.0_1.0.0-ga, smarc-imx6_v2018.03_4.14.98_2.0.0_ga, smarc-imx7_v2017.03_4.9.11_1.0.0_ga, smarc-imx7_v2018.03_4.14.98_2.0.0_ga, smarc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx_v2015.04_4.1.15_1.0.0_ga, smarc-imx_v2017.03_4.9.11_1.0.0_ga, smarc-imx_v2017.03_4.9.88_2.0.0_ga, smarc-imx_v2017.03_o8.1.0_1.3.0_8m, smarc-imx_v2018.03_4.14.78_1.0.0_ga, smarc-m6.0.1_2.1.0-ga, smarc-n7.1.2_2.0.0-ga, smarc-rel_imx_4.1.15_2.0.0_ga, smarc_8m-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8m-imx_v2019.04_4.19.35_1.1.0, smarc_8m_00d0-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2019.04_4.19.35_1.1.0, smarc_8mm-imx_v2020.04_5.4.24_2.1.0, smarc_8mp_lf_v2020.04, smarc_8mq-imx_v2020.04_5.4.24_2.1.0, smarc_8mq_lf_v2020.04, ti-u-boot-2015.07, u-boot-2013.01.y, v2013.10, v2013.10-smarct33, v2013.10-smartmen, v2014.01, v2014.04, v2014.04-smarct33, v2014.04-smarct33-emmc, v2014.04-smartmen, v2014.07, v2014.07-smarct33, v2014.07-smartmen, v2015.07-smarct33, v2015.07-smarct33-emmc, v2015.07-smarct4x, v2016.05-dlt, v2016.05-smarct3x, v2016.05-smarct3x-emmc, v2016.05-smarct4x, v2017.01-smarct3x, v2017.01-smarct3x-emmc, v2017.01-smarct4x

NAND: Add nand read.raw and write.raw commands

These commands should work around various "hardware" ECC and BCH methods.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Scott Wood <scottwood@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
[scottwood@freescale.com: s/write the page/access the page/]
Signed-off-by: Scott Wood <scottwood@freescale.com>

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

... ... @@ -602,6 +602,22 @@
602 602 ret = nand->read_oob(nand, off, &ops);
603 603 else
604 604 ret = nand->write_oob(nand, off, &ops);
  605 + } else if (!strcmp(s, ".raw")) {
  606 + /* Raw access */
  607 + mtd_oob_ops_t ops = {
  608 + .datbuf = (u8 *)addr,
  609 + .oobbuf = ((u8 *)addr) + nand->writesize,
  610 + .len = nand->writesize,
  611 + .ooblen = nand->oobsize,
  612 + .mode = MTD_OOB_RAW
  613 + };
  614 +
  615 + rwsize = nand->writesize + nand->oobsize;
  616 +
  617 + if (read)
  618 + ret = nand->read_oob(nand, off, &ops);
  619 + else
  620 + ret = nand->write_oob(nand, off, &ops);
605 621 } else {
606 622 printf("Unknown nand command suffix '%s'.\n", s);
607 623 return 1;
... ... @@ -695,6 +711,9 @@
695 711 "nand write - addr off|partition size\n"
696 712 " read/write 'size' bytes starting at offset 'off'\n"
697 713 " to/from memory address 'addr', skipping bad blocks.\n"
  714 + "nand read.raw - addr off|partition\n"
  715 + "nand write.raw - addr off|partition\n"
  716 + " Use read.raw/write.raw to avoid ECC and access the page as-is.\n"
698 717 #ifdef CONFIG_CMD_NAND_TRIMFFS
699 718 "nand write.trimffs - addr off|partition size\n"
700 719 " write 'size' bytes starting at offset 'off' from memory address\n"
... ... @@ -94,6 +94,15 @@
94 94 of data for one 512-byte page or 2 256-byte pages. There is no check
95 95 for bad blocks.
96 96  
  97 + nand read.raw addr ofs|partition
  98 + Read page from `ofs' in NAND flash to `addr'. This reads the raw page,
  99 + so ECC is avoided and the OOB area is read as well.
  100 +
  101 + nand write.raw addr ofs|partition
  102 + Write page from `addr' to `ofs' in NAND flash. This writes the raw page,
  103 + so ECC is avoided and the OOB area is written as well, making the whole
  104 + page written as-is.
  105 +
97 106 Configuration Options:
98 107  
99 108 CONFIG_CMD_NAND