<?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>How to know it started first time after flash firmware.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6337/how-to-know-it-started-first-time-after-flash-firmware</link><description>I&amp;#39;m actually writing some data to the flash. I&amp;#39;m using pstorage api interface. 
 But whenever I flash the new firmware, I get some garbage data.
in my main function I would like to know that, after flashing a new firmware, it started for the first time</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 06 Apr 2015 09:12:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6337/how-to-know-it-started-first-time-after-flash-firmware" /><item><title>RE: How to know it started first time after flash firmware.</title><link>https://devzone.nordicsemi.com/thread/22100?ContentTypeID=1</link><pubDate>Mon, 06 Apr 2015 09:12:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ed5906e-3d27-4174-a6e7-9ffa2a1b09e1</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi mobi,&lt;/p&gt;
&lt;p&gt;I called it flags, but it could be anything that you set in flash.&lt;/p&gt;
&lt;p&gt;I am not fully understand what you meant by &amp;quot;waste data&amp;quot;. If you want to erase/modify something on flash, you would need to erase the whole page (1024 byte).
To write data to an address in flash when programming, you should use &lt;strong&gt;attribute&lt;/strong&gt; and set the address and the value you want to write to flash.
You can refer on how we do it in file bootloader_settings_arm.c in the dfu bootloader example in the nRF51 SDK.&lt;/p&gt;
&lt;p&gt;For example here we write BOOTLOADER_REGION_START value to NRF_UICR_BOOT_START_ADDRESS address:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint32_t m_uicr_bootloader_start_address __attribute__((at(NRF_UICR_BOOT_START_ADDRESS))) = BOOTLOADER_REGION_START;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to know it started first time after flash firmware.</title><link>https://devzone.nordicsemi.com/thread/22103?ContentTypeID=1</link><pubDate>Mon, 06 Apr 2015 04:25:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:478dfa80-ae30-4690-a4c0-f70db8a2f5b1</guid><dc:creator>mobi</dc:creator><description>&lt;p&gt;BTW, can you point me where to get some more knowledge about flags? what you have suggested? So, on flashing the firmware if I can set some flag. And when the application runs I can check that flag. Can I also reset that flag from that application again ?
Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to know it started first time after flash firmware.</title><link>https://devzone.nordicsemi.com/thread/22102?ContentTypeID=1</link><pubDate>Mon, 06 Apr 2015 04:22:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64695a8f-c141-48ed-9aa5-6422df4e33a9</guid><dc:creator>mobi</dc:creator><description>&lt;p&gt;Hi Hung, I have implemented similar to what you suggested already, that is, I write some header in flash.
On Start of the firmware, I read header, if the header is not correct, that mean entire flash data is not valid and I need to erase that. But I have to waste a page data (140 bytes). Rest of the pages are used for other data and information storage. So, if there is an alternate to wasting page data, that will be great.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to know it started first time after flash firmware.</title><link>https://devzone.nordicsemi.com/thread/22101?ContentTypeID=1</link><pubDate>Mon, 06 Apr 2015 03:48:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e2b243f-121f-4d28-b13c-0ad5e2e1d9a4</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@mobi: Could you elaborate a little bit more ?
My understanding is when you flash the firmware you write some flags (garbage data) to a location on flash.&lt;br /&gt;
On the first time when the firmware starts, it will read that address and if the flags are set, it will clear the flags. So that next time when the device reset or restart it will be able to detect by reading the flags&amp;#39; address again ?
If it&amp;#39;s correct, I don&amp;#39;t see a problem with this approach.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>