<?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>Scheduler get full by NRF_EVT_RADIO_BLOCKED events during connect.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80616/scheduler-get-full-by-nrf_evt_radio_blocked-events-during-connect</link><description>Using: 
 
 nRF52832 
 SDK 15.3.0 
 SD S132 6.1.1 
 nRF5 SDK for Mesh 3.2.0 
 NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_APPSH 
 
 Hi, I&amp;#39;m often getting a crash when connecting. The back trace showed hints of it happening in the mesh code: timeslot</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Nov 2021 08:51:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80616/scheduler-get-full-by-nrf_evt_radio_blocked-events-during-connect" /><item><title>RE: Scheduler get full by NRF_EVT_RADIO_BLOCKED events during connect.</title><link>https://devzone.nordicsemi.com/thread/340838?ContentTypeID=1</link><pubDate>Fri, 26 Nov 2021 08:51:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60cc037f-4943-45f9-86ab-b4708605cbec</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;So I tested with 3000us, and it seems like that doesn&amp;#39;t result in the loop anymore (I still see plenty of BLOCKED events, but always with 100ms in between, so that&amp;#39;s probably the next advertisement with a full time slot).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler get full by NRF_EVT_RADIO_BLOCKED events during connect.</title><link>https://devzone.nordicsemi.com/thread/337685?ContentTypeID=1</link><pubDate>Fri, 05 Nov 2021 12:30:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c418e5bb-3c2c-45af-b9cd-34fe6a35e5ff</guid><dc:creator>Mttrinh</dc:creator><description>[quote user="bart"]Thanks, I will try the first solution and get back with the results. How is this 3800 us calculated, if i may ask?[/quote]
