eclipse-threadx / levelx

Eclipse ThreadX - LevelX Provides Flash Wear Leveling for FileX and Stand Alone purposes.
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/levelx/index.md
MIT License
102 stars 61 forks source link

NOR simulator assumes sizeof(ULONG) == 4 #22

Open jiri-novotny opened 1 year ago

jiri-novotny commented 1 year ago

Provided example assumes sizeof(ULONG) is 4B

    /* Setup pointer.  */
    pointer =  (ULONG *) &nor_memory_area[0];

    /* Loop to erase block.  */
    words =  sizeof(nor_memory_area)/(sizeof(ULONG));
    while (words--)
    {

        /* Erase word of block.  */
        *pointer++ =  (ULONG) 0xFFFFFFFF;
    }

when changed to

memset((uint8_t *) &nor_memory_area[0], 0xFF, sizeof(FLASH_BLOCK) * TOTAL_BLOCKS);

subsequent write/read test failes

jiri-novotny commented 1 year ago

also internal checks are done in 4B mode, e.g. in _lx_nor_flash_logical_sector_find

if (list_word == LX_NOR_PHYSICAL_SECTOR_FREE)

with

#define LX_NOR_SECTOR_MAPPING_CACHE_ENTRY_MASK      0x7FFFFFFF
#define LX_NOR_SECTOR_MAPPING_CACHE_ENTRY_VALID     0x80000000

#define LX_NOR_PHYSICAL_SECTOR_VALID                0x80000000
#define LX_NOR_PHYSICAL_SECTOR_SUPERCEDED           0x40000000
#define LX_NOR_PHYSICAL_SECTOR_MAPPING_NOT_VALID    0x20000000
#define LX_NOR_LOGICAL_SECTOR_MASK                  0x1FFFFFFF
#define LX_NOR_PHYSICAL_SECTOR_FREE                 0xFFFFFFFF
jiri-novotny commented 1 year ago

this should be solved in PR #23