[PATCH 7/9] bsps/xnandpsu: Mark correct reserved blocks

Kinsey Moore kinsey.moore at oarcorp.com
Sat Dec 9 02:31:24 UTC 2023


When marking the trailing blocks on a device as reserved for Bad Block
Table usage, ensure that the correct blocks are marked. This resolves an
off-by-one error that was marking one block too low and leaving the last
block in the device unmarked.
---
 bsps/shared/dev/nand/xnandpsu_bbm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/bsps/shared/dev/nand/xnandpsu_bbm.c b/bsps/shared/dev/nand/xnandpsu_bbm.c
index d1b7d5a39d..4fb62b2f6d 100644
--- a/bsps/shared/dev/nand/xnandpsu_bbm.c
+++ b/bsps/shared/dev/nand/xnandpsu_bbm.c
@@ -830,7 +830,11 @@ static s32 XNandPsu_MarkBbt(XNandPsu* InstancePtr, XNandPsu_BbtDesc *Desc,
 
 	/* Mark the last four blocks as Reserved */
 	BlockIndex = ((Target + (u32)1) * InstancePtr->Geometry.NumTargetBlocks) -
+#ifdef __rtems__
+						Desc->MaxBlocks;
+#else
 						Desc->MaxBlocks - (u32)1;
+#endif
 
 	for(Index = 0U; Index < Desc->MaxBlocks; Index++) {
 
-- 
2.39.2



More information about the devel mailing list