&lt;p&gt;Great! This was based on specification from our Softdevice team, it stated that the mesh stack could always get at least 4000us, even in a connection. It seems to have changed though.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler get full by NRF_EVT_RADIO_BLOCKED events during connect.</title><link>https://devzone.nordicsemi.com/thread/337235?ContentTypeID=1</link><pubDate>Wed, 03 Nov 2021 10:32:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3c1ac6a-7d06-42a3-a4c5-ec515a068911</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Thanks, I will try the first solution and get back with the results. How is this 3800 us calculated, if i may ask?&lt;/p&gt;
&lt;p&gt;Solution 2 is indeed what I also thought to be a better solution, but I don&amp;#39;t dare to implement this, as it seems quite a big change, with possible side effects.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler get full by NRF_EVT_RADIO_BLOCKED events during connect.</title><link>https://devzone.nordicsemi.com/thread/336715?ContentTypeID=1</link><pubDate>Fri, 29 Oct 2021 14:28:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:553b1efa-d48d-4b40-9c41-d9ab726324ab</guid><dc:creator>Mttrinh</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;From speaking to one of our developer he&lt;span&gt;&amp;nbsp;thinks there are two potential solutions to this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;1. Reduce TIMESLOT_BASE_LENGTH_SHORT_US so it can fit between two connection events of the shortest type. This is the intent of the current functionality, but some condition on the device (configuration, clock drift setting?) is preventing the device from getting this short timeslot. Currently, it&amp;#39;s 3800 us, try changing it to 3000, for instance.&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. Add some backoff mechanism in the BLOCKED event handler. In this handler, we&amp;#39;re currently setting the timeslot request length to TIMESLOT_BASE_LENGTH_SHORT_US before retrying. If we end up here, and the request timeslot length is TIMESLOT_BASE_LENGTH_SHORT_US already, try starting a backoff timer that comes back to request a timeslot later. This could also be implemented as an nrf_mesh_evt_t, but that might still be too tight of a loop.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler get full by NRF_EVT_RADIO_BLOCKED events during connect.</title><link>https://devzone.nordicsemi.com/thread/335732?ContentTypeID=1</link><pubDate>Mon, 25 Oct 2021 12:12:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44bab057-fdb8-4448-bfe0-da0ca38a2022</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Thanks, looking forward to it.&lt;/p&gt;
&lt;p&gt;For now I&amp;#39;m using a work around to at least not crash: &lt;a href="https://github.com/crownstone/bluenet/blob/master/patch/04nrf5.patch"&gt;patch&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When just using that work around, however, we get even more calls to &lt;code&gt;sd_radio_request()&lt;/code&gt;, causing the main thread to be blocked until the connect succeeded.&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;To avoid that, I now also wait for&amp;nbsp;&lt;code&gt;NRF_MESH_EVT_DISABLED&lt;/code&gt; before calling&amp;nbsp;&lt;code&gt;sd_ble_gap_connect()&lt;/code&gt;. This prevents most of the &lt;code&gt;NRF_EVT_RADIO_BLOCKED&lt;/code&gt; loops.&lt;/p&gt;
&lt;p&gt;Handling &lt;code&gt;NRF_EVT_RADIO_SESSION_CLOSED&lt;/code&gt; still takes 4 ms while connecting. And there are still some short&amp;nbsp;&lt;code&gt;NRF_EVT_RADIO_BLOCKED&lt;/code&gt; loops, mostly while connected, but they don&amp;#39;t block the main thread for seconds, still can take up to 15 ms to handle.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler get full by NRF_EVT_RADIO_BLOCKED events during connect.</title><link>https://devzone.nordicsemi.com/thread/335329?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 13:36:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3fd4b904-76ad-484a-8253-4552864e0877</guid><dc:creator>Mttrinh</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This have been sent to our Mesh team to have look at, I will update you once I have a response from them.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler get full by NRF_EVT_RADIO_BLOCKED events during connect.</title><link>https://devzone.nordicsemi.com/thread/334632?ContentTypeID=1</link><pubDate>Mon, 18 Oct 2021 13:15:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d5f9bdb-e47b-485b-8a28-d45ed1fcf18a</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;After some more testing, I found out that it seems like &lt;em&gt;sd_radio_request()&lt;/em&gt; sometimes is a blocking call, which blocks for &lt;em&gt;p_request-&amp;gt;earliest-&amp;gt;timeout_us&lt;/em&gt; micro seconds, when the SD is connecting as central. Or maybe it&amp;#39;s always blocking, and normally returns quickly. After that time, the &lt;em&gt;NRF_EVT_RADIO_BLOCKED&lt;/em&gt; event is triggered, and since the main thread is still in the&amp;nbsp;&lt;em&gt;nrf_sdh_soc_evts_poll()&lt;/em&gt; loop, it will immediately process this event, leading to another &lt;em&gt;sd_radio_request()&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;I do not know how to properly fix this, the cpu shouldn&amp;#39;t be blocked for that long.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler get full by NRF_EVT_RADIO_BLOCKED events during connect.</title><link>https://devzone.nordicsemi.com/thread/334398?ContentTypeID=1</link><pubDate>Fri, 15 Oct 2021 14:20:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca551da7-caa7-4b2e-8d71-63cd248e1168</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;I did some more research, and it&amp;#39;s best reproducible with a connection as central.&lt;/p&gt;
&lt;p&gt;Before making a connection, I stop the mesh with &lt;em&gt;nrf_mesh_disable().&lt;/em&gt; If i don&amp;#39;t stop the mesh, connecting takes very long.&lt;/p&gt;
&lt;p&gt;Most times, the mesh actually stops, and i get events &lt;em&gt;NRF_EVT_RADIO_SESSION_IDLE&lt;/em&gt; and &lt;em&gt;NRF_EVT_RADIO_SESSION_CLOSED&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Sometimes, however, the mesh doesn&amp;#39;t seem to stop, that&amp;#39;s when i get multiple &lt;em&gt;NRF_EVT_RADIO_BLOCKED&lt;/em&gt; events. What&amp;#39;s worse, suddenly the calls to &lt;em&gt;nrf_mesh_on_sd_evt()&lt;/em&gt; with the event&amp;nbsp;&lt;em&gt;NRF_EVT_RADIO_BLOCKED&lt;/em&gt; take &lt;strong&gt;15ms&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Does the softdevice take up all this CPU time? Or can the call &lt;em&gt;sd_radio_request()&lt;/em&gt; take so much time because something in the SD is blocking?&lt;/p&gt;
&lt;p&gt;Is there a better way to stop the mesh? It shouldn&amp;#39;t be making new timeslot requests when i called &lt;em&gt;nrf_mesh_disable()&lt;/em&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler get full by NRF_EVT_RADIO_BLOCKED events during connect.</title><link>https://devzone.nordicsemi.com/thread/334264?ContentTypeID=1</link><pubDate>Fri, 15 Oct 2021 07:21:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28d8d70a-2531-4266-9c60-7aeb954c5cbf</guid><dc:creator>bart</dc:creator><description>&lt;blockquote&gt;
&lt;p&gt;Not sure what you mean by connect? Assuming your application are only running ble mesh, t&lt;span&gt;here is no concept of connections in a mesh network.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Could you provide more information regarding your use-case and what you are trying to do?&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;span&gt;A normal BLE connection with a phone for example, either as peripheral or as central. The mesh is used to communicate between nodes.&lt;/span&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span&gt;Could it be related to &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.meshsdk.v5.0.0/md_doc_user_guide_mesh_interrupt_priorities.html?cp=8_2_2_5" rel="noopener noreferrer" target="_blank"&gt;interrupt priority levels&lt;/a&gt;?&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;span&gt;I followed that guide and run all code at thread level: using &lt;em&gt;NRF_SDH_DISPATCH_MODEL_APPSH&lt;/em&gt;, and init the mesh with &lt;em&gt;NRF_MESH_IRQ_PRIORITY_THREAD&lt;/em&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span&gt;Also, is there a reason you are using an old SDK version? If possible I would suggest you move to our latest SDK(nRF5 for Mesh SDK v5.0.0), as many improvements have been made from v3.2.0 to v.5.0.0.&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;span&gt;I checked &lt;em&gt;timeslot.c&lt;/em&gt; at the 5.0.0 mesh SDK, and that handles the &lt;em&gt;NRF_EVT_RADIO_BLOCKED&lt;/em&gt; event in exactly the same way. I didn&amp;#39;t have any reason to update SDK version yet, and usually a new SDK requires more resources.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not too sure anymore about &lt;em&gt;NRF_EVT_RADIO_BLOCKED&lt;/em&gt; being the source of the problems, I noticed that &lt;em&gt;app_sched_execute()&lt;/em&gt; does finish in between the events.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When inspecting the app scheduler queue on crash, I noticed it&amp;#39;s full of calls to &lt;em&gt;appsh_events_poll().&lt;/em&gt; A function that gets and dispatches all pending events from the SD. Wouldn&amp;#39;t it be a good idea to check whether this call isn&amp;#39;t already queued in the scheduler before putting it in there?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler get full by NRF_EVT_RADIO_BLOCKED events during connect.</title><link>https://devzone.nordicsemi.com/thread/334205?ContentTypeID=1</link><pubDate>Thu, 14 Oct 2021 14:25:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12c5590f-3f3d-4376-ad75-af6a61f35c53</guid><dc:creator>Mttrinh</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]Am I right to assume this timeslot request loop can lead to the scheduler getting filled up (especially when other processes also add to the scheduler)?[/quote]
&lt;p&gt;Yes, I think that can be the case.&lt;/p&gt;
[quote user=""]When logging SOC events, I noticed many NRF_EVT_RADIO_BLOCKED events coming in when a connection is made.[/quote]
&lt;p&gt;Not sure what you mean by connect? Assuming your application are only running ble mesh, t&lt;span&gt;here is no concept of connections in a mesh network.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Could you provide more information regarding your use-case and what you are trying to do?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Could it be related to &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.meshsdk.v5.0.0/md_doc_user_guide_mesh_interrupt_priorities.html?cp=8_2_2_5" rel="noopener noreferrer" target="_blank"&gt;interrupt priority levels&lt;/a&gt;?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Also, is there a reason you are using an old SDK version? If possible I would suggest you move to our latest SDK(nRF5 for Mesh SDK v5.0.0), as many improvements have been made from v3.2.0 to v.5.0.0.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>