<?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>using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34597/using-app-scheduler-does-not-prevent-ble-stack-starvation</link><description>Hello, 
 In our application we heavily use the application scheduler. This was done for 2 main reasons: 
 
 serialize access to system resources 
 enable the soft device to handle higher priority tasks 
 
 It appears that it isn&amp;#39;t sufficient to use the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 29 May 2018 16:06:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34597/using-app-scheduler-does-not-prevent-ble-stack-starvation" /><item><title>RE: using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/thread/133884?ContentTypeID=1</link><pubDate>Tue, 29 May 2018 16:06:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3920cf3-5db2-41dc-a4f7-37104d3e735a</guid><dc:creator>Allen</dc:creator><description>&lt;p&gt;It is set to 0.&lt;/p&gt;
&lt;p&gt;I did try setting it to 1 and increasing the queue size to see if that fix the problem. It did not and seemed to perform worse than the default configuration.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/thread/133883?ContentTypeID=1</link><pubDate>Tue, 29 May 2018 16:01:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4d9fd8b-fd24-4c37-9781-ddea7efd0507</guid><dc:creator>MattyIce</dc:creator><description>&lt;p&gt;&lt;span&gt;What is `&lt;/span&gt;&lt;span&gt;NRF_SDH_DISPATCH_MODEL` set to in your project? My understanding is that if you&amp;#39;ve set this to 1 or 2 (and&amp;nbsp;&lt;/span&gt;&lt;strong&gt;not&lt;/strong&gt;&lt;span&gt;&amp;nbsp;0) then you will encounter priority issues with the soft device.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/thread/133879?ContentTypeID=1</link><pubDate>Tue, 29 May 2018 15:24:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60545eab-acce-45a4-99ac-9ff81412635d</guid><dc:creator>Allen</dc:creator><description>&lt;p&gt;I thought that BLE events were handled in an interrupt context unless the event scheduling method is changed. Is that not true? If so, why would a scheduled event prevent these from being serviced?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/thread/133575?ContentTypeID=1</link><pubDate>Mon, 28 May 2018 07:47:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87f1bb99-1a94-47db-905c-983c7b5d140b</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I agree with you, ideally there should be some priority within app scheduler to ensure some operations (for instance handling BLE events) could be prioritized. Unfortunately that is not the case, so your workaround to use a timer to&amp;nbsp;&amp;quot;spread&amp;quot; the time consuming tasks over time is I believe the best workaround.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/thread/133299?ContentTypeID=1</link><pubDate>Thu, 24 May 2018 16:48:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da642d24-0766-4afe-9790-479e6527f9f7</guid><dc:creator>Allen</dc:creator><description>&lt;p&gt;The whole premise of this issue report is that we should not be blocking BLE for 10 seconds since we are using the app_sched_event_put() to perform the operation in 128 byte chunks.&lt;/p&gt;
&lt;p&gt;We are using a bonded communication scheme so an external sniffer does not work. (we tried that)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/thread/133137?ContentTypeID=1</link><pubDate>Thu, 24 May 2018 07:23:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ff384d8-9750-4d9e-aa64-54144feff6e7</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Is it possible to get a on air sniffer log do you think? Or possible just dump the BLE evt_id to UART, so we may try to find which event that in specific may be the problem here.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The 0x16 error is local host terminated, do&amp;nbsp;you initialize or receive connection update/phy update/ channel map update on the device?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also does this happen on a peripheral or a central?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A quick calculation on your description means you may be blocking BLE events for 64kB/128B*20ms=10seconds. This is a long time, but should work, so I would like to understand which event in specific that may be time critical.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/thread/133095?ContentTypeID=1</link><pubDate>Wed, 23 May 2018 18:42:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb448004-e9d3-42d6-b031-a4ef1b9c7003</guid><dc:creator>Allen</dc:creator><description>&lt;p&gt;Yes, disconnect reason 0x28. 0x16 is also a BLE error code. The last one is probably due to a software error in our code. I could probably get a log file if you are interested.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/thread/133093?ContentTypeID=1</link><pubDate>Wed, 23 May 2018 18:36:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10521056-badc-481e-8a26-a4769605d74a</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Interesting, so you may have several 20ms periods where you are not handling any BLE events in between if I understand you correctly. I will run this by the softdevice team.&lt;/p&gt;
&lt;p&gt;You write: &amp;quot;Usually the connection terminates with a 0x28 error code. Then we get 0x16 after that.&amp;quot;&lt;/p&gt;
&lt;p&gt;I assume that you mean that you get disconnect reason 0x28, but not sure what you mean by 0x16? Is this an error code from a specific softdevice call, or are you getting 2 disconnects?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/thread/133085?ContentTypeID=1</link><pubDate>Wed, 23 May 2018 17:27:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb5412ae-904e-4869-ad41-44a7bffb4422</guid><dc:creator>Allen</dc:creator><description>&lt;p&gt;Here is what we are doing and how it is implemented.&lt;/p&gt;
&lt;p&gt;I am erasing 64KB of eeprom connected to the SPI bus. Each time the erase function is called it erases 128 bytes from the eeprom and then reschedules itself. The eeprom SPI interface is *not* interrupt driven. Each erase operation takes about 20ms.&lt;/p&gt;
&lt;p&gt;I also investigated the interrupt priorities. However we are never doing anything in an interrupt context. So, repeatedly scheduling 20ms non-interrupt operations with no idle time will kill BLE. Adding a timer delay fixes the issue.&lt;/p&gt;
&lt;p&gt;BTW: as another test I changed the SD scheduler configuration to use the application event queue and increased the allocated queue size to 50. If anything, this seemed worse.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/thread/133081?ContentTypeID=1</link><pubDate>Wed, 23 May 2018 16:46:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e701315b-d352-43d4-bcce-9745060ee053</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Sorry, I still do not quite understand how this is possible. If you take a look at the interrupt priorities for the softdevice and application here:&lt;br /&gt;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/processor_avail_interrupt_latency/exception_mgmt_sd.html?cp=2_3_1_0_15_1"&gt;http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/processor_avail_interrupt_latency/exception_mgmt_sd.html?cp=2_3_1_0_15_1&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The only thing I can think of is that you are staying much time in priority 2 and 3, thereby then prevent the softdevice priority 4 from running for several connection intervals. Is that what is happening here?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/thread/133068?ContentTypeID=1</link><pubDate>Wed, 23 May 2018 15:45:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7602d981-13b6-4dd9-99bc-a5295c34c32c</guid><dc:creator>Allen</dc:creator><description>&lt;p&gt;The BLE events are not getting handled. Usually the connection terminates with a 0x28 error code. Then we get 0x16 after that.&lt;/p&gt;
&lt;p&gt;We were able to work around the problem by setting a timer for 12ms that would then queue the event. Initially we tried 10ms but that still failed after awhile.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using app scheduler does not prevent BLE stack starvation</title><link>https://devzone.nordicsemi.com/thread/132980?ContentTypeID=1</link><pubDate>Wed, 23 May 2018 11:59:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d33516d2-f3d3-4734-ab6c-ed239ae2d28f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello, I am under the same impression, can you give an example of what is happening here. Are you saying that the BLE throughput is reduced or that you are not handling BLE events?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>