<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>pstorage block size</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/2843/pstorage-block-size</link><description>What exactly is block size in pstorage? 
 
 Desired block size for persistent memory storage, for example, if a module has a table with 10 entries, each entry is size 64 bytes,
it can request 10 blocks with block size 64 bytes. On the other hand, the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Jul 2015 19:32:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/2843/pstorage-block-size" /><item><title>RE: pstorage block size</title><link>https://devzone.nordicsemi.com/thread/10845?ContentTypeID=1</link><pubDate>Mon, 20 Jul 2015 19:32:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c28b8f8-40b6-420c-8bea-a5bf23e8a96c</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;it doesn&amp;#39;t work with softdevice at all&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage block size</title><link>https://devzone.nordicsemi.com/thread/10844?ContentTypeID=1</link><pubDate>Sat, 13 Sep 2014 00:19:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9037d5dd-6c0b-42bf-ab88-81c69948ddce</guid><dc:creator>mira67</dc:creator><description>&lt;p&gt;Hi Håkon Alseth , I am using this example code, but the op_code returned from the example_cb_handler is always 0x02, PSTORAGE_STORE_OP_CODE    0x02, why it this?
Before the example code, I use ble_stack_init() to enable softdevice, anything missing?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage block size</title><link>https://devzone.nordicsemi.com/thread/10843?ContentTypeID=1</link><pubDate>Wed, 13 Aug 2014 07:35:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f6727f7-8f6f-4d6d-a86f-7fd9819a8851</guid><dc:creator>kk</dc:creator><description>&lt;p&gt;thank you very much, i made it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage block size</title><link>https://devzone.nordicsemi.com/thread/10842?ContentTypeID=1</link><pubDate>Wed, 13 Aug 2014 06:31:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f31e0d3f-814c-4cdc-a70f-8d291d65a800</guid><dc:creator>S&amp;#233;bastien Despont</dc:creator><description>&lt;p&gt;Here is the signature of the handler :&lt;/p&gt;
&lt;p&gt;void pstorage_cb_handler(pstorage_handle_t * handle,
uint8_t             op_code,
uint32_t            result,
uint8_t           * p_data,
uint32_t            data_len)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage block size</title><link>https://devzone.nordicsemi.com/thread/10841?ContentTypeID=1</link><pubDate>Wed, 13 Aug 2014 06:28:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79b89746-e77c-424f-92b2-c43730668e5f</guid><dc:creator>kk</dc:creator><description>&lt;p&gt;Hi,Håkon Alseth!
I want to ask you how do you creat and initialize your example_cb_hanlder?
Because I did as what you said and return a NRF_ERROR_NULL when running NULL_PARAM_CHECK(p_module_param-&amp;gt;cb);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage block size</title><link>https://devzone.nordicsemi.com/thread/10847?ContentTypeID=1</link><pubDate>Tue, 05 Aug 2014 13:46:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79c22da6-77ce-4bc2-9912-9019ff9c533f</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;That&amp;#39;s true! thanks for pointing that out. Will fix that ASAP.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage block size</title><link>https://devzone.nordicsemi.com/thread/10846?ContentTypeID=1</link><pubDate>Tue, 08 Jul 2014 11:07:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:365d0bfd-a303-4503-abe2-1221dcb8ba92</guid><dc:creator>S&amp;#233;bastien Despont</dc:creator><description>&lt;p&gt;@Håkon Alseth : Your example is not working because the data to store &amp;quot;dummy_data&amp;quot; are defined in a context potentially no longer available when the pstorage queue (asynchronous) will process the task .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage block size</title><link>https://devzone.nordicsemi.com/thread/10840?ContentTypeID=1</link><pubDate>Thu, 19 Jun 2014 14:44:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8141af53-c02a-4d3f-b564-9548727159bb</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;The total allocated space by the pstorage is set by:
block_size * block_count = total flash space&lt;/p&gt;
&lt;p&gt;for instance:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static pstorage_handle_t m_p_example_id;
...
static void example_pstorage_init()
{
	uint32_t err_code;         
	pstorage_module_param_t p_example_param;	
	
	// Setup pstorage with 60blocks of 16byte in each.
	p_example_param.block_size  = 0x10; // recommended to be &amp;gt;= 4 byte
	p_example_param.block_count = 60;
	p_example_param.cb          = example_cb_handler;

	err_code = pstorage_init();
	APP_ERROR_CHECK(err_code);  
	
	err_code = pstorage_register (&amp;amp;p_example_param, &amp;amp;m_p_example_id);
	APP_ERROR_CHECK(err_code);  
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will allocate 960 bytes in flash, divided into 60 blocks of 16 bytes each.
The minimum block-size is set by define PSTORAGE_MIN_BLOCK_SIZE in pstorage_platform.h&lt;/p&gt;
&lt;p&gt;To store data into one of these blocks, you can do like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Init pstorage for application storage
example_pstorage_init();

// Store some data to first block
{
	uint32_t err_code;         
	
	uint16_t dummy_block = 0;
    // Must be static as the pstorage module processes the queue asynchronously
	static uint8_t dummy_data[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
	uint16_t dummy_size = 16;
	uint16_t dummy_offset = 0;
	pstorage_handle_t p_block_id;
	
	err_code = pstorage_block_identifier_get(&amp;amp;m_p_example_id, dummy_block, &amp;amp;p_block_id);
	APP_ERROR_CHECK(err_code);
	
	err_code = pstorage_store(&amp;amp;p_block_id, dummy_data, dummy_size, dummy_offset);
	APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The pstorage_block_identifier_get will specify which instance/ID is trying to access it&amp;#39;s chunk of data (ID is written into m_p_example_id, similar to what app_timer/app_gpiote also does) and set p_block_id to the right address corresponding to your block.&lt;/p&gt;
&lt;p&gt;Then you store the data using pstorage_store(...).&lt;/p&gt;
&lt;p&gt;Since this module uses the softdevice flash API, the events will be processed through the function given into &amp;quot;softdevice_sys_evt_handler_set()&amp;quot;.&lt;/p&gt;
&lt;p&gt;You can read back the data using this function (after you&amp;#39;ve gotten the event in the above handler):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = pstorage_load(my_buffer, &amp;amp;p_block_id, dummy_size, dummy_offset);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>