<?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>Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29926/bug-in-peer-manager-in-sdk-14-2</link><description>I have recently ported my nRF52832 application from SDK 12.3 to SDK 14.2 and have been disappointed to find that the preripheral is locking up after a period in operation. 
 In order to track down the issue I left the debugger running until the application</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 16 Mar 2019 11:58:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29926/bug-in-peer-manager-in-sdk-14-2" /><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/176549?ContentTypeID=1</link><pubDate>Sat, 16 Mar 2019 11:58:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bd9713c-feb0-42e0-a00b-64573f2c514f</guid><dc:creator>dkkeller</dc:creator><description>&lt;p&gt;This was fixed with&amp;nbsp;SDK15.0.0 &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f44d.svg" title="Thumbsup"&gt;&amp;#x1f44d;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/121640?ContentTypeID=1</link><pubDate>Thu, 22 Feb 2018 10:04:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3dafbd67-43f2-46de-9860-d41509a062ea</guid><dc:creator>Amy</dc:creator><description>&lt;div&gt;Hi Petter,&lt;/div&gt;
&lt;div&gt;I faced the same issue.&lt;/div&gt;
&lt;div&gt;Could you also provide the SDK14.0.0 for peer_database.c?&lt;/div&gt;
&lt;div&gt;The code base is changed a lot between SDK14.2.0 adn SDK14.0.0&lt;/div&gt;
&lt;div&gt;Thanks.&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/119635?ContentTypeID=1</link><pubDate>Sun, 04 Feb 2018 05:11:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed22f071-d243-4fdc-a45a-51b860fa8f11</guid><dc:creator>jumpingfool</dc:creator><description>&lt;p&gt;Yes, that&amp;#39;s fixed it - thanks!&lt;/p&gt;
&lt;p&gt;Even after reviewing your changes I still have no idea what the cause of the problem was, I can only be thankful that Nordic have such a skilled support team. :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/119433?ContentTypeID=1</link><pubDate>Thu, 01 Feb 2018 21:33:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6bcb09fc-b4f2-4236-bb4f-c242332ec773</guid><dc:creator>yacine</dc:creator><description>&lt;p&gt;Forget my comment you&amp;#39;re right,it has nothing to do with your issue. the only common points are gatt and sdk14. It&amp;#39;s too late, I need rest !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/119430?ContentTypeID=1</link><pubDate>Thu, 01 Feb 2018 20:52:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2555f15a-a23e-457a-9d44-422fb741b1f1</guid><dc:creator>yacine</dc:creator><description>&lt;p&gt;the last lines are:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;nrf_sdh_ble: BLE event: 0x12. // BLE_GAP_EVT_CONN_PARAM_UPDATE&lt;br /&gt;&lt;span&gt;nrf_sdh_ble: BLE event: 0x12. // BLE_GAP_EVT_CONN_PARAM_UPDATE&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;It stays like this.&amp;nbsp;I use the same client as for SDK12. with SDK12 it connects and I can write/read etc.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/119429?ContentTypeID=1</link><pubDate>Thu, 01 Feb 2018 20:46:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53f0926e-33f3-4e54-8fc4-727e0062ac35</guid><dc:creator>jumpingfool</dc:creator><description>&lt;p&gt;yacine - this looks like a different issue to me.&amp;nbsp;What does the stack trace look like when your app gets stuck?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/119424?ContentTypeID=1</link><pubDate>Thu, 01 Feb 2018 20:08:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77d64907-4862-4d32-9294-ef8a50dac119</guid><dc:creator>yacine</dc:creator><description>&lt;p&gt;hello Peter, jumpingfool,&lt;/p&gt;
&lt;p&gt;I have a very similar problem since my migration to SDK14, but without the flash problems.&lt;/p&gt;
&lt;p&gt;&amp;lt;debug&amp;gt; &lt;span&gt;my_app:&amp;nbsp;&lt;/span&gt;Advertising....&lt;br /&gt;&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x10. //BLE_GAP_EVT_CONNECTED&lt;br /&gt;&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x23. //BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST&lt;br /&gt;&amp;lt;debug&amp;gt; ble_gatt: Peer on connection 0x0 requested a data length of 27 bytes.&lt;br /&gt;&amp;lt;debug&amp;gt; ble_gatt: Updating data length to 27 bytes on connection 0x0.&lt;br /&gt;&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x24. //BLE_GAP_EVT_DATA_LENGTH_UPDATE&lt;br /&gt;&amp;lt;debug&amp;gt; ble_gatt: Data length updated to 27 on connection 0x0.&lt;br /&gt;&amp;lt;debug&amp;gt; ble_gatt: max_rx_octets: 27&lt;br /&gt;&amp;lt;debug&amp;gt; ble_gatt: max_tx_octets: 27&lt;br /&gt;&amp;lt;debug&amp;gt; ble_gatt: max_rx_time: 328&lt;br /&gt;&amp;lt;debug&amp;gt; ble_gatt: max_tx_time: 328&lt;br /&gt;&amp;lt;debug&amp;gt; my_app: ATT MTU exchange completed. central 0x17 peripheral 0x17&lt;br /&gt;&lt;strong&gt;&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x12. //BLE_GAP_EVT_CONN_PARAM_UPDATE&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x12. //BLE_GAP_EVT_CONN_PARAM_UPDATE&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;After the GATT negotiation, I receive two or three&amp;nbsp;&lt;span&gt;BLE_GAP_EVT_CONN_PARAM_UPDATE and I&amp;#39;lm stucked here.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;on SDK12 (-without the gatt), it worked like a charm&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;thx&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;yacine&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/119020?ContentTypeID=1</link><pubDate>Wed, 31 Jan 2018 14:47:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbe59bff-77eb-4163-a68b-dda1e6ca1539</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I see.&lt;/p&gt;
&lt;p&gt;The CCCD shall be persistent across connections for bonded devices. See Section 3.3.3.3, Part G, Vol. 3 in the Bluetooth core v5 spec.&lt;/p&gt;
&lt;p&gt;Thank you for the information, I will have to look into this further. Will update here when I have any news.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Edit 02.02.2018&lt;/p&gt;
&lt;p&gt;Could you try&amp;nbsp;fix this and see if it resolves the issue?&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-58692f8200b0403d84ec128c86010545/fix.rar"&gt;devzone.nordicsemi.com/.../fix.rar&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/119019?ContentTypeID=1</link><pubDate>Wed, 31 Jan 2018 14:29:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a2f626f-94e1-49d1-87a4-d371369b4c52</guid><dc:creator>jumpingfool</dc:creator><description>&lt;p&gt;Just trying to debug a little further (which is quite hard as adding logging seems to cause thread priority issues!) it seems that the peer database updates that are initiated after garbage collection has started but before it has completed get stuck in a loop calling reattempt_previous_operations() where the call to write_space_reserve() is returning FDS_ERR_NO_SPACE_IN_FLASH which then generates PM_EVT_STORAGE_FULL and it goes around in a cycle. This is despite the fact that all indications are that garbage collection has finished by this point so there should be storage available - as evidenced by the fact that the FDS_EVT_GC has been received and the output of fds_stat() which shows the dirty pages are gone. Perhaps peer manager is getting out of sync with FDS somehow because of the GC operation moving where the record for the peer data is located in flash after the write operation has started, but the code around that is mighty complicated and I am struggling to follow the logic. At this point I think the workaround for me is simply to put a delay in between writing to each CCCD on the iOS side - that is a fudge I&amp;#39;d rather avoid if I can but I need to move past this issue. What I can say is this issue was not present in SDK 12.3.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/119016?ContentTypeID=1</link><pubDate>Wed, 31 Jan 2018 12:58:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57e1fe24-8776-46fa-a137-5f7f3fe801b3</guid><dc:creator>jumpingfool</dc:creator><description>&lt;p&gt;Ok, so this is confirmed, if I limit my app to only writing to one CCCD at connection time then everything works as expected - if the flash buffer is full GC completes fine and everything runs normally. So the issue is that the peer manager/FDS is not correctly managing the situation where multiple CCCD writes are made simultaneously and FDS needs to do garbage collection to store their values in the local cache.&lt;/p&gt;
&lt;p&gt;I also note that if I disable the gatt module my peripheral no longer receives BLE_GATTS_EVT_WRITE events - so turning it off seems like a bad idea!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/119015?ContentTypeID=1</link><pubDate>Wed, 31 Jan 2018 12:27:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa936139-9bf9-47c9-852f-3b404f111134</guid><dc:creator>jumpingfool</dc:creator><description>&lt;p&gt;Unfortunately my central is an unpublished iOS app so although I&amp;#39;d be happy to share the project with you I don&amp;#39;t think that&amp;#39;s going to be much help without the app to test with.&lt;/p&gt;
&lt;p&gt;However, I think I may now know what is happening. I do get PM_EVT_FLASH_GARBAGE_COLLECTED and FDS_EVT_GC after the first CCCD write and fds_stat() shows the dirty records have gone at that point. However, I can see three flash writes going out before this happens (as my app requests notification on three CCCDs at connection). My guess is that we have contention here on the flash buffer - the CCCD writes are coming in while the GC process is still in flight and this is somehow screwing up the FDS state and causing problems . Is that plausible?&lt;/p&gt;
&lt;p&gt;Out of interest why is persistent storage for the CCCD state required? Am I doing the right thing by writing to the CCCD each time the app connects to ensure I get notifications or should I be reading the state and only updating if notifications are not already enabled?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/119018?ContentTypeID=1</link><pubDate>Wed, 31 Jan 2018 11:31:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8593184c-2969-4e91-a7b7-6e5ef2d23b9e</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Hmm. I didn&amp;#39;t expect the writes to go away by commenting out gatt_init(). I expected MTU exchange to go away. Which central example are using? Maybe the write is trigger by the MTU exchange or something.&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t want to use the GATT module you should also remove the files from the project, and/or disable the module in sdk_config.h see NRF_BLE_GATT_ENABLED. Implications will be that some events will not be handled anymore, see nrf_ble_gatt_on_ble_evt().&lt;/p&gt;
&lt;p&gt;When you run fds_stat() immediately after calling fds_gc()? That is expected, the GC is not complete until you get PM_EVT_FLASH_GARBAGE_COLLECTED and FDS_EVT_GC. Do you get these events? What do fds_stat() return then?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure why the logging changes anything. Would it be possible to upload your complete projects? And tell me how I can reproduce this? And which logging removes removes the issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/119017?ContentTypeID=1</link><pubDate>Wed, 31 Jan 2018 10:36:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba11c5f0-7fc6-421b-bc24-4da105b4087a</guid><dc:creator>jumpingfool</dc:creator><description>&lt;p&gt;Hi Petter - thanks for your help. Yes I am writing to (several) CCCDs immediately when the connection is established so my central can receive notifications. A few updates.&lt;/p&gt;
&lt;p&gt;First I tried commenting out gatt_init from main as you suggested and this makes the problem go away - the flash writes simply don&amp;#39;t happen anymore. I&amp;#39;m not sure if there are other implications with doing that though?&lt;/p&gt;
&lt;p&gt;Secondly I implemented some logging around the PM_EVT_STORAGE_FULL event. Calling fds_gc() returns zero but the GC does not actually complete - there are still over a hundred dirty pages when I run fds_stat() immediately after. Interestingly I also added some logging to PM_EVT_LOCAL_DB_CACHE_APPLIED so I could see the cache filling up and the problem went away - GC did clear out the dirty records. The delay associated with the extra logging clearly helped so I think this must be a race condition - perhaps the previous flash write is not completing before fds_gc() is executed?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in peer manager in SDK 14.2</title><link>https://devzone.nordicsemi.com/thread/119014?ContentTypeID=1</link><pubDate>Tue, 30 Jan 2018 12:45:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1113f35e-f0f4-41e8-9dfd-0fb76fc96cc3</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;You say GC is attempted? Could you elaborate?&lt;/p&gt;
&lt;p&gt;Do you get the PM_EVT_STORAGE_FULL event in pm_evt_handler()? If you do, do fds_gc() return 0x00000000 (NRF_SUCCESS)? Do you get the PM_EVT_FLASH_GARBAGE_COLLECTED event in pm_evt_handler()? Or the FDS_EVT_GC event in fds_evt_handler()?&lt;/p&gt;
&lt;p&gt;Could you run fds_stat() and see what it returns?&lt;/p&gt;
&lt;p&gt;The ATT MTU request is probably done by the GATT module, I think you can just comment out gatt_init() in main() and this will not happen.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m guessing that the BLE_GATTS_EVT_WRITE is a write to a CCCD? Every time a CCCD is written to, the PM_PEER_DATA_ID_GATT_LOCAL_V2 record will be updated. This means that a new record will be written, and the old should be invalidated. Then when doing GC this invalidated record should be collected.&lt;/p&gt;
&lt;p&gt;Would it be possible for you to upload the complete projects so I can test them here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>