Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions common/src/lx_nor_flash_next_block_to_erase_find.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ULONG max_logical_sector;
UINT status;
#endif
UINT obsolete_sectors_available;
UINT mapped_sectors_available;
UINT mapped_sectors_available = LX_FALSE;


/* Setup the block word pointer to the first word of the search block. */
Expand Down Expand Up @@ -171,9 +171,10 @@ UINT mapped_sectors_available;
if (erase_count > max_system_block_erase_count)
max_system_block_erase_count = erase_count;

/* Initialize the obsolete and mapped sector count available flags. */
/* Initialize the mapped sector count and the obsolete/mapped sector count availability flags. */
obsolete_sectors_available = LX_FALSE;
mapped_sectors_available = LX_FALSE;
mapped_sectors = 0;

#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE

Expand Down Expand Up @@ -469,5 +470,4 @@ UINT mapped_sectors_available;
}
/* Return success. */
return(LX_SUCCESS);
}

}
38 changes: 38 additions & 0 deletions test/regression/levelx_nor_flash_test_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/* SPDX-License-Identifier: MIT */
/***************************************************************************/

/* Portions of this file were generated with AI assistance. */

/* Basic NOR flash tests... */

#include <stdio.h>
Expand Down Expand Up @@ -82,6 +84,12 @@ ULONG i, j, sector;
UINT status;

ULONG *word_ptr;
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
ULONG erase_block = LX_ALL_ONES;
ULONG erase_count = LX_ALL_ONES;
ULONG mapped_sectors = LX_ALL_ONES;
ULONG obsolete_sectors = LX_ALL_ONES;
#endif


/* Initialize LevelX. */
Expand Down Expand Up @@ -1660,6 +1668,36 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2,
}
}

#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
/* Verify the mapped sector count when the obsolete count comes from the cache. */
printf("\nTest 7: Cached obsolete count with mapped sectors..");

status = lx_nor_flash_sector_release(&nor_sim_flash, 0);
if (status == LX_SUCCESS)
{
status = _lx_nor_flash_next_block_to_erase_find(&nor_sim_flash, &erase_block, &erase_count,
&mapped_sectors, &obsolete_sectors);
}

if ((status != LX_SUCCESS) ||
(nor_sim_flash.lx_nor_flash_extended_cache_obsolete_count_max_block == 0) ||
(nor_sim_flash.lx_nor_flash_extended_cache_obsolete_count[0] != 1) ||
(erase_block != 0) ||
(erase_count != nor_sim_flash.lx_nor_flash_minimum_erase_count) ||
(mapped_sectors != (nor_sim_flash.lx_nor_flash_physical_sectors_per_block - 1)) ||
(obsolete_sectors != 1))
{
printf("FAILED!\n");
#ifdef BATCH_TEST
exit(1);
#endif
while(1)
{
}
}
printf("SUCCESS!\n");
#endif

#ifdef BATCH_TEST
exit(0);
#endif
Expand Down