diff options
author | Kinsey Moore <kinsey.moore@oarcorp.com> | 2023-10-25 16:22:07 -0500 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2023-12-14 13:40:03 -0600 |
commit | a6aa6c63851334c76d36daa12e979bacc34c6441 (patch) | |
tree | 0973eaf5e6470d43e283ad0505ff2171e85d4984 | |
parent | bsps/arm/stm32f4: Enable USART RX interrupts (diff) | |
download | rtems-a6aa6c63851334c76d36daa12e979bacc34c6441.tar.bz2 |
bsps/zynqmp/jffs2: Use BBT information directly
The XNandPsu_IsBlockBad() function is insufficient for JFFS2 to
determine whether a block is usable since the function does not report
reserved blocks. JFFS2 is also unable to use the last 4 blocks of each
target attached to the NAND controller since they are reserved for the
Bad Block Table (BBT), but not necessarily marked as such.
-rw-r--r-- | bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c b/bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c index cf2a7d8192..3fa70cc0c3 100644 --- a/bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c +++ b/bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c @@ -130,6 +130,10 @@ static int flash_block_is_bad( { XNandPsu *nandpsu = get_flash_control(super)->nandpsu; uint32_t BlockIndex; + uint8_t BlockData; + uint8_t BlockShift; + uint8_t BlockType; + uint32_t BlockOffset; assert(bad); @@ -137,10 +141,28 @@ static int flash_block_is_bad( return -EIO; } + *bad = true; + BlockIndex = offset / nandpsu->Geometry.BlockSize; rtems_mutex_lock(&(get_flash_control(super)->access_lock)); - *bad = (XNandPsu_IsBlockBad(nandpsu, BlockIndex) == XST_SUCCESS); + + /* XNandPsu_IsBlockBad() is insufficient for this use case */ + BlockOffset = BlockIndex >> XNANDPSU_BBT_BLOCK_SHIFT; + BlockShift = XNandPsu_BbtBlockShift(BlockIndex); + BlockData = nandpsu->Bbt[BlockOffset]; + BlockType = (BlockData >> BlockShift) & XNANDPSU_BLOCK_TYPE_MASK; + + if (BlockType == XNANDPSU_BLOCK_GOOD) { + *bad = false; + } + + int TargetBlockIndex = BlockIndex % nandpsu->Geometry.NumTargetBlocks; + /* The last 4 blocks of every device target are reserved for the BBT */ + if (nandpsu->Geometry.NumTargetBlocks - TargetBlockIndex <= 4) { + *bad = true; + } + rtems_mutex_unlock(&(get_flash_control(super)->access_lock)); return 0; } |