<?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>Can&amp;#39;t seem to get the fstorage library to work properly.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93170/can-t-seem-to-get-the-fstorage-library-to-work-properly</link><description>I&amp;#39;m trying to get some data written and read from flash memory using the fstorage library as explained in the examples provided with the sdk. 
 I write to flash and get the callback saying that the bytes were written and try to read them back with garbage</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Oct 2022 03:28:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93170/can-t-seem-to-get-the-fstorage-library-to-work-properly" /><item><title>RE: Can't seem to get the fstorage library to work properly.</title><link>https://devzone.nordicsemi.com/thread/392274?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2022 03:28:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b74065f2-b788-4e27-b764-7083e62ccd78</guid><dc:creator>JosephAzar</dc:creator><description>&lt;p&gt;Ok we got it sorted. &lt;br /&gt;The problem was the actual memory addresses used, so for anyone who comes across this in the future, the way I solved it was to use this method to adjust the memory used:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint32_t nrf5_flash_end_addr_get()
{
    uint32_t const bootloader_addr = BOOTLOADER_ADDRESS;
    uint32_t const page_sz         = NRF_FICR-&amp;gt;CODEPAGESIZE;
    uint32_t const code_sz         = NRF_FICR-&amp;gt;CODESIZE;
    
    uint32_t returnvalue = 0;
    returnvalue = (bootloader_addr != 0xFFFFFFFF ? bootloader_addr : (code_sz * page_sz));
    return returnvalue;
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This method is used to return the end of the memory taking into account the bootloader position.&lt;br /&gt;So this method returns the end address and i subtracted the size of memory that I wanted and got the start address like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;end_addr = nrf5_flash_end_addr_get();
fstorage.end_addr = end_addr;
start_addr = end_addr - 0x400;
fstorage.start_addr = start_addr; &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This has to be done before the nrf_fstorage_init command.&lt;br /&gt;&lt;br /&gt;After that I used the start address to write the bytes i needed and as mentioned everywhere it has to be 32 bit values so multiples of 4 bytes, anything less would return error 0x09.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't seem to get the fstorage library to work properly.</title><link>https://devzone.nordicsemi.com/thread/392146?ContentTypeID=1</link><pubDate>Mon, 24 Oct 2022 12:07:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79741567-a981-4845-9a65-e317ab2bacaf</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t immediately see the problem here. Did you remember to do a full erase before testing this code? That is important in case the address you write to was not erased from before, and a write can only flip bits from &amp;#39;1&amp;#39; to &amp;#39;0&amp;#39;. If that is not the problem, then perhaps you can upload a full failing example so that I can have a closer look?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>