<?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>nRF54L15 crashes on debug when using TFM due to GDB triggering the MPC while reading call stacks</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/125851/nrf54l15-crashes-on-debug-when-using-tfm-due-to-gdb-triggering-the-mpc-while-reading-call-stacks</link><description>I&amp;#39;m building the nrf/samples/openthread/cli sample with the nrf54l15dk/nrf54l15/cpuapp/ns board. The only change I&amp;#39;m making is enabling CONFIG_DEBUG_THREAD_INFO. 
 The app runs fine until you pause execution in any way with the debugger. When GDB pauses</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Dec 2025 18:51:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/125851/nrf54l15-crashes-on-debug-when-using-tfm-due-to-gdb-triggering-the-mpc-while-reading-call-stacks" /><item><title>RE: nRF54L15 crashes on debug when using TFM due to GDB triggering the MPC while reading call stacks</title><link>https://devzone.nordicsemi.com/thread/556053?ContentTypeID=1</link><pubDate>Tue, 02 Dec 2025 18:51:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bfcc64c-a72c-421c-b2f7-7a577bd69b94</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The MPC&amp;nbsp;is a generic Cortex M33 feature/peripheral; where as the memory map of a Cortex M device is implementation specific (ie. vendor and/or device specific), so changing the zephyr configuration might not be the best option.&lt;/p&gt;
&lt;p&gt;The MPC peripheral does what it is supposed to do here, where it detects an out-of-bounds read,&amp;nbsp;the MPC event is then triggered and TF-M has MPC_IRQn enabled.&lt;/p&gt;
&lt;p&gt;I suspect the proper way around this would be to add a debug check in TF-M, similar to this one, with a guard of CONFIG_INIT_STACKS:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/ncs-v3.2.0-rc1/platform/ext/target/nordic_nrf/common/core/faults.c#L111-L126"&gt;https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/ncs-v3.2.0-rc1/platform/ext/target/nordic_nrf/common/core/faults.c#L111-L126&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will report this to the TF-M team internally, but CONFIG_INIT_STACKS hardcodes the value based on architecture, here for the cortex m:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/arch/arm/core/cortex_m/reset.S#L204"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/main/arch/arm/core/cortex_m/reset.S#L204&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This means that the value to check for is technically subject-to-change, and unless zephyr is changed; the magic value&amp;nbsp;would&amp;nbsp;also be copied into TF-M.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF54L15 crashes on debug when using TFM due to GDB triggering the MPC while reading call stacks</title><link>https://devzone.nordicsemi.com/thread/555922?ContentTypeID=1</link><pubDate>Mon, 01 Dec 2025 20:05:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1c4a68d-6b03-4daa-afe4-348c31352487</guid><dc:creator>michael.feist.etc</dc:creator><description>&lt;p&gt;I tested the hello_world sample to simplify this as well. To make the crash more repeatable, it&amp;#39;s helpful to have CONFIG_INIT_STACKS=y in order to force that return address to a bogus address that is unmapped in memory. If the address is 0x0, the MPC won&amp;#39;t trigger. Any thoughts on whether this is worth bringing up in Zephyr&amp;#39;s github issues?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF54L15 crashes on debug when using TFM due to GDB triggering the MPC while reading call stacks</title><link>https://devzone.nordicsemi.com/thread/555726?ContentTypeID=1</link><pubDate>Fri, 28 Nov 2025 10:52:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d266732-c248-4580-aa3f-710c18bebd19</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you for sharing.&lt;/p&gt;
&lt;p&gt;I took an arbitrary example, and used &amp;quot;west attach&amp;quot; to connect to an already running debug session, with this backtrace:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;(gdb) bt
#0  __enable_irq () at /opt/ncs/modules/hal/cmsis/CMSIS/Core/Include/cmsis_gcc.h:951
#1  arch_cpu_idle () at /opt/ncs/zephyr/arch/arm/core/cortex_m/cpu_idle.c:104
#2  0x0000613c in k_cpu_idle () at /opt/ncs/zephyr/include/zephyr/kernel.h:6323
#3  idle (unused1=&amp;lt;optimized out&amp;gt;, unused2=&amp;lt;optimized out&amp;gt;, unused3=&amp;lt;optimized out&amp;gt;) at /opt/ncs/zephyr/kernel/idle.c:75
#4  0x00000d02 in z_thread_entry (entry=0x611d &amp;lt;idle&amp;gt;, p1=0x20000d18 &amp;lt;_kernel&amp;gt;, p2=0x0 &amp;lt;cbvprintf_package&amp;gt;, 
    p3=0x0 &amp;lt;cbvprintf_package&amp;gt;) at /opt/ncs/zephyr/lib/os/thread_entry.c:48
