summaryrefslogtreecommitdiffstats
path: root/bsps/shared
diff options
context:
space:
mode:
authorKinsey Moore <kinsey.moore@oarcorp.com>2023-10-19 13:26:29 -0500
committerJoel Sherrill <joel@rtems.org>2023-10-27 11:33:44 -0500
commit3363fabb9d1f03b0ce8219058b8013e92598a696 (patch)
tree0c8cdc5b138ee6730a7c61cdb861fe80071ae914 /bsps/shared
parentbsps/aarch64/zynqmp/nand: Erase using offset (diff)
downloadrtems-3363fabb9d1f03b0ce8219058b8013e92598a696.tar.bz2
bsps/xnandpsu: Avoid loop counter reset
On configurations where multiple NAND chips are in use, the erasure loop in XNandPsu_Erase() can reset the loop counter variable once it gets to blocks in the second chip causing an infinite loop overwriting parts of the first chip. This change ensures that the loop counter is not accidentally reset.
Diffstat (limited to 'bsps/shared')
-rw-r--r--bsps/shared/dev/nand/xnandpsu.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/bsps/shared/dev/nand/xnandpsu.c b/bsps/shared/dev/nand/xnandpsu.c
index e140364ce8..5aeee90084 100644
--- a/bsps/shared/dev/nand/xnandpsu.c
+++ b/bsps/shared/dev/nand/xnandpsu.c
@@ -1714,13 +1714,21 @@ s32 XNandPsu_Erase(XNandPsu *InstancePtr, u64 Offset, u64 Length)
for (Block = StartBlock; Block < (StartBlock + NumBlocks); Block++) {
Target = Block/InstancePtr->Geometry.NumTargetBlocks;
+#ifdef __rtems__
+ u32 ModBlock = Block % InstancePtr->Geometry.NumTargetBlocks;
+#else
Block %= InstancePtr->Geometry.NumTargetBlocks;
+#endif
/* Don't erase bad block */
if (XNandPsu_IsBlockBad(InstancePtr, Block) ==
XST_SUCCESS)
continue;
/* Block Erase */
+#ifdef __rtems__
+ Status = XNandPsu_EraseBlock(InstancePtr, Target, ModBlock);
+#else
Status = XNandPsu_EraseBlock(InstancePtr, Target, Block);
+#endif
if (Status != XST_SUCCESS)
goto Out;