<?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>nrf5340: Evaluating Power Consumption of XIP Functions</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85955/nrf5340-evaluating-power-consumption-of-xip-functions</link><description>Hello, 
 I am looking into evaluating the nrf5340 with different functions running out of external flash, and how current draw is affected by these functions. We are looking at running some code out of qspi flash, and other code internally. We plan to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 21 Mar 2022 23:50:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85955/nrf5340-evaluating-power-consumption-of-xip-functions" /><item><title>RE: nrf5340: Evaluating Power Consumption of XIP Functions</title><link>https://devzone.nordicsemi.com/thread/359241?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2022 23:50:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57aadd0f-e77c-4f86-9bc1-49d15bf21482</guid><dc:creator>wyorgason</dc:creator><description>&lt;p&gt;Thanks for this information and the sample project. I download the project and built it. I am having problems flashing it.&amp;nbsp; I am using the nrf SDK version 1.9.0 and Visual Studio Code with Windows 10.&amp;nbsp; Here is my flash command and the response:&lt;/p&gt;
&lt;p&gt;nrfjprog --coprocessor CP_APPLICATION --sectorerase --qspisectorerase --verify --program build/zephyr/zephyr.hex --log&lt;br /&gt;&lt;br /&gt;Parsing image file.&lt;br /&gt;Verifying programming.&lt;br /&gt;ERROR: [&amp;nbsp; nRF53] - Data does not match in QSPI memory address range [0x00000000-0x000051f4]&lt;br /&gt;ERROR: [&amp;nbsp; nRF53] - QSPI memory verification failed&lt;br /&gt;ERROR: [&amp;nbsp; nRF53] - Failed while verifying file build/zephyr/zephyr.hex.&lt;br /&gt;ERROR: Write verify failed.&lt;/p&gt;
&lt;p&gt;I also tried to make my own little application that places some functions in external flash space. Here is a portion of the map file that shows &amp;quot;test_code&amp;quot; and &amp;quot;test2_code&amp;quot; in external flash space, as well as the flash command and response:&lt;/p&gt;
&lt;p&gt;xip_text&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x10000000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x34&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x10000000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN (0x4)&lt;br /&gt;xip_text&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x10000000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x34 app/libapp.a(test_code.c.obj)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x10000000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; test_code&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x1000001a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; test2_code&lt;/p&gt;
&lt;p&gt;But on flashing the device, it shows an error that the program downloader doesn&amp;rsquo;t know how to write to external QSPI flash.&lt;/p&gt;
&lt;p&gt;nrfjprog --coprocessor CP_APPLICATION --sectorerase --qspisectorerase --verify --program internal_flash/zephyr/zephyr.hex --log&lt;/p&gt;
&lt;p&gt;Parsing image file.&lt;br /&gt;ERROR: [ Worker] - Address 0x00100000 does not map to a known memory.&lt;br /&gt;ERROR: The file specified is not a valid hex file, has data outside valid areas&lt;br /&gt;ERROR: or does not have data in valid areas.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5340: Evaluating Power Consumption of XIP Functions</title><link>https://devzone.nordicsemi.com/thread/359240?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2022 23:13:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8fdbb13-19c2-4478-be67-dfa24aeba3f9</guid><dc:creator>Krzysztof Loska</dc:creator><description>&lt;p&gt;Recently we did some measurements to evaluate performance of the nRF5340 XIP. Execute in place (XIP) allows the CPU to execute program code directly from the external flash: &lt;a href="https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Finfocenter.nordicsemi.com%2Ftopic%2Fps_nrf5340%2Fqspi.html%3Fcp%3D3_0_0_6_24_4%23execute_in_place&amp;amp;data=04%7C01%7CKrzysztof.Loska%40nordicsemi.no%7C88691fe835014a12612b08da0b8d10be%7C28e5afa2bf6f419a8cf6b31c6e9e5e8d%7C0%7C0%7C637834997749312345%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;amp;sdata=32CkIMSOip43u%2F4jy%2BDGrZ4rhYfWQDiTS8oFFdoKGoY%3D&amp;amp;reserved=0"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf5340/qspi.html?cp=3_0_0_6_24_4#execute_in_place&lt;/a&gt;. Maybe this is something useful for you.&lt;/p&gt;
&lt;p&gt;For the experiment nRF Connect SDK Machine Learning application has been chosen: &lt;a href="https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdeveloper.nordicsemi.com%2FnRF_Connect_SDK%2Fdoc%2Flatest%2Fnrf%2Fapplications%2Fmachine_learning%2FREADME.html&amp;amp;data=04%7C01%7CKrzysztof.Loska%40nordicsemi.no%7C88691fe835014a12612b08da0b8d10be%7C28e5afa2bf6f419a8cf6b31c6e9e5e8d%7C0%7C0%7C637834997749312345%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;amp;sdata=fiW4NjDF8cLe%2BASUwrmdeg58I8BagAYnIiXXhh%2BJrVA%3D&amp;amp;reserved=0"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/machine_learning/README.html#&lt;/a&gt;. Application design allows to separate Edge Impulse library to an external memory. There is only one call to this library from Edge Impulse wrapper module, and therefore this call is used to measure time of execution. Additional measurements of current allowed us to compare total energy used. Please note that given numbers include current consumed only by the nRF5340 alone. To have a complete number you should add an additional current used by an external Flash, which will vary between manufacturers.&lt;/p&gt;
&lt;p&gt;If you plan to run radio operations and use QSPI/XIP concurrently, you should only compare numbers for 1.8V. This is because of the following errata: &lt;a href="https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Finfocenter.nordicsemi.com%2Ftopic%2Ferrata_nRF5340_Rev1%2FERR%2FnRF5340%2FRev1%2Flatest%2Fanomaly_340_133.html%3Fcp%3D3_0_1_0_1_18&amp;amp;data=04%7C01%7CKrzysztof.Loska%40nordicsemi.no%7C88691fe835014a12612b08da0b8d10be%7C28e5afa2bf6f419a8cf6b31c6e9e5e8d%7C0%7C0%7C637834997749469177%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;amp;sdata=2e9SGyAhrByUJxe9eI5SidLTh2m%2Bfw1ycZyZz4CtnQE%3D&amp;amp;reserved=0"&gt;https://infocenter.nordicsemi.com/topic/errata_nRF5340_Rev1/ERR/nRF5340/Rev1/latest/anomaly_340_133.html?cp=3_0_1_0_1_18&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/xip_5F00_measurements.png" /&gt;&lt;/p&gt;
&lt;p&gt;The best results for execution from an external Flash were achieved for CPU freq == 128 MHz, with cache enabled and QSPI speed == 96 MHz. Execution time was 10% longer, and energy used was 27% higher comparing to the same setup while running from the internal Flash.&lt;/p&gt;
&lt;p&gt;Please note that execution time 10% longer, and energy used 27% higher does not apply to the entire solution, but only to a code parts running from an external Flash. If you split the code in a clever way so that rarely used functions are in the external Flash and often used functions are in the internal Flash, the results relating to the overall solution will be much better.&lt;/p&gt;
&lt;p&gt;Here are tips if you would like to repeat these measurements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;branch used for the experiment can be found at &lt;a href="https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fawojasinski-nordicsemi%2Fsdk-nrf%2Ftree%2FNRFX-1428-xip-performance-ncs&amp;amp;data=04%7C01%7CKrzysztof.Loska%40nordicsemi.no%7C88691fe835014a12612b08da0b8d10be%7C28e5afa2bf6f419a8cf6b31c6e9e5e8d%7C0%7C0%7C637834997749469177%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;amp;sdata=mTSzFse2HyZ%2F%2BMFBLSxy%2F5vWg8zNaFlRkX%2BM7TtDfeE%3D&amp;amp;reserved=0"&gt;https://github.com/awojasinski-nordicsemi/sdk-nrf/tree/NRFX-1428-xip-performance-ncs&lt;br /&gt;&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;compilation: &lt;em&gt;west build -b nrf5340dk_nrf5340_cpuapp&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;flashing firmware: &lt;em&gt;nrfjprog --coprocessor CP_APPLICATION --sectorerase --qspisectorerase --program build/zephyr/zephyr.hex&lt;br /&gt;&lt;br /&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Compile to external memory:
&lt;ul&gt;
&lt;li&gt;in CMakeLists.txt change compile definition XIP_MEMORY=1&lt;/li&gt;
&lt;li&gt;in configuration/nrf5340dk_nrf5340_cpuapp/prj.conf change CONFIG_HAVE_CUSTOM_LINKER_SCRIPT to y&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Compile to internal memory
&lt;ul&gt;
&lt;li&gt;in CMakeLists.txt change compile definition XIP_MEMORY=0&lt;/li&gt;
&lt;li&gt;in configuration/nrf5340dk_nrf5340_cpuapp/prj.conf change CONFIG_HAVE_CUSTOM_LINKER_SCRIPT to n&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Change CPU clock to 128MHz
&lt;ul&gt;
&lt;li&gt;in CMakeLists.txt change compile definition CPU_128MHZ=1 (0 =&amp;gt; 64MHz, 1=&amp;gt; 128MHz)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Change QSPI speed
&lt;ul&gt;
&lt;li&gt;in CMakeLists.txt change compile definition XIP_DIV
&lt;ul&gt;
&lt;li&gt;XIP_DIV=0 =&amp;gt; 94MHz&lt;/li&gt;
&lt;li&gt;XIP_DIV=1 =&amp;gt; 48MHz&lt;/li&gt;
&lt;li&gt;XIP_DIV=2 =&amp;gt; 24MHz&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Disable/Enable Cache
&lt;ul&gt;
&lt;li&gt;in configuration/nrf5340dk_nrf5340_cpuapp/prj.conf change CONFIG_NRF_ENABLE_CACHE to n/y&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>