<?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>MPU Fault when attempting to subscribe to BLE notifications</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94144/mpu-fault-when-attempting-to-subscribe-to-ble-notifications</link><description>Hi! 
 I am attempting to configure a nrf5340 dk as a central to receive BLE notifications. The code is based on the central_hr sample. 
 The notifications i am attempting to receive are 20 bytes of accelerometer data sent every 1000ms from another development</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 29 Nov 2022 09:29:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94144/mpu-fault-when-attempting-to-subscribe-to-ble-notifications" /><item><title>RE: MPU Fault when attempting to subscribe to BLE notifications</title><link>https://devzone.nordicsemi.com/thread/398040?ContentTypeID=1</link><pubDate>Tue, 29 Nov 2022 09:29:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f61a854-2dae-4d75-bbfa-9e063b3172b4</guid><dc:creator>teover</dc:creator><description>&lt;p&gt;Takk Vidar!&lt;/p&gt;
&lt;p&gt;This helped me trace the faulting code, which was an incorrectly defined exchange_mtu function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPU Fault when attempting to subscribe to BLE notifications</title><link>https://devzone.nordicsemi.com/thread/397007?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2022 17:59:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:618edb8e-38b9-417c-a12c-443edecf8032</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Tor Egil,&lt;/p&gt;
&lt;p&gt;Thanks for confirming and for providing the additional information.&amp;nbsp;0x20005fb8 is pointing to the idle thread&amp;#39;s stack if I&amp;#39;m reading the map file correctly, which doesn&amp;#39;t make much sense, or not to me, at least. I guess was expecting&amp;nbsp;a more&amp;nbsp;&amp;quot;random&amp;quot; address.&lt;/p&gt;
&lt;p&gt;To troubleshoot this further, I would suggest that you re-build the project with&amp;nbsp;CONFIG_ARM_MPU=n. This will allow code execution from RAM without triggering the MPU fault you saw earlier. You&amp;nbsp;should then be able to place a breakpoint at the faulting RAM address and (hopefully) find out exactly where the branch to this invalid address occurred in the first place.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How to set a&amp;nbsp;breakpoint at an arbitrary address in VS code&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1669139493845v7.png" alt=" " /&gt;&lt;/strong&gt;&lt;/p&gt;
[quote user="teover"]I would also like to note that the BT RX thread is usually at up to 80%-99% CPU in the thread analyze before the MPU fault, but was not in first picture i posted.&amp;nbsp;[/quote]
&lt;p&gt;It seems a bit high, but I haven&amp;#39;t tried to profile the CPU usage in this scenario, so I&amp;#39;m not sure if it is to be expected or not.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPU Fault when attempting to subscribe to BLE notifications</title><link>https://devzone.nordicsemi.com/thread/396958?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2022 14:03:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:693697da-d441-4055-b1b0-ec9e7138736d</guid><dc:creator>teover</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In my zephyr.map(address at line 15):&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; .noinit.&amp;quot;WEST_TOPDIR/zephyr/subsys/bluetooth/host/long_wq.c&amp;quot;.0
                0x0000000020003550      0x518 zephyr/subsys/bluetooth/host/libsubsys__bluetooth__host.a(long_wq.c.obj)
                0x0000000020003550                bt_lw_stack_area
 .noinit.&amp;quot;WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c&amp;quot;.0
                0x0000000020003a68     0x1000 zephyr/subsys/bluetooth/host/libsubsys__bluetooth__host.a(hci_core.c.obj)
 .noinit.&amp;quot;WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c&amp;quot;.1
                0x0000000020004a68      0x400 zephyr/subsys/bluetooth/host/libsubsys__bluetooth__host.a(hci_core.c.obj)
 .noinit.&amp;quot;WEST_TOPDIR/zephyr/subsys/bluetooth/host/att.c&amp;quot;.k_mem_slab_buf_chan_slab
                0x0000000020004e68      0x150 zephyr/subsys/bluetooth/host/libsubsys__bluetooth__host.a(att.c.obj)
                0x0000000020004e68                _k_mem_slab_buf_chan_slab
 .noinit.&amp;quot;WEST_TOPDIR/zephyr/kernel/init.c&amp;quot;.0
                0x0000000020004fb8     0x1000 zephyr/kernel/libkernel.a(init.c.obj)
                0x0000000020004fb8                z_main_stack
 .noinit.&amp;quot;WEST_TOPDIR/zephyr/kernel/init.c&amp;quot;.1
                0x0000000020005fb8      0x140 zephyr/kernel/libkernel.a(init.c.obj)
 .noinit.&amp;quot;WEST_TOPDIR/zephyr/kernel/init.c&amp;quot;.2
                0x00000000200060f8      0x800 zephyr/kernel/libkernel.a(init.c.obj)
                0x00000000200060f8                z_interrupt_stacks
 .noinit.&amp;quot;WEST_TOPDIR/zephyr/kernel/system_work_q.c&amp;quot;.0
                0x00000000200068f8      0x800 zephyr/kernel/libkernel.a(system_work_q.c.obj)
 .noinit.&amp;quot;WEST_TOPDIR/zephyr/kernel/mempool.c&amp;quot;.kheap_buf__system_heap
                0x00000000200070f8      0x800 zephyr/kernel/libkernel.a(mempool.c.obj)
                0x00000000200070f8                kheap__system_heap
 .noinit.&amp;quot;WEST_TOPDIR/zephyr/subsys/bluetooth/host/buf.c&amp;quot;.0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;subscribe_params&amp;nbsp;is initialized to zero and passed to&amp;nbsp;&lt;/span&gt;bt_gatt_subscribe as the second screenshot&lt;span&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1669124580620v2.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I would also like to note that the BT RX thread is usually at up to 80%-99% CPU in the thread analyze before the MPU fault, but was not in first picture i posted.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MPU Fault when attempting to subscribe to BLE notifications</title><link>https://devzone.nordicsemi.com/thread/396890?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2022 12:09:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45d15f80-aca0-4293-9b8d-983c95bb980d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;If there were a stack overflow, it should have been caught by the stack limit checker (in HW) before your program had a chance to try executing code from RAM and trigger the MPU fault. Could you please try to look up the faulting address (0x20005fb8) in your *.map file to see what variable you have in that address range?&lt;/p&gt;
&lt;p&gt;Also, just to confirm, is the subscribe_params struct initialized to zero?&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>