<?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>(2.6.1 update) lte_lc_connect_async crashes [Illegal use of the EPSR]</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111093/2-6-1-update-lte_lc_connect_async-crashes-illegal-use-of-the-epsr</link><description>Migrating to 2.6.1 we have everything working and the project builds. But as soon as lte_lc_connect_async is called the app now crashes. The Faulting instruction address seems like it might be datetime related? I have tried doubling the main thread stack</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 29 May 2024 14:10:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111093/2-6-1-update-lte_lc_connect_async-crashes-illegal-use-of-the-epsr" /><item><title>RE: (2.6.1 update) lte_lc_connect_async crashes [Illegal use of the EPSR]</title><link>https://devzone.nordicsemi.com/thread/486491?ContentTypeID=1</link><pubDate>Wed, 29 May 2024 14:10:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4317d1a2-542b-4079-8c4a-fa95f0d6573f</guid><dc:creator>CRD</dc:creator><description>&lt;p&gt;It&amp;#39;s possible the ble_enable was keeping that work function running or something. The code was basically this before (when the bug was occurring):&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;
void start_ble_work_fn(struct k_work *work);
K_WORK_DELAYABLE_DEFINE(start_ble_work, start_ble_work_fn);    
    
void start_ble_work_fn(struct k_work *work){    
    ARG_UNUSED(work);
    
    err = bt_enable(NULL);
	if (err) {
		LOG_ERR(&amp;quot;Bluetooth init failed (err %d)\n&amp;quot;, err);
		return err;
	}

	if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
		settings_load();
	}

	ble_interface_evt_handler = event_handler;
	
    if (err) {
    	LOG_ERR(&amp;quot;ble_interface_init, error: %d&amp;quot;, err);
    }else{
    	SEND_EVENT(ble, BLE_EVT_START_ADVERTISING);
    	ble_enabled = true;
    }
}

void main_loop(){
    if (IS_EVENT(msg, app, APP_EVT_START)){
        k_work_schedule(&amp;amp;start_ble_work, K_SECONDS(3));
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;That code worked in SDK 2.5.2 but not after we updated to 2.6.1. It would crash as soon as LTE connected and this was called in lte_lc_helpers.c &amp;quot;curr-&amp;gt;handler(evt);&amp;quot; as shown above in a previous response.&lt;/p&gt;
&lt;p&gt;I was able to fix this by instead making the caller wait 3 seconds before sending an event to start ble. This new delayed event then triggered the &amp;quot;start_ble()&amp;quot; function directly rather than from a k_work_delayable function.&lt;/p&gt;
&lt;p&gt;In the end I removed the delay all together and now send an event when all the relevant modules have been all initialized removing the need for the arbitrary 3 second delay.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: (2.6.1 update) lte_lc_connect_async crashes [Illegal use of the EPSR]</title><link>https://devzone.nordicsemi.com/thread/486480?ContentTypeID=1</link><pubDate>Wed, 29 May 2024 13:46:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4fd79ab-6d76-4e5e-b7c3-949f27518e95</guid><dc:creator>Charlie</dc:creator><description>&lt;p&gt;Hi Colin,&lt;/p&gt;
&lt;p&gt;Thanks for the update. Yes, it is very strange.&lt;/p&gt;
&lt;p&gt;I just wonder, have you done something time-consuming or even blocking in your work&amp;nbsp;task function. Have you used log to check when it is actually finished?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: (2.6.1 update) lte_lc_connect_async crashes [Illegal use of the EPSR]</title><link>https://devzone.nordicsemi.com/thread/486062?ContentTypeID=1</link><pubDate>Mon, 27 May 2024 20:25:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e05e100-7074-4a9e-9214-2851004af909</guid><dc:creator>CRD</dc:creator><description>&lt;p&gt;I have finally resolved this but I don&amp;#39;t fully understand what was wrong. I will put my best guess here in case anyone else finds this and has a similar issue.&lt;br /&gt;&lt;br /&gt;My device also runs BLE. When the device boots up it reads the stored BLE name from persistent memory and triggers an event to let the BLE module know it can start advertising. However, the function in my ble module that receives this event uses a k_work_schedule with a 3 second delay.&lt;/p&gt;
&lt;p&gt;Even though the BLE starts way before (30 seconds) the LTE connection attempt and this delayable should be long gone it was somehow leading to the ESPR issue. If I remove the k_work_schedule for starting BLE everything works normally now. I have now reworked the code to make sure everything is initialized instead of using the arbitrary 3 second delay which has allowed me to remove the k_work_schedule and resolved the issues.&lt;br /&gt;&lt;br /&gt;I find it very strange that this code would have impacted anything (especially an unrelated call happening 30 seconds later on a different thread). It&amp;#39;s almost like there was a memory leak or corruption from the k_work_schedule. Very confusing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: (2.6.1 update) lte_lc_connect_async crashes [Illegal use of the EPSR]</title><link>https://devzone.nordicsemi.com/thread/485441?ContentTypeID=1</link><pubDate>Wed, 22 May 2024 13:43:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2cc8d97-ca16-4fcd-8812-c5b4f089b231</guid><dc:creator>Charlie</dc:creator><description>&lt;p&gt;Hi Colin,&lt;/p&gt;
&lt;p&gt;Ok, it seems the cause is from the nRF library, but I feel not confident when you start to modify the library codes.&lt;/p&gt;
&lt;p&gt;Have you ported the UDP sample to your custom board to have a try? Or test your minimal codes that can repeat this issue on a nRF9160DK?&lt;/p&gt;
&lt;p&gt;These tests will help to identify if it is the hardware to make the difference.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: (2.6.1 update) lte_lc_connect_async crashes [Illegal use of the EPSR]</title><link>https://devzone.nordicsemi.com/thread/484781?ContentTypeID=1</link><pubDate>Thu, 16 May 2024 20:07:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc328f32-f8c9-4723-bb6a-db4924d591b3</guid><dc:creator>CRD</dc:creator><description>&lt;p&gt;To add to this: with those lines commented out I get good LTE connections now but I no longer get the datetime updated after connecting to LTE which was one of my original hunches as a potential cause of the fault messages. So some event sent by that macro for datetime updates is leading to the kernel crash.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: (2.6.1 update) lte_lc_connect_async crashes [Illegal use of the EPSR]</title><link>https://devzone.nordicsemi.com/thread/484742?ContentTypeID=1</link><pubDate>Thu, 16 May 2024 14:43:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88cf2bf6-1f42-406f-9af6-af4ef10ff264</guid><dc:creator>CRD</dc:creator><description>&lt;p&gt;I finally made some big progress. I used the amr-zephyr-eabi-addr2line.exe program to work back the fault. I finally got this:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;arm-zephyr-eabi-addr2line.exe -e ./build/debug/zephyr/zephyr.elf -a 0x00025ab7
0x00025ab7
C:/ncs/v2.6.1/nrf/lib/lte_link_control/lte_lc_helpers.c:124 (discriminator 343)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If I comment out the SYS_SLIST_FOR_EACH_CONTAINER_SAFE macro (see below) in the function &amp;quot;event_handler_list_dispatch&amp;quot; the app now connects to lte and works normally. As far as I can tell this seems to be unchanged from SDK 2.5.1 so I don&amp;#39;t see how its now causing a problem... something deeper in fails with slist peek_next().&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;void event_handler_list_dispatch(const struct lte_lc_evt *const evt)
{
	struct event_handler *curr, *tmp;

	if (event_handler_list_is_empty()) {
		return;
	}

	k_mutex_lock(&amp;amp;list_mtx, K_FOREVER);

	/* Dispatch events to all registered handlers */
	LOG_DBG(&amp;quot;Dispatching event: type=%d&amp;quot;, evt-&amp;gt;type);
	// SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&amp;amp;handler_list, curr, tmp, node) {
	// 	LOG_DBG(&amp;quot; - handler=0x%08X&amp;quot;, (uint32_t)curr-&amp;gt;handler);
	// 	curr-&amp;gt;handler(evt);
	// }
	LOG_DBG(&amp;quot;Done&amp;quot;);

	k_mutex_unlock(&amp;amp;list_mtx);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: (2.6.1 update) lte_lc_connect_async crashes [Illegal use of the EPSR]</title><link>https://devzone.nordicsemi.com/thread/484740?ContentTypeID=1</link><pubDate>Thu, 16 May 2024 14:32:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afc03164-4316-4f8f-aed3-1c9d20bc6492</guid><dc:creator>Charlie</dc:creator><description>&lt;p&gt;Hi Colin,&lt;/p&gt;
&lt;p&gt;Ok, have you tried to run lte connection actions in a standalone thread? but I think it is not necessary.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Our&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.6.1/nrf/samples/cellular/udp/README.html"&gt;Cellular: UDP — nRF Connect SDK 2.6.1 documentation (nordicsemi.com)&lt;/a&gt;&amp;nbsp;sample shows simple usage of&amp;nbsp;lte_lc_connect_async and it is not multi-threads application, could you read through its source codes to get some hint?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: (2.6.1 update) lte_lc_connect_async crashes [Illegal use of the EPSR]</title><link>https://devzone.nordicsemi.com/thread/483356?ContentTypeID=1</link><pubDate>Tue, 14 May 2024 19:51:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c86b608b-21b2-4f65-bbec-61338768852e</guid><dc:creator>CRD</dc:creator><description>&lt;p&gt;Okay I have found out more. (my app is based off the aws asset tracked v2 project btw).&lt;/p&gt;
&lt;p&gt;When I was connecting previously it was after a delay. So:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;main.c was calling &lt;em&gt;&lt;strong&gt;nrf_modem_lib_init() &lt;/strong&gt;&lt;/em&gt;on bootup&lt;/li&gt;
&lt;li&gt;After 30 seconds the modem module thread would call &lt;strong&gt;lte_lc_connect_async&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;This crashes immediately after changing the CFUN to 1&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;During my testing I modified the code (I tried running them from the same thread, from main etc etc..) but at some point I ran the lte_lc_connect_async() at bootup time immediately after initializing the modem. This connects to the network..... but then crashes after about 30 seconds the same way.&lt;/p&gt;
&lt;p&gt;I have tried recreating this issue in the lte_ble_gateway sample, and even copied all my modem module code into it but strangely it works without any issues in that case... This sample isn&amp;#39;t running multiple module threads so maybe that is part of the issue?&lt;/p&gt;
&lt;p&gt;I added the AT_HOST_LIBRARY=y so I could log out the AT commands that are being sent during connection and before the crash through the RTT logs:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;LTE CONNECTING....
%CESQ: 34,1,0,0
modem_rsrp_handler: Incoming RSRP status message, RSRP value is -106
+CEREG: 0
lte_evt_handler: LTE cell changed: Cell ID: -1, Tracking area: -1
+CEREG: 2,&amp;quot;&amp;lt;hidden&amp;gt;&amp;quot;,&amp;quot;&amp;lt;hidden&amp;gt;&amp;quot;,7
lte_evt_handler: PSM parameter update: TAU: 2, Active time: 0
lte_evt_handler: LTE cell changed: Cell ID: &amp;lt;hidden&amp;gt;, Tracking area: &amp;lt;hidden&amp;gt;
+CSCON: 1
lte_evt_handler: RRC mode: Connected
%CESQ: 41,2,4,0
modem_rsrp_handler: Incoming RSRP status message, RSRP value is -99
+CGEV: ME PDN ACT 0,0
modem: PDN LTE CONNECTED
+CNEC_ESM: 50,0
pdn_event_handler: Event: PDP context 0, PDN type IPv4 only allowed
%MDMEV: SEARCH STATUS 2
+CEREG: 5,&amp;quot;&amp;lt;hidden&amp;gt;&amp;quot;,&amp;quot;&amp;lt;hidden&amp;gt;&amp;quot;,7,,,&amp;quot;00001010&amp;quot;,&amp;quot;11000001&amp;quot;
lte_evt_handler: Network registration status: Connected - roaming
lte_evt_handler: PSM parameter update: TAU: 1152000, Active time: 20
%XTIME: ,&amp;quot;42504191339469&amp;quot;,&amp;quot;01&amp;quot;

(About 10 seconds pass)

%CESQ: 255,0,255,0
+CSCON: 0
[00:00:27.201,293] &amp;lt;err&amp;gt; os: ***** USAGE FAULT *****
[00:00:27.201,324] &amp;lt;err&amp;gt; os:   Illegal use of the EPSR
[00:00:27.201,354] &amp;lt;err&amp;gt; os: r0/a1:  0x20020ff8  r1/a2:  0x20013aa8  r2/a3:  0x20013aa8
[00:00:27.201,354] &amp;lt;err&amp;gt; os: r3/a4:  0x0002b000 r12/ip:  0x0ccccccc r14/lr:  0x00029c07
[00:00:27.201,385] &amp;lt;err&amp;gt; os:  xpsr:  0x60000000
[00:00:27.201,385] &amp;lt;err&amp;gt; os: s[ 0]:  0x00000003  s[ 1]:  0x2001cb08  s[ 2]:  0x2001cb04  s[ 3]:  0x00029317
[00:00:27.201,416] &amp;lt;err&amp;gt; os: s[ 4]:  0x00000003  s[ 5]:  0x00000000  s[ 6]:  0x00000000  s[ 7]:  0x00000000
[00:00:27.201,446] &amp;lt;err&amp;gt; os: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
[00:00:27.201,477] &amp;lt;err&amp;gt; os: s[12]:  0x00000000  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x00000000
[00:00:27.201,477] &amp;lt;err&amp;gt; os: fpscr:  0x00000000
[00:00:27.201,507] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x0002b000
[00:00:27.201,538] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 35: Unknown error on CPU 0
[00:00:27.201,599] &amp;lt;err&amp;gt; os: Current thread: 0x20013aa8 (sysworkq)
[00:00:27.733,703] &amp;lt;err&amp;gt; fatal_error: Resetting system&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: (2.6.1 update) lte_lc_connect_async crashes [Illegal use of the EPSR]</title><link>https://devzone.nordicsemi.com/thread/483235?ContentTypeID=1</link><pubDate>Tue, 14 May 2024 11:27:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4079f7e7-657a-44d9-977e-96280358fdbb</guid><dc:creator>Charlie</dc:creator><description>&lt;p&gt;Hi Colin,&lt;/p&gt;
&lt;p&gt;Good to see so much useful information.&lt;/p&gt;
[quote user="CRD"] I was able to load the lte_ble_gateway sample on the same device (built with 2.6.1 and it works fine) + some other info below.[/quote]
&lt;p&gt;Do you mean the same issue works fine with NCSv2.6.1 lte_ble_gateway sample on your custom device?&lt;/p&gt;
&lt;p&gt;The codes you shared are related to your custom codes?&lt;/p&gt;
[quote user="CRD"]If I leave just err = nrf_modem_at_printf(cscon); and don&amp;#39;t check the error it seems to run stable...[/quote]
&lt;p&gt;This also sounds very weird to me. Could you repeat this issue with your codes on a nRF9160DK? Just share a minimal part of your codes that can repeat this issue if you can.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: (2.6.1 update) lte_lc_connect_async crashes [Illegal use of the EPSR]</title><link>https://devzone.nordicsemi.com/thread/483130?ContentTypeID=1</link><pubDate>Mon, 13 May 2024 20:11:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:475a512d-37ba-4b78-81fc-96f8043666d6</guid><dc:creator>CRD</dc:creator><description>&lt;p&gt;Hi Charlie, &lt;br /&gt;&lt;br /&gt;I did a bunch of testing today. We are using MFW1.3.4 but it doesn&amp;#39;t seem to be related to this. I was able to load the lte_ble_gateway sample on the same device (built with 2.6.1 and it works fine) + some other info below.&lt;/p&gt;
&lt;p&gt;I was able to trace the error to this line:&lt;br /&gt;&lt;br /&gt;lte_lc.c (line 546)&lt;br /&gt;&lt;strong&gt;SDK v2.6.1&lt;/strong&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* +CSCON notifications */
err = nrf_modem_at_printf(cscon);
if (err) {
	LOG_WRN(&amp;quot;Failed to enable RRC notifications (+CSCON), error %d&amp;quot;, err);
	return -EFAULT;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;SDK v2.5.1&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* +CSCON notifications */
err = nrf_modem_at_printf(cscon);
if (err) {
	char buf[50];

	/* AT+CSCON is supported from modem firmware v1.1.0, and will
	 * not work for older versions. If the command fails, RRC
	 * mode change notifications will not be received. This is not
	 * considered a critical error, and the error code is therefore
	 * not returned, while informative log messages are printed.
	 */
	LOG_WRN(&amp;quot;AT+CSCON failed (%d), RRC notifications are not enabled&amp;quot;, err);
	LOG_WRN(&amp;quot;AT+CSCON is supported in nRF9160 modem &amp;gt;= v1.1.0&amp;quot;);

	err = nrf_modem_at_cmd(buf, sizeof(buf), &amp;quot;AT+CGMR&amp;quot;);
	if (err == 0) {
		char *end = strstr(buf, &amp;quot;\r\nOK&amp;quot;);

		if (end) {
			*end = &amp;#39;\0&amp;#39;;
		}

		LOG_WRN(&amp;quot;Current modem firmware version: %s&amp;quot;, buf);
	}
}

return 0;&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If I comment that command it seems to connect and run stable. But there is still some strange behaviour I can&amp;#39;t quite figure out. It almost seems like the LOG_WRN calls are leading to the crash? But as far as I know it is not returning an error so those shouldn&amp;#39;t even be called. &lt;br /&gt;&lt;br /&gt;If I leave just err = nrf_modem_at_printf(cscon); and don&amp;#39;t check the error it seems to run stable...&lt;br /&gt;&lt;br /&gt;Very confusing but hopefully on the right track.&lt;br /&gt;&lt;br /&gt;I also tried sending AT+CSCON=1 command manually and it returned OK and didn&amp;#39;t crash the app.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: (2.6.1 update) lte_lc_connect_async crashes [Illegal use of the EPSR]</title><link>https://devzone.nordicsemi.com/thread/483051?ContentTypeID=1</link><pubDate>Mon, 13 May 2024 12:50:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25100d62-c820-49e1-b5f9-37aaeb268f91</guid><dc:creator>Charlie</dc:creator><description>&lt;p&gt;Hi Colin,&lt;/p&gt;
&lt;p&gt;May I know which NCS version your previous codes are based on?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you also updated to the latest modem firmware(MFW1.3.6 for nRF9160 at current time)?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>