<?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>Debug Port Disabled After Flashing TF-M Provisioning Image on nRF9151DK: Is This Intentional?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114815/debug-port-disabled-after-flashing-tf-m-provisioning-image-on-nrf9151dk-is-this-intentional</link><description>Context: 
 I&amp;#39;m testing the tfm_psa_template sample on the nRF9151DK and I got confused as to why I lose access to the debug port. 
 As required by the sample, I first flash the provisioning_image sample to write keys to OTP. After flashing this sample</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 25 Sep 2024 11:03:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114815/debug-port-disabled-after-flashing-tf-m-provisioning-image-on-nrf9151dk-is-this-intentional" /><item><title>RE: Debug Port Disabled After Flashing TF-M Provisioning Image on nRF9151DK: Is This Intentional?</title><link>https://devzone.nordicsemi.com/thread/503731?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2024 11:03:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9a8b3aa-0765-493b-8ca9-7566a5a9eaef</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Vytautas,&amp;nbsp;&lt;br /&gt;I would consider this as a feature not a bug. The documentation should be improved though. You can leave the ticket as is.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Debug Port Disabled After Flashing TF-M Provisioning Image on nRF9151DK: Is This Intentional?</title><link>https://devzone.nordicsemi.com/thread/503397?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2024 12:41:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0fa9141-cb12-475b-b057-1bc4ed96964c</guid><dc:creator>vytautas</dc:creator><description>&lt;p&gt;The ticket can be closed, though I am not sure which answer should be &amp;#39;verified&amp;#39;.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Debug Port Disabled After Flashing TF-M Provisioning Image on nRF9151DK: Is This Intentional?</title><link>https://devzone.nordicsemi.com/thread/503296?ContentTypeID=1</link><pubDate>Fri, 20 Sep 2024 14:15:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:964f3ec5-9741-44cb-8029-a7b689aa6b2c</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I agree, the documentation should mention that the sample also demonstrate blocking debug port on the app core .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Debug Port Disabled After Flashing TF-M Provisioning Image on nRF9151DK: Is This Intentional?</title><link>https://devzone.nordicsemi.com/thread/503293?ContentTypeID=1</link><pubDate>Fri, 20 Sep 2024 13:57:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f31287f-9116-41e7-b285-75bc67b64c2d</guid><dc:creator>vytautas</dc:creator><description>&lt;p&gt;The way it is now is acceptable to me.&lt;/p&gt;
