<?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>MPSL Assert 109, 496</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/118190/mpsl-assert-109-496</link><description>I am developing an application based on nRF desktop, SDK 2.9.0. In normal build it works as expected. In release build, which includes MCUMgr/MCUBoot and no logging or asserts (which are the only differences, and which work normally), after ~30m connected</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 18 Feb 2025 16:15:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/118190/mpsl-assert-109-496" /><item><title>RE: MPSL Assert 109, 496</title><link>https://devzone.nordicsemi.com/thread/523578?ContentTypeID=1</link><pubDate>Tue, 18 Feb 2025 16:15:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3251535-9d1e-466f-a9b2-b956656506dd</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;It appears to be a division error caused by&amp;nbsp;CONFIG_SYS_CLOCK_TICKS_PER_SEC being set to &amp;#39;1000&amp;#39; instead of the default &amp;#39;32768&amp;#39; value in this project. Commenting this line in the prj.conf file made the problem go away. I will check with the team why this was added in the first place. Git history shows it has been there from the start.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPSL Assert 109, 496</title><link>https://devzone.nordicsemi.com/thread/521310?ContentTypeID=1</link><pubDate>Tue, 04 Feb 2025 13:09:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b8c7fb7-f8b7-4c76-8fdf-318b240d9c83</guid><dc:creator>nrbrook</dc:creator><description>&lt;p&gt;I can confirm your example works correctly. However, it doesn&amp;#39;t in nRF Desktop. Modify main.c as shown:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
#include &amp;lt;app_event_manager.h&amp;gt;

#define MODULE main
#include &amp;lt;caf/events/module_state_event.h&amp;gt;

#include &amp;lt;zephyr/logging/log.h&amp;gt;
LOG_MODULE_REGISTER(MODULE);

static struct k_work_delayable delay_work;

static void delay_work_handler(struct k_work *work)
{
	int64_t current_time = k_uptime_get();
    {
        int16_t ms = current_time % MSEC_PER_SEC;
        int16_t s = (current_time / MSEC_PER_SEC) % SEC_PER_MIN;
        int16_t m = (current_time / (MSEC_PER_SEC * SEC_PER_MIN)) % MIN_PER_HOUR;
        int16_t h = current_time / (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR);
        LOG_INF(&amp;quot;Current time: %02u:%02u:%02u.%03u&amp;quot;, h, m, s, ms);
    }
}

int main(void)
{
	if (app_event_manager_init()) {
		LOG_ERR(&amp;quot;Application Event Manager not initialized&amp;quot;);
	} else {
		module_set_state(MODULE_STATE_READY);
	}

	int64_t current_time = k_uptime_get();
    {
        int16_t ms = current_time % MSEC_PER_SEC;
        int16_t s = (current_time / MSEC_PER_SEC) % SEC_PER_MIN;
        int16_t m = (current_time / (MSEC_PER_SEC * SEC_PER_MIN)) % MIN_PER_HOUR;
        int16_t h = current_time / (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR);
        LOG_INF(&amp;quot;Current time: %02u:%02u:%02u.%03u&amp;quot;, h, m, s, ms);
    }

	k_work_init_delayable(&amp;amp;delay_work, delay_work_handler);
	k_work_schedule(&amp;amp;delay_work, K_SECONDS(60));

	return 0;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Result:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:00.004,821] &amp;lt;inf&amp;gt; main: Current time: 00:00:00.004
...
[00:00:58.598,693] &amp;lt;inf&amp;gt; main: Current time: 00:01:00.005&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPSL Assert 109, 496</title><link>https://devzone.nordicsemi.com/thread/520714?ContentTypeID=1</link><pubDate>Thu, 30 Jan 2025 13:18:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:245d3996-faed-458a-a9fe-cb4d4cfed6cf</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thank you for the code snippets. Unfortunately, I have not managed to reproduce the issue here. Both are using the kernel&amp;#39;s system clock (RTC) to produce timestamps. Here is the project I used for test:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/4263.timestamp_5F00_test.zip"&gt;devzone.nordicsemi.com/.../4263.timestamp_5F00_test.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Were&amp;nbsp;you able to reproduce this with any of the SDK samples?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPSL Assert 109, 496</title><link>https://devzone.nordicsemi.com/thread/519603?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2025 14:49:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a535030-7a6b-44f5-9fc4-3fc1bcca048b</guid><dc:creator>nrbrook</dc:creator><description>&lt;p&gt;Thanks for your responses.&lt;/p&gt;
&lt;p&gt;To assist reproduction of the timestamp issue, here is the code to print the timestamps:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static struct k_work_delayable power_off_timeout_work;

