summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-06-12 06:58:24 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-06-12 08:29:48 +0200
commitc3400f3d6430af32baaa9f4a878561e9faca7500 (patch)
tree99d68ba5c12568ae112493c5ae8bd34a93c5b529 /common
parent22f8077c391c6a226dbb9a5228af8e9840fc0e42 (diff)
downloadbarebox-c3400f3d6430af32baaa9f4a878561e9faca7500.tar.gz
imx-bbu-nand-fcb: Let DBBT start at page 1
We used to put the FCB in the first two NAND blocks and the DBBT in the third and fourth block. It's much more space efficient to put the FCB and DBBT together into the same eraseblock in different pages. This way we can store four FCBs and four DBBTs instead of two only. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/imx-bbu-nand-fcb.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
index 920b5a1..d65b9cd 100644
--- a/common/imx-bbu-nand-fcb.c
+++ b/common/imx-bbu-nand-fcb.c
@@ -257,8 +257,8 @@ static int fcb_create(struct imx_nand_fcb_bbu_handler *imx_handler,
fcb->NumEccBlocksPerPage = mtd->writesize / fcb->EccBlock0Size - 1;
- /* DBBT search area starts at third block */
- fcb->DBBTSearchAreaStartAddress = mtd->erasesize / mtd->writesize * 2;
+ /* DBBT search area starts at second page on first block */
+ fcb->DBBTSearchAreaStartAddress = 1;
fcb->BadBlockMarkerByte = mxs_nand_mark_byte_offset(mtd);
fcb->BadBlockMarkerStartBit = mxs_nand_mark_bit_offset(mtd);
@@ -445,10 +445,6 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *dat
*/
memset(fcb_raw_page + mtd->writesize, 0xFF, 2);
- ret = raw_write_page(mtd, fcb_raw_page, 0);
- if (ret)
- goto out;
-
ret = raw_write_page(mtd, fcb_raw_page, mtd->erasesize);
if (ret)
goto out;
@@ -467,14 +463,19 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *dat
imx_handler->dbbt_create(imx_handler, dbbt, ret);
}
- for (i = 2; i < 4; i++) {
- ret = mtd_write(mtd, mtd->erasesize * i, 2048, &written, dbbt_page);
+ for (i = 0; i < 4; i++) {
+ ret = raw_write_page(mtd, fcb_raw_page, mtd->erasesize * i);
+ if (ret)
+ goto out;
+
+ ret = mtd_write(mtd, mtd->erasesize * i + mtd->writesize,
+ mtd->writesize, &written, dbbt_page);
if (ret)
goto out;
if (dbbt->DBBTNumOfPages > 0) {
- ret = mtd_write(mtd, mtd->erasesize * i + mtd->writesize * 4,
- 2048, &written, dbbt_data_page);
+ ret = mtd_write(mtd, mtd->erasesize * i + mtd->writesize * 5,
+ mtd->writesize, &written, dbbt_data_page);
if (ret)
goto out;
}