&lt;p&gt;For debugging, we can just use a patched/modified file.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I was just outlying everything for anyone who stumbles across this ticket.&lt;/p&gt;
&lt;p&gt;Though I do think it should be added to the README.md that debug port will be disabled&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Debug Port Disabled After Flashing TF-M Provisioning Image on nRF9151DK: Is This Intentional?</title><link>https://devzone.nordicsemi.com/thread/503290?ContentTypeID=1</link><pubDate>Fri, 20 Sep 2024 13:49:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7b20dde-67e4-4d74-a19c-57d3efd3a665</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Vytautas,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;If you take a look at this:&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf9151/page/dif.html#ariaid-title3"&gt;https://docs.nordicsemi.com/bundle/ps_nrf9151/page/dif.html#ariaid-title3&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You can find that the Debug/Access port is protected by both hardware and software. The UICR.APPROTECT is the Hardware protection. It&amp;#39;s not just for indication.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;To be honest I&amp;#39;m not too familiar with TFM and PSA, but my point of view is that after you run provisioning image and having identity key stored on UICR, you&amp;nbsp;MUST have disable port locked. From security point of view, this is&amp;nbsp;a MUST. I know that for developing you still want to be able to access debug port and want that we provide an option/configuration to disable this feature.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;But as security sample I don&amp;#39;t think it&amp;#39;s a good idea. This create a chance that product getting out on the market with this backdoor still open because&amp;nbsp;the developer&amp;nbsp;forgot to remove the DEBUG option. Trust me, this story is really not uncommon.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;After the UICR.APPROTECT block the debug port access, the only way to change this value is to erase the UICR and the only way to erase the UICR is to do an Eraseall (if it&amp;#39;s still not blocked).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Debug Port Disabled After Flashing TF-M Provisioning Image on nRF9151DK: Is This Intentional?</title><link>https://devzone.nordicsemi.com/thread/503151?ContentTypeID=1</link><pubDate>Thu, 19 Sep 2024 14:34:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0bd7b61-2c81-4b46-acd2-2f44525edff2</guid><dc:creator>vytautas</dc:creator><description>&lt;p&gt;On the SiP it says &amp;quot;NRF9151 LACA A0 2422AAAC002TKFE&amp;quot;&lt;/p&gt;
&lt;p&gt;I managed to get debugging to work. I originally thought that UICR by itself isn&amp;#39;t going to disable the debug port and was set only to indicate the debugging needs to be disabled.&lt;/p&gt;
&lt;p&gt;To enable debugging, apply the following patch:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;diff --git nrf/modules/trusted-firmware-m/tfm_boards/common/nrf_provisioning.c nrf/modules/trusted-firmware-m/tfm_boards/common/nrf_provisioning.c
index 4ce7792e1..cd8c9e782 100644
--- nrf/modules/trusted-firmware-m/tfm_boards/common/nrf_provisioning.c
+++ nrf/modules/trusted-firmware-m/tfm_boards/common/nrf_provisioning.c
@@ -29,7 +29,7 @@ static enum tfm_plat_err_t disable_debugging(void)

        if (approt_writable) {
                nrfx_nvmc_word_write((uint32_t)&amp;amp;NRF_UICR_S-&amp;gt;APPROTECT,
-                                    UICR_APPROTECT_PALL_Protected);
+                                    UICR_APPROTECT_PALL_HwUnprotected);
                nrfx_nvmc_word_write((uint32_t)&amp;amp;NRF_UICR_S-&amp;gt;SECUREAPPROTECT,
                                     UICR_SECUREAPPROTECT_PALL_Protected);
        } else {&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;(You might also need to apply the workaround in the errata. In my case it wasn&amp;#39;t necessary)&lt;/p&gt;
&lt;p&gt;The default behavior for the TF-M implementation for NRF is to disable the debugger.&lt;/p&gt;
&lt;p&gt;There doesn&amp;#39;t seem to be a way to prevent this without modifying the code.&lt;/p&gt;
&lt;p&gt;(Perhaps something to look into for Nordic?)&lt;/p&gt;
&lt;p&gt;See nrf/modules/trusted-firmware-m/tfm_boards/common/nrf_provisioning.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static enum tfm_plat_err_t disable_debugging(void)
{
	/* Configure the UICR such that upon the next reset, APPROTECT will be enabled */
	bool approt_writable;

	approt_writable = nrfx_nvmc_word_writable_check((uint32_t)&amp;amp;NRF_UICR_S-&amp;gt;APPROTECT,
							UICR_APPROTECT_PALL_Protected);
	approt_writable &amp;amp;= nrfx_nvmc_word_writable_check((uint32_t)&amp;amp;NRF_UICR_S-&amp;gt;SECUREAPPROTECT,
							 UICR_SECUREAPPROTECT_PALL_Protected);

	if (approt_writable) {
		nrfx_nvmc_word_write((uint32_t)&amp;amp;NRF_UICR_S-&amp;gt;APPROTECT,
				     UICR_APPROTECT_PALL_HwUnprotected);
		nrfx_nvmc_word_write((uint32_t)&amp;amp;NRF_UICR_S-&amp;gt;SECUREAPPROTECT,
				     UICR_SECUREAPPROTECT_PALL_Protected);
	} else {
		return TFM_PLAT_ERR_SYSTEM_ERR;
	}

	return TFM_PLAT_ERR_SUCCESS;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If NRF_APPROTECT_USER_HANDLING is set, you will likely need to modify the UICR register yourself to unlock the debugger. Though I haven&amp;#39;t tried this out yet... though isn&amp;#39;t UICR supposed to be locked and inaccessible?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Debug Port Disabled After Flashing TF-M Provisioning Image on nRF9151DK: Is This Intentional?</title><link>https://devzone.nordicsemi.com/thread/503091?ContentTypeID=1</link><pubDate>Thu, 19 Sep 2024 10:36:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2a86b80-51c6-494a-9d3f-0c023bf92543</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Vytautas,&amp;nbsp;&lt;br /&gt;Do you have any other DK that you can test for example the nRF9160DK ?&amp;nbsp;&lt;br /&gt;I got a tip from a coworker that this behavior can be related to this errata:&amp;nbsp;&lt;br /&gt;&lt;a href="https://docs.nordicsemi.com/bundle/errata_nRF9151_Rev1/page/ERR/nRF9151/Rev1/latest/anomaly_151_36.html#anomaly_151_36"&gt;https://docs.nordicsemi.com/bundle/errata_nRF9151_Rev1/page/ERR/nRF9151/Rev1/latest/anomaly_151_36.html#anomaly_151_36&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can also try the workaround in the errata to see if it help solving the issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>