[rtems commit] bsps/xnandpsu: Mark correct reserved blocks

Joel Sherrill joel at rtems.org
Thu Dec 14 19:11:58 UTC 2023


Module:    rtems
Branch:    master
Commit:    d77a873ddb373aafe5927bbbb95fe3a1c2b6e6eb
Changeset: http://git.rtems.org/rtems/commit/?id=d77a873ddb373aafe5927bbbb95fe3a1c2b6e6eb

Author:    Kinsey Moore <kinsey.moore at oarcorp.com>
Date:      Sat Dec  2 14:17:26 2023 -0600

bsps/xnandpsu: Mark correct reserved blocks

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++) {
 



More information about the vc mailing list