As far as I know from the stm32_nvm.c implement
here we use 2 flash sector to store config parameters .
I find out descrition
* We consider each sector as an array of 64-bit fields except the first N bytes, which we
* instead use as an allocation block. The allocation block is a compact bit-field (2 bit per entry)
* that keeps track of the state of each field (erased, invalid, valid).
It tell me that the first N bytes used to indicate the state of field …
But when we write some buffer eg. buf[10]={0..10} to one sector . I find out the fist byte will be modify as 0b11110000 instead of 0 .
because of the sector alloc_table and data are both point to the FLASH_SECTOR_A_BASE address . so , how to distinguish the first N bytes?
sector_t sectors[] = { {
.sector_id = FLASH_SECTOR_A,
.n_data = FLASH_SECTOR_A_SIZE >> 3,
.n_reserved = (FLASH_SECTOR_A_SIZE >> 3) >> 5,
.alloc_table = FLASH_SECTOR_A_BASE,
.data = (uint64_t *)FLASH_SECTOR_A_BASE
}, {
.sector_id = FLASH_SECTOR_B,
.n_data = FLASH_SECTOR_B_SIZE >> 3,
.n_reserved = (FLASH_SECTOR_B_SIZE >> 3) >> 5,
.alloc_table = FLASH_SECTOR_B_BASE,
.data = (uint64_t *)FLASH_SECTOR_B_BASE
}};
Am I miss something ? It is normal for that implement?