<?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>NCS Update to v2.5.2: MPSL Hard Fault on Advertisement</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/109834/ncs-update-to-v2-5-2-mpsl-hard-fault-on-advertisement</link><description>Hello, 
 I&amp;#39;m not a big fan of updating the NRF Connect SDK, because experience has shown that every time so many things have been changed that I am always busy for at least a whole day until my application is compatible again. Accordingly, we always wait</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 08 Apr 2024 12:30:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/109834/ncs-update-to-v2-5-2-mpsl-hard-fault-on-advertisement" /><item><title>RE: NCS Update to v2.5.2: MPSL Hard Fault on Advertisement</title><link>https://devzone.nordicsemi.com/thread/477562?ContentTypeID=1</link><pubDate>Mon, 08 Apr 2024 12:30:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9df32523-b861-4b4b-96cf-1195ae58d3a9</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for sharing the details of your investigation and findings. I is good to know you solved it. (And to find that it was not due to a bug in the MPSL).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Update to v2.5.2: MPSL Hard Fault on Advertisement</title><link>https://devzone.nordicsemi.com/thread/477460?ContentTypeID=1</link><pubDate>Mon, 08 Apr 2024 07:06:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b2e36af-f87d-47a9-b370-6f4c52bd8b38</guid><dc:creator>Talisca</dc:creator><description>&lt;p&gt;First of all, thanks for the tip with CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_PERIOD. &lt;br /&gt;This actually reduced the time from approx. 34 minutes to approx. 2 minutes.&lt;/p&gt;
&lt;p&gt;I then started to systematically remove individual systems from our application.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s embarrassing, but I found the error in our codebase.&lt;/p&gt;
&lt;p&gt;From NCS v2.4 to v2.5, something also changed with the SPI drivers. &lt;br /&gt;I have to mention that we are not using Zephyr&amp;#39;s drivers, because the overhead and the event notification is not sufficient and fast enough for our time-critical application.&lt;br /&gt;Therefore, we directly use the nrfx drivers for SPI.&lt;/p&gt;
&lt;p&gt;Originally we had the following code for our initialization (snippet):&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;IRQ_DIRECT_CONNECT(SPI0_TWI0_IRQn, 0, nrfx_spis_0_irq_handler, 0);
irq_enable(SPI0_TWI0_IRQn);

spi_instance = NRFX_SPIS_INSTANCE(0);
nrfx_spis_config_t spi_config =
NRFX_SPIS_DEFAULT_CONFIG(spi_pins.sck, spi_pins.mosi, spi_pins.miso, spi_pins.csn);
spi_config.orc = 0x99u;
spi_config.def = 0x66u;
spi_config.mode = NRF_SPIS_MODE_3;
spi_config.bit_order = NRF_SPIS_BIT_ORDER_MSB_FIRST;
spi_config.miso_drive = NRF_GPIO_PIN_H0H1;

