<?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>Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102139/restart-after-system-off-if-the-sensor-driver-is-not-suspended-zephyr-os</link><description>Hello, 
 
 I&amp;#39;m working with LIS3DH sensor and I want to wakeup nRF52832 from system off by an interrupt from the sensor (not added the interrupt configuration yet). I&amp;#39;m using Zephyr OS v3.1.99 on a nRF52 DK, and I&amp;#39;ve merged two examples : nRF5x System</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 27 Oct 2023 20:24:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102139/restart-after-system-off-if-the-sensor-driver-is-not-suspended-zephyr-os" /><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/452857?ContentTypeID=1</link><pubDate>Fri, 27 Oct 2023 20:24:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f34dcb7-f64c-4954-a9ea-49b209fc11c0</guid><dc:creator>Hossein Kasaei</dc:creator><description>&lt;p&gt;After a long time I found out that this phenomena only occurs for the LIS2DH driver, may be a bug or something. I rather to suspend the driver before entering system off.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/438920?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2023 08:35:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd653f12-b0eb-4616-8def-4a431f4fce0e</guid><dc:creator>Vidar Berg</dc:creator><description>[quote user="Hossein Kasaei"]The point is, before the sensor error log, there is a i2c_nrfx_twi error, maybe i2c driver is suspended earlier than the sensor driver, which causes i2c read error.[/quote]