static void power_off_timeout(struct k_work *work) {
    LOG_WRN(&amp;quot;Power off timeout&amp;quot;);
    int64_t current_time = k_uptime_get();
    {
        int16_t ms = current_time % MSEC_PER_SEC;
        int16_t s = (current_time / MSEC_PER_SEC) % SEC_PER_MIN;
        int16_t m = (current_time / (MSEC_PER_SEC * SEC_PER_MIN)) % MIN_PER_HOUR;
        int16_t h = current_time / (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR);
        LOG_DBG(&amp;quot;Current time: %02u:%02u:%02u.%03u&amp;quot;, h, m, s, ms);
    }
}

static void reschedule_power_off_after(uint32_t delay_s) {
    int64_t current_time = k_uptime_get();
    {
        int16_t ms = current_time % MSEC_PER_SEC;
        int16_t s = (current_time / MSEC_PER_SEC) % SEC_PER_MIN;
        int16_t m = (current_time / (MSEC_PER_SEC * SEC_PER_MIN)) % MIN_PER_HOUR;
        int16_t h = current_time / (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR);
        LOG_DBG(&amp;quot;Current time: %02u:%02u:%02u.%03u&amp;quot;, h, m, s, ms);
    }
    int64_t completed_time = current_time + delay_s * MSEC_PER_SEC;
    int16_t ms = completed_time % MSEC_PER_SEC;
    int16_t s = (completed_time / MSEC_PER_SEC) % SEC_PER_MIN;
    int16_t m = (completed_time / (MSEC_PER_SEC * SEC_PER_MIN)) % MIN_PER_HOUR;
    int16_t h = completed_time / (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR);
    LOG_DBG(&amp;quot;Rescheduling power off timeout in %d seconds at %02u:%02u:%02u.%03u&amp;quot;, delay_s, h, m, s, ms);
    k_work_reschedule(&amp;amp;power_off_timeout_work, K_SECONDS(delay_s));
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPSL Assert 109, 496</title><link>https://devzone.nordicsemi.com/thread/519600?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2025 14:44:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43750be6-b910-434a-bb87-b315296c78d3</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The issue seems to be that LF clock calibration events&amp;nbsp;fails to be&amp;nbsp;configured properly when the bootloader and the application select different LF clock sources (LFXO and LFRC). The MPSL team is looking into this. If you plan to use the RC oscillator, it is best to set it as the default clock source in your board file. That way it will default to the same clock source for other FW images such as bootloader.&lt;/p&gt;
[quote user="nrbrook"]In what cases would I want to enable&amp;nbsp;&amp;quot;CONFIG_SYSTEM_CLOCK_WAIT_FOR_STABILITY&amp;quot;?[/quote]
&lt;p&gt;This is the default option, but I can&amp;#39;t think of a good example where&amp;nbsp;it is strictly required. There are some samples which enables&amp;nbsp;SYSTEM_CLOCK_NO_WAIT to reduce the startup time. MPSL will ensure&amp;nbsp;LFXO is running, or LFRC is calibrated before BLE is started.&lt;/p&gt;
[quote user="nrbrook"]Should I be modifying any other configuration to ensure the RC oscillator does not get out of sync? Existing boards e.g. nRF52DK and nRF52kbd don&amp;#39;t seem to.[/quote]
&lt;p&gt;It should be sufficient to enable CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC. CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION is automatically enabled when&amp;nbsp;the RC osc. is selected.&lt;/p&gt;
[quote user="nrbrook"]How can I ensure the firmware reboots on MPSL assert?[/quote]
&lt;p&gt;CONFIG_RESET_ON_FATAL_ERROR=y&lt;/p&gt;
[quote user="nrbrook"]Possibly also related: delayed work (using k_work_reschedule) seems to be submitted before expected when compared to the log timestamp. This happens even with XTAL. For example:[/quote]
&lt;p&gt;I&amp;#39;m not sure about this. I thought both were using the same system clock. I need to see if I can reproduce this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPSL Assert 109, 496</title><link>https://devzone.nordicsemi.com/thread/519443?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2025 07:05:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dbaf9bb-cc5f-4713-ba29-94a87d7e42bf</guid><dc:creator>nrbrook</dc:creator><description>&lt;p&gt;Yes on this one, but perhaps not on all board designs.&lt;/p&gt;
&lt;p&gt;A few&amp;nbsp;tangential questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In what cases would I want to enable&amp;nbsp;&amp;quot;CONFIG_SYSTEM_CLOCK_WAIT_FOR_STABILITY&amp;quot;?&lt;/li&gt;
&lt;li&gt;Should I be modifying any other configuration to ensure the RC oscillator does not get out of sync? Existing boards e.g. nRF52DK and nRF52kbd don&amp;#39;t seem to.&lt;/li&gt;
&lt;li&gt;How can I ensure the firmware reboots on MPSL assert?&lt;/li&gt;
&lt;li&gt;Possibly also related: delayed work (using k_work_reschedule) seems to be submitted before expected when compared to the log timestamp. This happens even with XTAL. For example:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:06.782,836] &amp;lt;dbg&amp;gt; idle_power_off: reschedule_power_off_after: Current time: 00:00:06.945
[00:00:06.782,867] &amp;lt;dbg&amp;gt; idle_power_off: reschedule_power_off_after: Rescheduling power off timeout in 60 seconds at 00:01:06.945
...
[00:01:05.377,014] &amp;lt;dbg&amp;gt; idle_power_off: power_off_timeout: Current time: 00:01:06.946&lt;/pre&gt;While the current time from k_uptime_get() indicates the delay is correct, the log timestamps do not have the same time difference.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPSL Assert 109, 496</title><link>https://devzone.nordicsemi.com/thread/519441?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2025 06:39:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ec7b278-5dcc-429c-b80d-4a390e8df6d0</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for confirming that it works. We will continue to investigate why it is asserting with the LFRC. Will you use the external crystal in your final design?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPSL Assert 109, 496</title><link>https://devzone.nordicsemi.com/thread/519395?ContentTypeID=1</link><pubDate>Tue, 21 Jan 2025 18:11:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b319cb23-f536-40ee-8b2c-f14e93fc434a</guid><dc:creator>nrbrook</dc:creator><description>&lt;p&gt;It seems to work ok when using the external crystal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPSL Assert 109, 496</title><link>https://devzone.nordicsemi.com/thread/519334?ContentTypeID=1</link><pubDate>Tue, 21 Jan 2025 14:22:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e074d95-0b33-4b22-a926-137a3654f4d0</guid><dc:creator>nrbrook</dc:creator><description>&lt;p&gt;Yes I am using the RC oscillator, because that config was copied from the keyboard. However, the board does actually have an external crystal I could use.&lt;/p&gt;
&lt;p&gt;I have not added bt_disable() and it doesn&amp;#39;t look like it was used by nrf_desktop anywhere.&lt;/p&gt;
&lt;p&gt;Stack trace attached.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot-2025_2D00_01_2D00_21-at-14.22.05.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPSL Assert 109, 496</title><link>https://devzone.nordicsemi.com/thread/519316?ContentTypeID=1</link><pubDate>Tue, 21 Jan 2025 13:37:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c133ef2-51ef-4e36-b348-a22e88d452be</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I don’t think I’ve seen any reports of this exact assertion before. If it’s possible to start a debug session before or after the assertion is raised, could you please&amp;nbsp;post a picture of the call stack? The developers&amp;nbsp;were interested in&amp;nbsp;having a look at the backtrace.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit:&amp;nbsp;&lt;/strong&gt;they were also wondering if you were using bt_disable() in your app and if you are using the internal RC oscillator as your LF clock source.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>