nrfx_err_t spi_err = nrfx_spis_init(&amp;amp;spi_instance, &amp;amp;spi_config, spi0_event, NULL);
if(spi_err != NRFX_SUCCESS)
{
BT_LOG_ERR(&amp;quot;got spi error: %8x\n&amp;quot;, spi_err);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Apparently something has changed in the declaration of the interrupt handler, which is why we have replaced the first line with:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;IRQ_DIRECT_CONNECT(SPI0_TWI0_IRQn, 0, NRFX_SPIS_INST_HANDLER_GET(0), 0);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;However, with NCS v2.5.2 we always received the following spi error during initialization:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;err&amp;gt; service: got spi error:  bad0005&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Which indicates an invalid state of my SPI instance. &lt;br /&gt;It seems that the SPI slave has now been pre-initialized by Zephyr or whatever - I don&amp;#39;t know.&lt;/p&gt;
&lt;p&gt;Therefore we added a call to nrfx_spis_uninit so that our code looked like this:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;IRQ_DIRECT_CONNECT(SPI0_TWI0_IRQn, 0, NRFX_SPIS_INST_HANDLER_GET(0), 0);
irq_enable(SPI0_TWI0_IRQn);

nrfx_spis_uninit(&amp;amp;spi_instance);

spi_instance = NRFX_SPIS_INSTANCE(0);

...

nrfx_err_t spi_err = nrfx_spis_init(&amp;amp;spi_instance, &amp;amp;spi_config, spi0_event, NULL);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You will notice an error there, just as I did when removing the code parts, that nrfx_spis_uninit is called with an uninitialized instance.&lt;/p&gt;
&lt;p&gt;My guess is that since we are using SPI0 as a slave, it is resetting the state of the correct instance, as the spi error then no longer occurs. Probably only other configurations are somewhat malformed.&lt;/p&gt;
&lt;p&gt;After fixing the sequence, the MPSL Hard Fault no longer occurs.&lt;/p&gt;
&lt;p&gt;It is nevertheless funny that none of our team noticed this error and SPI still simply worked.&lt;br /&gt;It is also interesting that SPI was only initialized during the tests but never used and yet the error always occurred in combination with the advertisement.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Update to v2.5.2: MPSL Hard Fault on Advertisement</title><link>https://devzone.nordicsemi.com/thread/477098?ContentTypeID=1</link><pubDate>Thu, 04 Apr 2024 12:17:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe4c8fc3-4163-4950-90af-a43d1afde3e8</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Just a short follow-up from me while waiting for your input. We have reproduced the same assert in a simple application that just starts advertising, and then calls&amp;nbsp;&lt;code&gt;NVIC_DisableIRQ(POWER_CLOCK_IRQn)&lt;/code&gt;. Our theory is that somethign similar to this happens in your application. (Maybe not exactly that Clock interrupt is disabled in NVIC, but something else that makes clock interrupt not get to the MPSL interrupt handler).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Update to v2.5.2: MPSL Hard Fault on Advertisement</title><link>https://devzone.nordicsemi.com/thread/476917?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 13:48:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bca39eb1-8ecb-43bd-8931-616d475bf672</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you. We are looking forward to hopefully getting code from you that reproduce it. In the mean time, we have some additional questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Can you try to change&amp;nbsp;CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_PERIOD to 250 (from the default 4000) and see if the issue happens quicker then?&lt;/li&gt;
&lt;li&gt;Can you conect with a debugger once the assert has happened, and use &amp;quot;west attach&amp;quot; then &amp;quot;run bt&amp;quot; and upload the resulting back trace here?&lt;/li&gt;
&lt;li&gt;Is the application touching the POWR_CLOCK peripheral in any way, or modifiing the&lt;br /&gt;POWER_CLOCK_IRQn in NVIC?&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Update to v2.5.2: MPSL Hard Fault on Advertisement</title><link>https://devzone.nordicsemi.com/thread/476827?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 10:49:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f475497a-9b66-4e48-81f9-299e91873ee9</guid><dc:creator>Talisca</dc:creator><description>[quote userid="7377" url="~/f/nordic-q-a/109834/ncs-update-to-v2-5-2-mpsl-hard-fault-on-advertisement/476656"]Do you use a 32.768 kHz crystal or the LFRC as low frequency clock source?[/quote]
&lt;p&gt;We use the internal RC as LFCLK.&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/109834/ncs-update-to-v2-5-2-mpsl-hard-fault-on-advertisement/476656"]Is a connection established at any point, or is the device only starting and stopping advertising when this happens?[/quote]
&lt;p&gt;No connections are established during these tests. We only use the nRF Connect app for android to check which advertisement data is sent from the device.&lt;br /&gt;The advertisement itself works fine until the device crashes after approx. 34 minutes.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/109834/ncs-update-to-v2-5-2-mpsl-hard-fault-on-advertisement/476656"]Do you by any chance use the mpsl_clock API, for instance by calling&amp;nbsp;&lt;code&gt;mpsl_clock_hfclk_request()&lt;/code&gt; and/or&amp;nbsp;&lt;code&gt;mpsl_clock_hfclk_release()&lt;/code&gt;?[/quote]
&lt;p&gt;We don&amp;#39;t use any functionalities of the MPSL library, but this does not necessarily mean that none of the used interfaces may use them after all. We do not know that.&lt;br /&gt;&lt;br /&gt;Among other things we use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SPI Slave&lt;/li&gt;
&lt;li&gt;UART&lt;/li&gt;
&lt;li&gt;RTC&lt;/li&gt;
&lt;li&gt;TIMER&lt;/li&gt;
&lt;li&gt;External Flash via QSPI&lt;/li&gt;
&lt;li&gt;Nordic UART Service (NUS)&lt;/li&gt;
&lt;li&gt;Bootloader Chain&lt;/li&gt;
&lt;li&gt;etc&lt;/li&gt;
&lt;/ul&gt;
[quote userid="7377" url="~/f/nordic-q-a/109834/ncs-update-to-v2-5-2-mpsl-hard-fault-on-advertisement/476656"]Is it possible for you to share code that reproduce this that we can test on our end?[/quote]
&lt;p&gt;I will try to reproduce the error in a minimal project. You can imagine that this is not so easy, as I only know whether the problem exists after about 34 minutes.&lt;/p&gt;
&lt;p&gt;I am also busy with other tasks, so it may well take until the end of next week.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS Update to v2.5.2: MPSL Hard Fault on Advertisement</title><link>https://devzone.nordicsemi.com/thread/476656?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 14:53:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30be83e7-7c4a-41e5-833a-05ed8968f33b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;We have started to look into this and have some questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Do you use a 32.768 kHz crystal or the LFRC as low frequency clock source?&lt;/li&gt;
&lt;li&gt;Is a connection established at any point, or is the device only starting and stopping advertising when this happens?&lt;/li&gt;
&lt;li&gt;Do you by any chance use the mpsl_clock API, for instance by calling&amp;nbsp;&lt;code&gt;mpsl_clock_hfclk_request()&lt;/code&gt; and/or&amp;nbsp;&lt;code&gt;mpsl_clock_hfclk_release()&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;Is it possible for you to share code that reproduce this that we can test on our end?&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>