Skip to contentSkip to conversation

commands: Kconfig: Remove HW ECC dependency from nandtest

PATCH Applied Stefan Riedmueller 2 participants 5 messages Mar 30, 2021 – Apr 1, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 commands: Kconfig: Remove HW ECC dependency from nandtest

NAND_ECC_HW is no longer optional so remove the dependency from nandtest. Otherwise nandtest won't be build for HW ECC boards.

---
 commands/Kconfig | 1 -
 1 file changed, 1 deletion(-)
commands/Kconfig +0 -1
index 6d84c956e576..8e8b5a926fbb 100644
@@ -1884,7 +1884,6 @@ config CMD_NANDTEST
 	tristate
 	depends on NAND
 	depends on PARTITION
-	depends on NAND_ECC_HW || NAND_ECC_SOFT
 	prompt "nandtest"
 	help
 	  NAND flash memory test
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/4 nandtest: Fix status print for NAND which size exceeds 4 GB

Nandsize can be larger than 4 GB. So during status print the number of blocks calculation needs to use 64 bit division.

---
 commands/nandtest.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
commands/nandtest.c +5 -3
index bfe4c4c0ed03..1bb59c7fdba5 100644
@@ -178,12 +178,14 @@ static int erase_and_write(loff_t ofs, unsigned char *data,
 }
 
 /* Print stats of nandtest. */
-static void print_stats(int nr_passes, int length)
+static void print_stats(int nr_passes, loff_t length)
 {
 	unsigned int i;
+	uint64_t blocks = (uint64_t)length;
+
+	do_div(blocks, meminfo.erasesize);
 	printf("-------- Summary --------\n");
-	printf("Tested blocks		: %d\n", (length/meminfo.erasesize)
-			* nr_passes);
+	printf("Tested blocks		: %lld\n", blocks * nr_passes);
 
 	for (i = 0; i < MAX_ECC_BITS; i++)
 		printf("ECC %d bit error(s)	: %u\n", i + 1, ecc_stats[i]);
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 3/4 mtd: nand_msx: Implement ooblayout ops

In reply to Stefan Riedmueller

The default ooblayout ops do not work on nand_mxs devices and can lead to an unresponsible system when doing a 'nand -i' on that device.

Thus implement the ooblayout ops for the nand_mxs driver separately. Since writing the oob area is not supported simply return the whole oob area as ecc.

---
 drivers/mtd/nand/nand_mxs.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/mtd/nand/nand_mxs.c +29 -0
index 96ae71364efb..285ae3c121b6 100644
@@ -269,6 +269,33 @@ static void mxs_nand_return_dma_descs(struct mxs_nand_info *info)
 	info->desc_index = 0;
 }
 
+/*
+ * We don't support writing the oob area so simply return the whole oob
+ * as ECC.
+ */
+static int mxs_nand_ooblayout_ecc(struct mtd_info *mtd, int section,
+				  struct mtd_oob_region *oobregion)
+{
+	if (section)
+		return -ERANGE;
+
+	oobregion->offset = 0;
+	oobregion->length = mtd->oobsize;
+
+	return 0;
+}
+
+static int mxs_nand_ooblayout_free(struct mtd_info *mtd, int section,
+				   struct mtd_oob_region *oobregion)
+{
+	return -ERANGE;
+}
+
+static const struct mtd_ooblayout_ops mxs_nand_ooblayout_ops = {
+	.ecc = mxs_nand_ooblayout_ecc,
+	.free = mxs_nand_ooblayout_free,
+};
+
 static uint32_t mxs_nand_ecc_chunk_cnt(uint32_t page_data_size)
 {
 	return page_data_size / MXS_NAND_CHUNK_DATA_CHUNK_SIZE;
@@ -2218,6 +2245,8 @@ static int mxs_nand_probe(struct device_d *dev)
 	if (err)
 		goto err2;
 
+	mtd_set_ooblayout(mtd, &mxs_nand_ooblayout_ops);
+
 	mxs_nand_scan_bbt(chip);
 
 	err = add_mtd_nand_device(mtd, "nand");
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 4/4 imx-bbu-nand-fcb: Inform user if the barebox partition is too small

In reply to Stefan Riedmueller

Show an error message and return an error code if the barebox partition is too small. This can easily happen when having large erasoblocks since all four FCB copies need a separate eraseblock.

---
 common/imx-bbu-nand-fcb.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
common/imx-bbu-nand-fcb.c +15 -1
index 0e008c6bc2c0..4e680a0a51e7 100644
@@ -501,7 +501,8 @@ static int imx_bbu_firmware_start_block(struct mtd_info *mtd, int num)
  * @num: The slot number (0 or 1)
  *
  * This returns the start page for a firmware slot, to be written into the
- * Firmwaren_startingPage field in the FCB.
+ * Firmwaren_startingPage field in the FCB or a negative error code in case
+ * of a failure.
  */
 static int imx_bbu_firmware_fcb_start_page(struct mtd_info *mtd, int num)
 {
@@ -512,6 +513,11 @@ static int imx_bbu_firmware_fcb_start_page(struct mtd_info *mtd, int num)
 
 	blocksleft = imx_bbu_firmware_max_blocks(mtd);
 
+	if (blocksleft <= 0) {
+		pr_err("partition size too small for both firmwares\n");
+		return -ENOMEM;
+	}
+
 	/*
 	 * The ROM only checks for a bad block when advancing the read position,
 	 * but not if the initial block is good, hence we cannot directly point
@@ -1258,7 +1264,15 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *dat
 		free(fcb);
 		fcb = xzalloc(sizeof(*fcb));
 		fcb->Firmware1_startingPage = imx_bbu_firmware_fcb_start_page(mtd, !used);
+		if (fcb->Firmware1_startingPage < 0) {
+			ret = fcb->Firmware1_startingPage;
+			goto out;
+		}
 		fcb->Firmware2_startingPage = imx_bbu_firmware_fcb_start_page(mtd, used);
+		if (fcb->Firmware2_startingPage < 0) {
+			ret = fcb->Firmware2_startingPage;
+			goto out;
+		}
 		fcb->PagesInFirmware1 = fw_size / mtd->writesize;
 		fcb->PagesInFirmware2 = fcb->PagesInFirmware1;
 
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#4 lore raw
In reply to Stefan Riedmueller
Quoted 7 lines · Stefan Riedmueller

NAND_ECC_HW is no longer optional so remove the dependency from nandtest. Otherwise nandtest won't be build for HW ECC boards.

---
 commands/Kconfig | 1 -
 1 file changed, 1 deletion(-)

Applied all to master, thanks

Sascha

Quoted 22 lines
commands/Kconfig +0 -1
index 6d84c956e576..8e8b5a926fbb 100644
@@ -1884,7 +1884,6 @@ config CMD_NANDTEST
 	tristate
 	depends on NAND
 	depends on PARTITION
-	depends on NAND_ECC_HW || NAND_ECC_SOFT
 	prompt "nandtest"
 	help
 	  NAND flash memory test
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox