<?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>Flash write</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/1776/flash-write</link><description>Hello, 
 I&amp;#39;m trying to write value to a specified address with ble_flash_page_write . 
 I&amp;#39;m using ble_flash_page_write after ble disconnect event. I&amp;#39;ve tested different page address to be sure i&amp;#39;m not writing on application or s110 areas and page address</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 18 Jul 2016 13:25:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/1776/flash-write" /><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7785?ContentTypeID=1</link><pubDate>Mon, 18 Jul 2016 13:25:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:010cadc2-a982-4db0-b7e8-03fd4a3ba222</guid><dc:creator>Peter</dc:creator><description>&lt;p&gt;Hi Thomas,&lt;/p&gt;
&lt;p&gt;Tested your code and works in raw mode for me.
Did you try removing the line
APP_ERROR_CHECK(result);&lt;/p&gt;
&lt;p&gt;from your ota_callback?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7784?ContentTypeID=1</link><pubDate>Wed, 12 Mar 2014 18:39:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0058623c-1d14-4afc-8152-d6f9baa7a1a5</guid><dc:creator>Krishna Shingala</dc:creator><description>&lt;p&gt;Thank you for the suggested improvement in documentation Thomas, yes, agreed it should be added here. Will be done in subsequent SDK release.&lt;/p&gt;
&lt;p&gt;Thanks again!&lt;/p&gt;
&lt;p&gt;Regards,
Krishna&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7783?ContentTypeID=1</link><pubDate>Tue, 11 Mar 2014 11:15:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:463e4736-d406-4028-94a8-74b350abe108</guid><dc:creator>thomas</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;In fact, i forgot to register for system events....Tanks for help.
Maybe this information ca be added to pstorage documentation page :
&lt;a href="https://devzone.nordicsemi.com/documentation/nrf51/5.1.0/html/a00131.html"&gt;https://devzone.nordicsemi.com/documentation/nrf51/5.1.0/html/a00131.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7782?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2014 19:49:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bb99947-b434-4cc2-8f3e-2262b80a785d</guid><dc:creator>Krishna Shingala</dc:creator><description>&lt;p&gt;Hi David,&lt;/p&gt;
&lt;p&gt;I would like to mention that pstorage implements a queue as SoftDevice permits only one flash access operation pending at a time. Hence issuing back to back erase is not a problem if you are receiving system events from SoftDevice and passing it on the pstorage module. It is on this event that the module pops next operation (if any) in its queue.&lt;/p&gt;
&lt;p&gt;Hence it is important that the procedures in the code snippet above are performed. Hope this helps!&lt;/p&gt;
&lt;p&gt;Regards,
Krishna&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7781?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2014 17:20:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb87b15f-07ec-4c76-bab7-9819ce34377d</guid><dc:creator>David Smoot</dc:creator><description>&lt;p&gt;I might be wrong but I think maybe you are getting the same issue I was getting.&lt;/p&gt;
&lt;p&gt;If I understand correctly, the calls to pstorage_raw_clear() and pstorage_raw_store() simply &lt;strong&gt;schedule&lt;/strong&gt; an erase and a store respectively.  So their return value just indicates that you scheduled an erase followed by a write.&lt;/p&gt;
&lt;p&gt;In my case, I had to set up an event handler to get the event indicating the erase operation was successful and then call the function to schedule the write in order for the write to succeed.  Not sure if this is what you are facing but I did notice you called an erase back to back with a write which was failing for me for the reason above.  Hope this helps.
David&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7780?ContentTypeID=1</link><pubDate>Thu, 06 Mar 2014 13:44:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3da2153d-3987-4a34-b5b0-108cf77a076f</guid><dc:creator>Krishna Shingala</dc:creator><description>&lt;p&gt;Hi Thomas,&lt;/p&gt;
&lt;p&gt;Can you confirm you have registered for system events and are passing it on to pstorage module?&lt;/p&gt;
&lt;p&gt;Below the code that may be useful you..!&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;


/**@brief Function for dispatching a system event to interested modules.
 *
 * @details This function is called from the System event interrupt handler after a system
 *          event has been received.
 *
 * @param[in]   sys_evt   System stack event.
 */
static void sys_evt_dispatch(uint32_t sys_evt)
{
    pstorage_sys_event_handler(sys_evt);
}

/**@brief BLE stack initialization.
 *
 * @details Initializes the SoftDevice and the stack event interrupt.
 */
static void ble_ant_stack_init(void)
{
    // Initialize SoftDevice
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);
    
    // Subscribe for BLE events.
    uint32_t err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    
    // Register with the SoftDevice handler module for BLE events.
    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);
}


&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hope this helps!&lt;/p&gt;
&lt;p&gt;Regards,
Krishna&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7779?ContentTypeID=1</link><pubDate>Thu, 06 Mar 2014 13:40:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed90ba51-0b85-4d11-81c8-e661d5db1b3c</guid><dc:creator>thomas</dc:creator><description>&lt;p&gt;any help ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7778?ContentTypeID=1</link><pubDate>Wed, 05 Mar 2014 11:50:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:866ea281-d527-4d9f-90f0-eaedf87570b2</guid><dc:creator>thomas</dc:creator><description>&lt;p&gt;I&amp;#39;ve tested with classic pstorage mode ( without raw mode)
My pstorage callback is never executed .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7777?ContentTypeID=1</link><pubDate>Tue, 04 Mar 2014 16:42:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:593192d1-63cc-4087-8fbe-4f755be45e6c</guid><dc:creator>thomas</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using finally pstorage Raw mode. My app (bluetooth modules) works fine( no err_code, no crash, no hard fault)...
But my pstorage callback is never executed...(debug led 1 never set).
Does anyone know were it can come from ?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
uint32_t		err_code;
uint8_t		ota_code[4]; 	
		
ota_code[0] = 0x81;
ota_code[1] = 0xAB;
ota_code[2] = 0xAC;
ota_code[3] = 0xAB;
		
		
pstorage_handle_t            handle;
pstorage_module_param_t            param;
uint32_t page_number = NRF_FICR-&amp;gt;CODESIZE-30;
uint32_t page_base_address = (uint32_t) (page_number * NRF_FICR-&amp;gt;CODEPAGESIZE);
		
param.block_size = 0x0010 ;
param.block_count = 1;
param.cb = ota_cb_handler;
		
handle.block_id = page_base_address; //bloc address
		
//registration
err_code = pstorage_raw_register(¶m, &amp;amp;handle);
APP_ERROR_CHECK(err_code);

handle.block_id = page_base_address; //definition de l&amp;#39;adresse du bloc

//clear
err_code = pstorage_raw_clear(&amp;amp;handle,0x0010);
APP_ERROR_CHECK(err_code);
				
//store
err_code = pstorage_raw_store(&amp;amp;handle,ota_code,4,0);
APP_ERROR_CHECK(err_code);

nrf_gpio_pin_set(LED_0); // debug led

&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;

static void ota_cb_handler(pstorage_handle_t  * handle,
                             uint8_t          	op_code,
                             uint32_t         	result,
                             uint8_t         		* p_data,
                             uint32_t         	data_len)
{
		
	APP_ERROR_CHECK(result);
	nrf_gpio_pin_set(LED_1);	//debug led													 
 }

&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7776?ContentTypeID=1</link><pubDate>Mon, 03 Mar 2014 17:58:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91b400d0-30d8-409c-a93b-a158052e5a0b</guid><dc:creator>thomas</dc:creator><description>&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7775?ContentTypeID=1</link><pubDate>Mon, 03 Mar 2014 17:53:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b055456-7fbf-4f2f-98e2-ef4c40182e22</guid><dc:creator>Krishna Shingala</dc:creator><description>&lt;p&gt;Hi Thomas,&lt;/p&gt;
&lt;p&gt;To give you an example, lets say you want to share bond information from application to boot-loader. Then this is what can be done:&lt;/p&gt;
&lt;p&gt;a. Ensure that pstorage_platform file has been provided with same start address. Number of applications and end address could be adjusted if you need more persistent memory in boot-loader mode.
b. Register bond related blocks in same order as in application mode once pstorage has been initialized.&lt;/p&gt;
&lt;p&gt;If this is done, and your bootloader is not overriding or clearing any of flash pages reserved for storing data persistently, you should be able to share information from application to bootloader.&lt;/p&gt;
&lt;p&gt;Regards,
Krishna&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7774?ContentTypeID=1</link><pubDate>Mon, 03 Mar 2014 17:46:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e879623-40df-4151-8263-0e2a9d52c97d</guid><dc:creator>thomas</dc:creator><description>&lt;p&gt;Thanks for response ,&lt;/p&gt;
&lt;p&gt;And for you , what is the best solution to share values between the main app and the bootloader (like a flag) ? The Raw mode ?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Thomas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7773?ContentTypeID=1</link><pubDate>Mon, 03 Mar 2014 17:03:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:490b30ad-f81a-4594-a2ea-5e17d4ef0dc9</guid><dc:creator>Krishna Shingala</dc:creator><description>&lt;p&gt;Hi Thomas,&lt;/p&gt;
&lt;p&gt;You should know that ble_flash module cannot be used when SoftDevice is enabled. This was done post SoftDevice 6.0.0 release, when flash access was offered as a part of SoftDevice functionality.&lt;/p&gt;
&lt;p&gt;Also, in case you need the address, in pstorage block_id of pstorage_handle_t contains actual flash access. Accessing the flash access yourself is not recommended for typical use cases.&lt;/p&gt;
&lt;p&gt;In case you do want to access all flash yourself, raw mode is appropriate. In this case, you need follow the following steps:
a. Initilaize pstorage using pstorage_init();
b. Register the application in raw mode using the pstorage_raw_register() with appropriate parameters. You will provided a handle here. The module id in this handle identifies your application. Block id of the handle can be manipulated to any flash access to desire to access subsequently.
c. Assign block_id field of the handle to an appropriate word aligned flash address (not page number). And call pstorage_raw_store. Do ensure that your source data lies in resident memory as flash access is no longer blocking.&lt;/p&gt;
&lt;p&gt;For an example usage of raw mode, you can look at the boot-loader included in the SDK. This is the only application using raw mode.&lt;/p&gt;
&lt;p&gt;Hope this helps!&lt;/p&gt;
&lt;p&gt;Regards,
Krishna&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7772?ContentTypeID=1</link><pubDate>Mon, 03 Mar 2014 11:58:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:000cca79-780f-4ac7-aaed-06ce3800a5ec</guid><dc:creator>thomas</dc:creator><description>&lt;p&gt;i&amp;#39;m calling ble_flash_page_write() just after the ble disconnect event and before to start advertisment.&lt;/p&gt;
&lt;p&gt;I tried to use pstorage manager, but don&amp;#39;t understand how to specify exactly were i want to write  (i need to read this value from the bootloader or an external flasher..). Raw mode seems to be appropriate but i don&amp;#39;t find documentation about this, just last lines of the pstorage lib documentation. &lt;a href="https://devzone.nordicsemi.com/documentation/nrf51/5.1.0/html/a00131.html"&gt;https://devzone.nordicsemi.com/documentation/nrf51/5.1.0/html/a00131.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash write</title><link>https://devzone.nordicsemi.com/thread/7771?ContentTypeID=1</link><pubDate>Mon, 03 Mar 2014 11:38:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa862877-0b32-485d-9aca-90a1baa2f818</guid><dc:creator>Balaji Srinivasan</dc:creator><description>&lt;p&gt;Hi Thomas,&lt;/p&gt;
&lt;p&gt;Are you calling ble_flash_page_write() when you are in a connection (connected to a peer)? That could be a reason for hardfault. You can either call this API when not in a connection (if that suits your usecase). Or you can use the API ble_flash_word_write instead. (This assumes that the Flash location to be written has been erased previously)&lt;/p&gt;
&lt;p&gt;It is recommended that you use the &amp;#39;Persistent Storage Interface&amp;#39; (pstorage.h) instead of the &amp;#39;Flash Manager&amp;#39; (ble_flash.h) to perform flash related operations. It has been added to the nRF51 SDK sicne version 5.0.0. It helps in handling asynchronous flash memory access without the application needing to know whether the radio is active (connected to the peer).&lt;/p&gt;
&lt;p&gt;Cheers,
Balaji&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>