#5  0x00000000 in ?? ()&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now, I printed the MPC.EVENTS_MEMACCERR, MEMACCERR.*, with the addresses in the datasheet (&lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf54L15/page/mpc.html#ariaid-title4"&gt;https://docs.nordicsemi.com/bundle/ps_nrf54L15/page/mpc.html#ariaid-title4&lt;/a&gt;):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;(gdb) print *0x50041100
$1 = 0x0
(gdb) print *0x50041400
$2 = 0x0
(gdb) print *0x50041404
$3 = 0x0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So far, so good.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now, to trigger the MPC:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;(gdb) print *0xaaaaaaaa
Cannot access memory at address 0xaaaaaaaa&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And print the MPC registers mentioned above:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;(gdb) print *0x50041404
$4 = 0x19041
(gdb) print *0x50041400
$5 = 0xaaaaaaaa
(gdb) print *0x50041100
$6 = 0x1&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;This behaviour correlates with your observation:&lt;/p&gt;
[quote user=""]The app runs fine until you pause execution in any way with the debugger. When GDB pauses execution, it reads the call stacks which eventually lead to a dummy return address since GDB doesn&amp;#39;t know to stop at z_thread_entry[/quote]
&lt;p&gt;With your configuration, ie. with secure/non-secure split:&lt;/p&gt;
[quote user=""]nrf54l15dk/nrf54l15/cpuapp/ns board[/quote]
&lt;p&gt;secure side, ie. TFM, will own the MPC peripheral.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I took the hello_world sample, configured it with /ns board, and tried the same procedure. I can see that the MPC registers are set as before when doing a print *0xAAAAAAAA, and can confirm that TF-M will trigger a fault on this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;arch_cpu_idle () at /opt/ncs/zephyr/arch/arm/core/cortex_m/cpu_idle.c:104
104             __enable_irq();
(gdb) print *0xaaaaaaaa
Cannot access memory at address 0xaaaaaaaa
(gdb) c
Continuing.
^C
Program received signal SIGTRAP, Trace/breakpoint trap.
tfm_hal_system_halt () at /opt/ncs/nrf/modules/trusted-firmware-m/tfm_boards/common/tfm_hal_reset_halt.c:30
30              while (1) {
(gdb) bt
#0  tfm_hal_system_halt () at /opt/ncs/nrf/modules/trusted-firmware-m/tfm_boards/common/tfm_hal_reset_halt.c:30
#1  0x0000744c in tfm_core_panic () at /opt/ncs/modules/tee/tf-m/trusted-firmware-m/secure_fw/spm/core/utilities.c:26
#2  0x0000640a in MPC_Handler ()
    at /opt/ncs/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/faults.c:102
Backtrace stopped: previous fra&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF54L15 crashes on debug when using TFM due to GDB triggering the MPC while reading call stacks</title><link>https://devzone.nordicsemi.com/thread/555542?ContentTypeID=1</link><pubDate>Wed, 26 Nov 2025 15:35:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14069401-928d-4aea-b5c3-dcd4cf2e34ce</guid><dc:creator>michael.feist.etc</dc:creator><description>&lt;p&gt;I&amp;#39;m also thinking this may be worth bringing up in a Zephyr issue since I would imagine this affects more than just nRF chips.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>