uint8_t data5[SIZE];
for (i = 0u; i < 5; i++)
{
data5[i] = i+1;
}
uint8_t data2[SIZE];
for (i = 0u; i < 2; i++)
{
data2[i] = i+1;
}
uint8_t data7[SIZE];
for (i = 0u; i < 7; i++)
{
data7[i] = i+1;
}
These are my datas. I want to write to flash memory with the most efficient way but It fills the remainder of the 8-byte section with 0s. But I want to write other data to come
while(address<FLASH_END_ADDRESS){
volatile uint32_t random_num = (rand() % 3) + 1;
if(random_num == 1u){
ret = FLASH_DRV_Program(&flashSSDConfig, address, sizeof(data5), data5);
DEV_ASSERT(STATUS_SUCCESS == ret);
address += sizeof(data5);
}
else if (random_num==2u){
ret = FLASH_DRV_Program(&flashSSDConfig, address, sizeof(data2), data2);
DEV_ASSERT(STATUS_SUCCESS == ret);
address += sizeof(data2);
}
else if (random_num==3u){
ret = FLASH_DRV_Program(&flashSSDConfig, address, sizeof(data7), data7);
DEV_ASSERT(STATUS_SUCCESS == ret);
address += sizeof(data7);
}
}
Here is my writing process
Hi @joshfx
in this case, it doesn't matter what the alignment is. Smallest portion of flash which can be programmed is one phrase which is 8 bytes. Cumulative programming within one phrase is not allowed, the phrase must be in fully erased state before programming.
It's mentioned also in the SDK user manual:
If you want to avoid the alignment of char arrays to 4 bytes anyway, you can put them to structure - then there won't be those gaps.
Regards,
Lukas