<?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>weird behavior of pstorage_update function</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17133/weird-behavior-of-pstorage_update-function</link><description>Hi, 
 If I am honest I have encountered a weirdest problem since I have been programming. Here is the code (function void scheduler_mass_history_handler) which is executed every 15s. Everythink works great if pstorage_update(&amp;amp;block_0_handle, m_mass.histroy_last</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 21 Oct 2016 13:48:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17133/weird-behavior-of-pstorage_update-function" /><item><title>RE: weird behavior of pstorage_update function</title><link>https://devzone.nordicsemi.com/thread/65752?ContentTypeID=1</link><pubDate>Fri, 21 Oct 2016 13:48:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13e6e491-5c95-48e2-893d-e454eb7e0300</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Samo&lt;/p&gt;
&lt;p&gt;This is the check in the pstorage_update function that checks the word alignment and potentially throws the NRF_ERROR_INVALID_ADDR error.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if ((!is_word_aligned(p_src))                    || 
    (!is_word_aligned((void *)(uint32_t)offset)) || 
    (!is_word_aligned((uint32_t *)p_dest-&amp;gt;block_id)))
{
    return NRF_ERROR_INVALID_ADDR;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is it thrown from this code in the pstorage_update function in pstorage.c file? If so, set breakpoint there and check what is causing it. If not, where is the NRF_ERROR_INVALID_ADDR error thrown?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: weird behavior of pstorage_update function</title><link>https://devzone.nordicsemi.com/thread/65754?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2016 11:34:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26929b8d-97e9-404b-89ac-ef14f234f6f2</guid><dc:creator>samo</dc:creator><description>&lt;p&gt;Hi Stefan&lt;/p&gt;
&lt;p&gt;As you can see from code above this is not the case (retval =   pstorage_update(&amp;amp;block_0_handle, m_mass.histroy_last, 80, 76); ). I do not understand why pstorage_update throws error only if the m_mass.history array is declared among the last variables in ble_mass_t struct otherwise everything works fine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: weird behavior of pstorage_update function</title><link>https://devzone.nordicsemi.com/thread/65755?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2016 11:06:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:207a8a1f-2a99-44c8-a1a3-3f8c333e37a3</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Samo&lt;/p&gt;
&lt;p&gt;When using pstorage, you need to have writes/updates word aligned, i.e. 4,8,12,16,... bytes. Perhaps that is causing the address error.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: weird behavior of pstorage_update function</title><link>https://devzone.nordicsemi.com/thread/65756?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2016 10:47:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4943ed00-25cb-481c-aa47-aba627286450</guid><dc:creator>samo</dc:creator><description>&lt;p&gt;Hi Stefan&lt;/p&gt;
&lt;p&gt;Thanks for reply. I make this. I used pstorage file from SDK 10. It should be noted that I changed config file as well. Unfortunately, I got the same weird behavior such as presented in my first post. Do you have any other ideal what can be reason for my problem.&lt;/p&gt;
&lt;p&gt;Thanks in advance&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: weird behavior of pstorage_update function</title><link>https://devzone.nordicsemi.com/thread/65753?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2016 09:07:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1658e9f2-d508-4a98-b12e-ddb6dacf0488</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Samo&lt;/p&gt;
&lt;p&gt;To start with, I would recommend to update your pstorage module to SDK 9.0.0 or more recent. Pstorage was refactored in SDK 9.0.0. There is a bug in pstorage of SDK 8 and older that can cause race condition and weird behavior. pstorage module is not dependent on any other modules so it should be relatively easy just to copy pstorage.h, pstorage.c and pstorage_platform.h files from SDK 9+ into your current project and start using it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: weird behavior of pstorage_update function</title><link>https://devzone.nordicsemi.com/thread/65751?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2016 10:13:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92c13b0e-2f7f-409f-a04b-037757d09eb2</guid><dc:creator>samo</dc:creator><description>&lt;p&gt;Hi Stefan&lt;/p&gt;
&lt;p&gt;thanks for your fast reply. I am using SDK 7.2 together with softdevice S110 7.3.0 (88kB). I tested program on PCA10028 board and custom-made board as well, but I came across the same problem. The compatibility between SDK and SofDevice was checked according to the following instructions &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf51%2Fdita%2Fnrf51%2Fpdflinks%2Fnrf51_comp_matrix.html"&gt;infocenter.nordicsemi.com/index.jsp&lt;/a&gt;. It is worth mentioning if array is declared in main.c file then everythink works well. Due to this fact I think that the problem is related to location of array.&lt;/p&gt;
&lt;p&gt;Thanks for help in advance&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: weird behavior of pstorage_update function</title><link>https://devzone.nordicsemi.com/thread/65750?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2016 09:52:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:013b75cf-3b12-4605-a8ca-cd040b568d24</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Samo&lt;/p&gt;
&lt;p&gt;Can you share what SDK version you are using, what softdevice and what IC?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>