From d77a873ddb373aafe5927bbbb95fe3a1c2b6e6eb Mon Sep 17 00:00:00 2001 From: Kinsey Moore Date: Sat, 2 Dec 2023 14:17:26 -0600 Subject: [PATCH] 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++) {