This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Pstorage understanding memory utilization

Hi, Merry Christmas!

I have a question about pstorage_store. Actually, I want to store some data in the memory. Each piece of data has its own size (between 1 byte to 4 bytes) . In total, I need 52 bytes for all data. So I did this:

param.block_size = 0x08;
param.block_count = 7;

8 bytes x 7 = 56 bytes

I write something like this in the memory:

pstorage_handle_t block_handle;
	
	uint32_t retval;
	uint8_t tab[4]={0x12,0x13,0x14,0x15};
	retval = pstorage_block_identifier_get(&app_data_flash_manager_handle, 4, &block_handle);
	
	
	dataToStore[0] = tab[0]
	dataToStore[1] = tab[1];
	dataToStore[2] = tab[2];	
	dataToStore[3] = tab[3];

	
	retval = pstorage_store(&block_handle, dataToStore, 4, 0);

So how much memory are used ? 1)8x4=32 bytes( size =4 and block_siz=8) 2) only 4 bytes ( uint8_t x 4 )?

Then I need to write only 1 byte

retval = pstorage_store(&block_handle, dataToStore, 1, 0);

And why it is not working? I have this error : NRF_ERROR_INVALID_LENGTH

Related