<?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>Programming and reading OTP</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92878/programming-and-reading-otp</link><description>I want to store some board info (serial number etc.) in OTP during board production. I managed to program OTP[189] trough J-Link commander. Now I want to read it back in the application. 
 My first attempt was to read the address: 
 
 This results in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 13 Jan 2025 10:03:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92878/programming-and-reading-otp" /><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/518108?ContentTypeID=1</link><pubDate>Mon, 13 Jan 2025 10:03:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e160b775-c6ec-43c7-b4c7-c48b95b7fd2c</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;This was introduced in&amp;nbsp;v2.8.0:&lt;/p&gt;
[quote user="hkn"]&lt;p&gt;TFM has support for accessing UICR from a non-secure application in ncs main:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/libraries/security/tfm/tfm_ioctl_api.html#read_service"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/libraries/security/tfm/tfm_ioctl_api.html#read_service&lt;/a&gt;&lt;/p&gt;[/quote]
&lt;p&gt;so if you are on an older version, it will not work.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="jpnorair"]Alternate possibility is to create a separate block of flash that is reserved for configuration constants. &amp;nbsp;This would normally take 5 minutes to edit linker script, but with Zephyr everything is harder -- do you have a help page for how to get a reserved flash block in zephyr that gets into the linker script as a section? &amp;nbsp;For example, in order to do something like:[/quote]
&lt;p&gt;This thread shows how to add a linker section (although it is for a RAM region):&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/102932/config_custom_linker_script-in-prj-conf-not-working/443434"&gt;RE: CONFIG_CUSTOM_LINKER_SCRIPT in prj.conf not working.&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you still run into issues, please consider to create a dedicated thread&amp;nbsp;wrt. your matter.&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;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/518048?ContentTypeID=1</link><pubDate>Sat, 11 Jan 2025 14:47:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6cea0b8-8a11-4cec-bcc6-c6ca5a9ff0ec</guid><dc:creator>jpnorair</dc:creator><description>&lt;p&gt;I am using this method, still without success (result is same as from original post, error code = 2).&lt;/p&gt;
&lt;p&gt;The configuration file complains about prerequisites to&amp;nbsp;&lt;span&gt; &lt;/span&gt;&lt;a class="reference external" title="(in Kconfig reference v&amp;amp;nbsp;)" href="https://docs.nordicsemi.com/bundle/ncs-latest/page/kconfig/index.html#CONFIG_TFM_PARTITION_PLATFORM" data-bundleid="ncs-latest" data-navpath="kconfig/index.html"&gt;&lt;code class="xref kconfig kconfig-option docutils literal notranslate"&gt;&lt;span class="pre"&gt;CONFIG_TFM_PARTITION_PLATFORM&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I have a system with nrf91, the modem core running modem stuff, mcuboot on the application core, and then the application image. &amp;nbsp;I need to access OTP in the application (for read only), but I don&amp;#39;t know how to set it up so that it works.&lt;/p&gt;
&lt;p&gt;Alternate possibility is to create a separate block of flash that is reserved for configuration constants. &amp;nbsp;This would normally take 5 minutes to edit linker script, but with Zephyr everything is harder -- do you have a help page for how to get a reserved flash block in zephyr that gets into the linker script as a section? &amp;nbsp;For example, in order to do something like:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;#160;const uint8_t serial_number[] __attribute__((section(&amp;quot;.my_serial_number&amp;quot;)))&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/499482?ContentTypeID=1</link><pubDate>Fri, 23 Aug 2024 07:43:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fe6b2fb-cf80-41a6-8414-2a8dee875cbd</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;TFM has support for accessing UICR from a non-secure application in ncs main:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/libraries/security/tfm/tfm_ioctl_api.html#read_service"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/libraries/security/tfm/tfm_ioctl_api.html#read_service&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;H&amp;aring;kon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/463179?ContentTypeID=1</link><pubDate>Mon, 08 Jan 2024 14:26:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6353a311-c603-4a7d-9c0a-221ec643ad9b</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Bob,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Unfortunately, the support is not implemented in TF-M, so accessing UICR from the non-secure application must be manually implemented by adding the range as described below.&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;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/463019?ContentTypeID=1</link><pubDate>Sun, 07 Jan 2024 03:19:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c006e3d8-a2a5-4f5d-965d-57f73b5591af</guid><dc:creator>bobkressin</dc:creator><description>&lt;p&gt;Hey&amp;nbsp;&lt;span&gt;H&amp;aring;kon - &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Have you any update on this issue regarding UICR access via TF-M? We are now in a similar situation. Thank you for advising.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kind Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;- Bob&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/442729?ContentTypeID=1</link><pubDate>Wed, 23 Aug 2023 10:17:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b9c7cbf-bd11-4b30-9f6f-3a3953dc5b5b</guid><dc:creator>hugzy123</dc:creator><description>&lt;p&gt;We&amp;#39;re also wanting to use this functionality for our product&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/422267?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2023 11:30:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be1f07ce-729c-4872-a6bb-5d9f349fa045</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;Unfortunately, this is not yet implemented on our side.&lt;/p&gt;
&lt;p&gt;One can add ranges by appending this array:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/v1.6.0-ncs3/platform/ext/target/nordic_nrf/nrf9160dk_nrf9160/services/include/tfm_read_ranges.h#L25"&gt;https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/v1.6.0-ncs3/platform/ext/target/nordic_nrf/nrf9160dk_nrf9160/services/include/tfm_read_ranges.h#L25&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Similarly for nrf5340,&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/v1.6.0-ncs3/platform/ext/target/nordic_nrf/nrf5340dk_nrf5340_cpuapp/services/include/tfm_read_ranges.h"&gt;https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/v1.6.0-ncs3/platform/ext/target/nordic_nrf/nrf5340dk_nrf5340_cpuapp/services/include/tfm_read_ranges.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But, please note that due to errata #160 for nRF9160, this function needs to be patched with a similar workaround (as I posted here:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/87895/error-reading-uicr--otp-registers-in-sdk-1-9-1-result-is-0xdeaddead/368610"&gt;RE: Error reading UICR-&amp;gt;OTP registers in SDK 1.9.1 (result is 0xdeaddead)&lt;/a&gt;&amp;nbsp;)&amp;nbsp; :&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/v1.6.0-ncs3/platform/ext/target/nordic_nrf/common/core/services/src/tfm_platform_hal_ioctl.c#L57"&gt;https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/v1.6.0-ncs3/platform/ext/target/nordic_nrf/common/core/services/src/tfm_platform_hal_ioctl.c#L57&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Which is effectively a call to memcpy:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/v1.6.0-ncs3/secure_fw/spm/include/tfm_memory_utils.h#L24-L27"&gt;https://github.com/nrfconnect/sdk-trusted-firmware-m/blob/v1.6.0-ncs3/secure_fw/spm/include/tfm_memory_utils.h#L24-L27&lt;/a&gt;&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;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/421989?ContentTypeID=1</link><pubDate>Mon, 24 Apr 2023 10:12:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80c860ff-6faa-48ac-bb41-1a0c743957f5</guid><dc:creator>pf7</dc:creator><description>&lt;p&gt;Hello H&amp;aring;kon,&lt;/p&gt;
&lt;p&gt;is there any update on this issue? It seems not very professional to default to TF-M if such an important feature is not implemented yet.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Patrick&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/417659?ContentTypeID=1</link><pubDate>Mon, 27 Mar 2023 11:55:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e095eeed-dee1-485e-ab45-1dbe9040aa73</guid><dc:creator>Oskar</dc:creator><description>&lt;p&gt;I want to bump this as well, I am working on a project where we would like to use the OTP to ensure read-only data. Are there any updates on this fix?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/407322?ContentTypeID=1</link><pubDate>Tue, 31 Jan 2023 12:33:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9e12948-4716-4495-8f00-82263c1edf20</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;Unfortunately, the task is not yet addressed, but I will address your comment to the team.&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;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/407310?ContentTypeID=1</link><pubDate>Tue, 31 Jan 2023 12:08:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9175ab53-510a-4e33-84b0-ffde3e267a22</guid><dc:creator>gjoasen</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any update on when we can hope to see reading UICR supported in TFM?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/399237?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2022 15:16:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e544a3f-fde4-49d0-b3c5-b3bfaf404029</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;My apologies for the inconvenience. The feature request has not yet been implemented. I will add your comments to the internal task.&lt;/p&gt;
&lt;p&gt;At this moment, since there is no added logic for reading UICR in TFM, it has to be stored in another place, for instance in a settings page (using for instance nvs) in flash.&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;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/398732?ContentTypeID=1</link><pubDate>Fri, 02 Dec 2022 10:56:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3499b11b-b1d4-435f-9583-8733de528ad2</guid><dc:creator>allard.p</dc:creator><description>&lt;p&gt;Still working on this. If I understand correctly: Reading UICR is only allowed from secure code. TF-M is now the default in SDK 2.1.0, but it has no way to read the OTP area, so UICR is now useless for storing user data?&lt;/p&gt;
&lt;p&gt;What way does Nordic suggest to store non-changeable data such as a serial number?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/391088?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 07:05:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc68c178-f065-4f9c-aac8-43fd70a784f2</guid><dc:creator>allard.p</dc:creator><description>&lt;p&gt;Thank you, I will wait for this feature, in the meantime I&amp;#39;ll come up with another solution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming and reading OTP</title><link>https://devzone.nordicsemi.com/thread/391010?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 13:56:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdf2e0cc-a494-4b4b-8ee7-4e1c6778bf11</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;Reading from UICR is currently not supported using TF-M, but I have inputted a feature request for this internally.&lt;/p&gt;
&lt;p&gt;For the nRF9160, there&amp;#39;s an errata when reading UICR and the mainblock, which needs a specific patch in TF-M handling:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/errata_nRF9160_Rev2/ERR/nRF9160/Rev2/latest/anomaly_160_7.html?cp=2_0_1_0_1_4"&gt;https://infocenter.nordicsemi.com/topic/errata_nRF9160_Rev2/ERR/nRF9160/Rev2/latest/anomaly_160_7.html?cp=2_0_1_0_1_4&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you are using SPM, there&amp;#39;s logic for reading UICR region here that handles the scenario:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/support-private/support/289023#permalink=758929"&gt;https://devzone.nordicsemi.com/support-private/support/289023#permalink=758929&lt;/a&gt;&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;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>