<?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>Zephyr application reading it&amp;#39;s own code partition</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87197/zephyr-application-reading-it-s-own-code-partition</link><description>Hey guys, 
 I have a small concern and decided to ask here, as i was not able to found answer neither in zephyr or nrf sdk docs (not even sure which one apply to my question). Is zephyr application able to read it&amp;#39;s own code from slot0? (i.e. by using</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 22 Apr 2022 11:18:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87197/zephyr-application-reading-it-s-own-code-partition" /><item><title>RE: Zephyr application reading it's own code partition</title><link>https://devzone.nordicsemi.com/thread/364449?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 11:18:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8d3e232-3c87-4340-834b-9b6d53fcbc64</guid><dc:creator>Dymek117</dc:creator><description>&lt;p&gt;Thanks Dejan, you absolutely cleared out all my doubts! :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr application reading it's own code partition</title><link>https://devzone.nordicsemi.com/thread/364436?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 10:52:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29cb3f78-4a5b-4ff1-9d06-92b51b3e48f0</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]Is zephyr application able to read it&amp;#39;s own code from slot0? (i.e. by using Zephyr flash_read())[/quote]
&lt;p&gt;flash_read() is used to read the data from the flash. You should be able to read the content of the flash from your own application.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user=""]This way I would be able to copy code of currently run from slot0 app to slot1, and then for mcuboot to swap and boot this cloned application right?[/quote]
&lt;p&gt;When you have copied the content from primary to the secondary slot, then MCUboot would see the same content in both slots. The bootloader supports both swap-based and overwrite-based image upgrades, as explained in&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/mcuboot/design.html"&gt;bootloader documentation&lt;/a&gt;.&lt;/p&gt;
[quote user=""]It looks possible, but isn&amp;#39;t there any mechanism blocking such readout from currently run slot?&amp;nbsp;&lt;br /&gt;How does APPROTECT apply to my question?[/quote]
&lt;p&gt;Access port protection (APPROTECT) is a&amp;nbsp;register that is used to prevent read and write access to all CPU registers and memory-mapped addresses. APPROTECT needs to be enabled on the device in order to prevent reading certain memory addresses and it is not related to accessing the flash area from the application.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>