&lt;p&gt;Could you please place a breakpoint at the PM_DEVICE_ACTION suspend function in these locations:&lt;/p&gt;
&lt;p&gt;1. &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/2331b76b9b463377f3fc6f6ac08f8f5e6a32bccc/drivers/sensor/lis2dh/lis2dh.c#L451"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/2331b76b9b463377f3fc6f6ac08f8f5e6a32bccc/drivers/sensor/lis2dh/lis2dh.c#L451&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2. &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/2331b76b9b463377f3fc6f6ac08f8f5e6a32bccc/drivers/i2c/i2c_nrfx_twim.c#L342"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/2331b76b9b463377f3fc6f6ac08f8f5e6a32bccc/drivers/i2c/i2c_nrfx_twim.c#L342&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Or, if you use TWI, at: &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/2331b76b9b463377f3fc6f6ac08f8f5e6a32bccc/drivers/i2c/i2c_nrfx_twi.c#L249"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/2331b76b9b463377f3fc6f6ac08f8f5e6a32bccc/drivers/i2c/i2c_nrfx_twi.c#L249&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This way, we can determine which function is being called first.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/438788?ContentTypeID=1</link><pubDate>Fri, 28 Jul 2023 14:35:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5cd24cdd-793e-4641-90aa-6ccb27b0b59f</guid><dc:creator>Hossein Kasaei</dc:creator><description>&lt;p&gt;Yes as you can see I&amp;#39;m reading sensor values once before entering the deep sleep and the readings are fine :&amp;nbsp;&lt;br /&gt;&lt;br /&gt;*** Booting Zephyr OS build v3.1.99-ncs1 ***&lt;br /&gt;Polling at 0.5 Hz&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#008000;"&gt;#1 @ 397 ms: x -0.612864 , y -0.153216 , z 9.959040&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;Going to sleep after 3 sec...&lt;br /&gt;[00:00:00.390,533] &amp;lt;inf&amp;gt; lis2dh: fs=2, odr=0x1 lp_en=0x8 scale=9576&lt;br /&gt;Deep Sleep Starts now&lt;br /&gt;[00:00:03.406,951] &amp;lt;err&amp;gt; i2c_nrfx_twi: Error on I2C line occurred for message 0&lt;br /&gt;[00:00:03.407,012] &amp;lt;err&amp;gt; lis2dh: failed to read reg_crtl1&lt;br /&gt;[00:00:03.407,043] &amp;lt;err&amp;gt; pm: Device lis3dh@19 did not enter suspended state (-5)&lt;br /&gt;&lt;br /&gt;The point is, before the sensor error log, there is a i2c_nrfx_twi error, maybe i2c driver is suspended earlier than the sensor driver, which causes i2c read error.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/438735?ContentTypeID=1</link><pubDate>Fri, 28 Jul 2023 11:41:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9171eda8-581c-4e73-b80e-a0b7f4b6d65d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Have you verified that you are able to read values from the sensor before entering System OFF? If you look at the SUSPEND action in the driver (&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/2331b76b9b463377f3fc6f6ac08f8f5e6a32bccc/drivers/sensor/lis2dh/lis2dh.c#L451"&gt;link&lt;/a&gt;), you can see it tries to read some register from the sensor before putting it to sleep. So I&amp;#39;m wondering if the communication has been working at all.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/438582?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2023 15:05:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b408a7a-d91a-4c0f-9d96-f613a561f6d2</guid><dc:creator>Hossein Kasaei</dc:creator><description>&lt;p&gt;I increased the stack size and I&amp;#39;m facing these errors :&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="powershell"&gt;*** Booting Zephyr OS build v3.1.99-ncs1  ***
Polling at 0.5 Hz
#1 @ 266 ms: x -0.612864 , y 0.612864 , z 10.571904
Going to sleep after 3 sec...
[00:00:00.259,094] &amp;lt;inf&amp;gt; lis2dh: fs=2, odr=0x1 lp_en=0x8 scale=9576
Deep Sleep Starts now
[00:00:03.275,512] &amp;lt;err&amp;gt; i2c_nrfx_twi: Error on I2C line occurred for message 0
[00:00:03.275,543] &amp;lt;err&amp;gt; lis2dh: failed to read reg_crtl1
[00:00:03.275,573] &amp;lt;err&amp;gt; pm: Device lis3dh@19 did not enter suspended state (-5)
*** Booting Zephyr OS build v3.1.99-ncs1  ***
Polling at 0.5 Hz
#1 @ 401 ms: x -0.766080 , y -0.153216 , z 9.499392
Going to sleep after 3 sec...&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;which is I think something related to the sensor driver, it might be running some code in the background in a thread, cause when I run k_sleep in the main thread, it logs :&amp;nbsp;&lt;br /&gt;[00:00:00.259,094] &amp;lt;inf&amp;gt; lis2dh: fs=2, odr=0x1 lp_en=0x8 scale=9576&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;and after 3 seconds it might be still running, so putting device into deep sleep interrupt it&amp;#39;s operation and the i2c and sensor driver face errors which indicate that it is better to suspend the driver (which suspend it&amp;#39;s thread) so it won&amp;#39;t face any error.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/438565?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2023 14:20:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e861c1b9-5432-4045-993c-9b9648cb0918</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure why you get a stack overflow in the&amp;nbsp;&amp;#39;idle&amp;#39; thread. Either way, please try to increase the stack size for this thread by adding&amp;nbsp;CONFIG_IDLE_STACK_SIZE=&amp;lt;new stack size&amp;gt; to your prj.conf and see if it helps. The default is 320 bytes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/438559?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2023 14:13:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bad973f0-1389-4d9c-9aa9-cf5777d483ce</guid><dc:creator>Hossein Kasaei</dc:creator><description>&lt;p&gt;after enabling mentioned config this is the new log :&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:03.275,482] &amp;lt;err&amp;gt; os: ***** MPU FAULT *****
[00:00:03.275,512] &amp;lt;err&amp;gt; os: Stacking error (context area might be not valid)
[00:00:03.275,512] &amp;lt;err&amp;gt; os: Data Access Violation
[00:00:03.275,512] &amp;lt;err&amp;gt; os: MMFAR Address: 0x20001678
[00:00:03.275,543] &amp;lt;err&amp;gt; os: r0/a1: 0x088324ff r1/a2: 0x4eb7b419 r2/a3: 0xdc5f7d29
[00:00:03.275,573] &amp;lt;err&amp;gt; os: r3/a4: 0x49e0b6dc r12/ip: 0xe53dc749 r14/lr: 0x2b23e114
[00:00:03.275,573] &amp;lt;err&amp;gt; os: xpsr: 0xafd52000
[00:00:03.275,573] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x5db9d8f3
[00:00:03.275,604] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
[00:00:03.275,634] &amp;lt;err&amp;gt; os: Current thread: 0x20000658 (idle)
[00:00:04.461,700] &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: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/438480?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2023 10:16:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:677bcd09-55e9-4a6b-a846-c69de9516f2d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The crashlog indicates that you had a stack overflow in one of your threads. Please add&amp;nbsp;CONFIG_DEBUG_THREAD_INFO=y to your prj.conf to get the name of the thread.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/438469?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2023 09:25:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdd647a1-bd12-43c2-a43b-4af6c05aab8f</guid><dc:creator>Hossein Kasaei</dc:creator><description>&lt;p&gt;I turned on the log and I&amp;#39;m getting these errors :&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="powershell"&gt;*** Booting Zephyr OS build v3.1.99-ncs1 ***
Polling at 0.5 Hz
#1 @ 266 ms: x -0.153216 , y -0.153216 , z 9.805824
Going to sleep after 3 sec...
[00:00:00.259,124] &amp;lt;inf&amp;gt; lis2dh: fs=2, odr=0x1 lp_en=0x8 scale=9576
Deep Sleep Starts now
[00:00:03.275,512] &amp;lt;err&amp;gt; os: ***** MPU FAULT *****
[00:00:03.275,543] &amp;lt;err&amp;gt; os: Stacking error (context area might be not valid)
[00:00:03.275,543] &amp;lt;err&amp;gt; os: Data Access Violation
[00:00:03.275,573] &amp;lt;err&amp;gt; os: MMFAR Address: 0x200015f8
[00:00:03.275,573] &amp;lt;err&amp;gt; os: r0/a1: 0x34f155bf r1/a2: 0x00c52802 r2/a3: 0x7d679934
[00:00:03.275,604] &amp;lt;err&amp;gt; os: r3/a4: 0xc0ebe905 r12/ip: 0x5c1b1937 r14/lr: 0x0a8008e8
[00:00:03.275,604] &amp;lt;err&amp;gt; os: xpsr: 0x2406de00
[00:00:03.275,634] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x8bc6d297
[00:00:03.275,634] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
[00:00:03.275,665] &amp;lt;err&amp;gt; os: Current thread: 0x20000628 (unknown)
[00:00:04.461,730] &amp;lt;err&amp;gt; fatal_error: Resetting system
*** Booting Zephyr OS build v3.1.99-ncs1 ***
Polling at 0.5 Hz
#1 @ 266 ms: x -0.153216 , y -0.306432 , z 9.959040
Going to sleep after 3 sec...&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/438430?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2023 07:32:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b67a32a-e747-41cf-a76f-84cf6c1849cd</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The RESETPIN bit is set, indicating that the last reset was a pinreset. But did you make sure to read the register after this happened:&lt;/span&gt;&lt;/p&gt;
[quote user=""]The problem is, whenever I put the chip in system off mode, It will reset immediately[/quote]
&lt;p&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/438383?ContentTypeID=1</link><pubDate>Wed, 26 Jul 2023 19:25:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:736676cd-bb59-4736-a4cb-2c2baf2b1a59</guid><dc:creator>Hossein Kasaei</dc:creator><description>&lt;p&gt;Hi Vidar,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;While my code was running, I ran the command you said in the terminal and I read : 0x40000400: 00000001. How do you interpret that ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/438051?ContentTypeID=1</link><pubDate>Tue, 25 Jul 2023 11:16:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e81a5d08-62b8-43a4-9188-a669d97ca4dc</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;None of the pins appear to be configured with sense enabled, which makes me think the wake-up is caused by something else. Please read the&amp;nbsp;&lt;a title="  RESETREAS  " href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/power.html?cp=5_2_0_17_8_2#register.RESETREAS"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;RESETREAS&lt;/a&gt;&amp;nbsp;after the device failed to stay in system off to see if the &amp;#39;OFF&amp;#39; bit is set. You can do this with the &amp;quot;$ nrfjprog --memrd 0x40000400 &amp;quot; command (Note that the chip can&amp;#39;t enter system OFF when it&amp;#39;s in debug interface mode).&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/437998?ContentTypeID=1</link><pubDate>Tue, 25 Jul 2023 07:53:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:567d682e-66e4-4491-9360-0734041a7b50</guid><dc:creator>Hossein Kasaei</dc:creator><description>&lt;p&gt;Hi, &lt;br /&gt;&lt;br /&gt;Thanks for your response. I checked the pin configuration before and after suspending the sensor driver, but it seems it doesn&amp;#39;t change any pin configuration : &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:365px;max-width:642px;" alt=" " height="365" src="https://devzone.nordicsemi.com/resized-image/__size/1284x730/__key/communityserver-discussions-components-files/4/before_5F00_after.png" width="642" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restart after system off if the sensor driver is not suspended (Zephyr OS)</title><link>https://devzone.nordicsemi.com/thread/437836?ContentTypeID=1</link><pubDate>Mon, 24 Jul 2023 11:09:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd2d3279-cdc3-406b-8426-54c2a65a8552</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;GPIOs that are configured as input with sense enabled can trigger wake-up from System OFF. Therefore, I assume the LIS2DH driver is configuring GPIOs with sense enabled, and that is what causes your device to immediately wake up again when you haven&amp;#39;t suspended it.&lt;br /&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I suggest you compare the pin configurations in VS code before and after suspending the device.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/1321.pastedimage1689079618520v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>