<?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>Store variable in external flash at compile time</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/95302/store-variable-in-external-flash-at-compile-time</link><description>Hello, I&amp;#39;m working with nRF5340DK, and need to initialize some variables - long arrays of approximately 16 KB each 
 
 they must be included at compile time (without depending on any external serial transmission on runtime) 
 they must be stored in QSPI</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 10 Jan 2023 09:16:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/95302/store-variable-in-external-flash-at-compile-time" /><item><title>RE: Store variable in external flash at compile time</title><link>https://devzone.nordicsemi.com/thread/404013?ContentTypeID=1</link><pubDate>Tue, 10 Jan 2023 09:16:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1cd96ff-124b-4f7b-8b3e-f78f8acced7b</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Leopoldo&lt;/p&gt;
&lt;p&gt;Great to hear that you got it working well &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Thanks for sharing the final code with the community,&amp;nbsp;I am sure this can be useful for others. Like I said this was a good learning experience for us as well, I can foresee many applications where it is handy to store data in external flash in this way.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The best of luck with your project!&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Store variable in external flash at compile time</title><link>https://devzone.nordicsemi.com/thread/403936?ContentTypeID=1</link><pubDate>Mon, 09 Jan 2023 21:14:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01f9c2e7-66a5-47b8-b404-a9d9f2247cf3</guid><dc:creator>lbudde</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;ve built your uploaded code, and added flash_read functions as you recomended, and everything works perfectly on SDK 1.7.1!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks a lot for all your help, this is exactly what we were looking for, and also thanks on the suggestion on using flash API instead of XIP on variables reading.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I leave here a .zip with my final version, which is exactly the same code you uploaded, with flash_read added in main.c, in case there is someone else who also needs this in the future.&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1_5F00_7_5F00_1_5F00_code_5F00_relocation_5F00_t.rar"&gt;devzone.nordicsemi.com/.../1_5F00_7_5F00_1_5F00_code_5F00_relocation_5F00_t.rar&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks again for your&amp;nbsp;- and your collegue&amp;#39;s&amp;nbsp;- time, this has been really usefull for us.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Leopoldo&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Store variable in external flash at compile time</title><link>https://devzone.nordicsemi.com/thread/403869?ContentTypeID=1</link><pubDate>Mon, 09 Jan 2023 14:00:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb243f5d-e874-4c4f-a617-dfd57d025290</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Leopoldo&lt;/p&gt;
&lt;p&gt;Me and a colleague had a look at your code for a long while and in the end I think we got to a working stage, with a couple of caveats (I&amp;#39;ll get to that later).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The code we ended up with is this one:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1_5F00_7_5F00_1_5F00_code_5F00_relocation_5F00_modified_5F00_by_5F00_nordic.rar"&gt;devzone.nordicsemi.com/.../1_5F00_7_5F00_1_5F00_code_5F00_relocation_5F00_modified_5F00_by_5F00_nordic.rar&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I went back to the prj.conf configuration, and removed the zephyr_linker_sources line from CMakeLists.txt (only keeping the&amp;nbsp;zephyr_code_relocate line).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you look at the linker script I put back in the MEMORY portion, and also added a custom section below it that I named sound_data, in order to allow you to define these variables by referencing the section, rather than putting them in a specific file.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then I changed the variables to be declared using the section attribute, like this:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;const uint16_t __attribute__ ((section(&amp;quot;.sound_data&amp;quot;))) sound0[SOUND_LEN] = {1, 2, 3};&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Now you should technically be able to read these variables using XIP, like in the original example, but I would not recommend this as using XIP for reading data comes with some drawbacks. In particular you are unlikely to get very good power consumption in this case, since you won&amp;#39;t be able to disable the QSPI interface in between reads. Secondly, if you want to use DFU at any point to read and write DFU images to the external flash you won&amp;#39;t be able to combine this with XIP in the same project.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In other words I would strongly recommend just using the flash API to read out the variables instead.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In order to do this you simply need to declare the variables in a similar way, but&amp;nbsp;subtract the 0x10000000 XIP offset before issuing a read over the flash interface (since the local address in the flash starts at 0, not 0x10000000).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I wish I could provide a bit more context on some of the changes we ended up with, but as you might have picked up on we are sort of learning as we go here &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;br /&gt;Still, if you have any questions I will do my best to answer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you give the modified example a go and see if it works better?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please note that I didn&amp;#39;t implement the flash read mechanism in the example, you would need to add this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, it seems that flashing the XIP directly from VSCode does not work in v1.7.1. This means you need to manually flash the code from the command line using nrfjprog:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;nrfjprog --program zephyr.hex --sectorerase --verify&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;You might also need to manually erase the flash device:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;nrfjprog --qspieraseall&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Store variable in external flash at compile time</title><link>https://devzone.nordicsemi.com/thread/403684?ContentTypeID=1</link><pubDate>Sat, 07 Jan 2023 22:24:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cda95c02-ad5e-4ce8-95df-acd26c5457d1</guid><dc:creator>lbudde</dc:creator><description>&lt;p&gt;Hi &lt;span&gt;Torbj&amp;oslash;rn,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks a lot for verifying the correct location of the variables in code_relocation example sent.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="2116" url="~/f/nordic-q-a/95302/store-variable-in-external-flash-at-compile-time/403613"]I believe part of the issue is down to the ext_mem_init.c implementation, which configures the QSPI[/quote]
&lt;p&gt;I got the same problem when trying to adapt the code for SDK 1.7.1. I took a different approach for trying to skip that issue by enabling the QSPI flash at prj.conf with&amp;nbsp;&lt;strong&gt;CONFIG_NORDIC_QSPI_NOR&lt;/strong&gt;&lt;span&gt;&lt;strong&gt;=y&lt;/strong&gt;, and then getting device binding in main.c with&amp;nbsp;&lt;/span&gt;&lt;strong&gt;flash_dev = device_get_binding(FLASH_DEVICE&lt;/strong&gt;&lt;span&gt;&lt;strong&gt;)&lt;/strong&gt;&amp;nbsp;through Device Tree, I might messed up things a little bit, but basically I think I&amp;#39;m using the flash driver.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I attach this code, named 1_7_1_code_relocation inside the zip file, and basically project compiles, but variables are not correctly located in external flash, and I also get&amp;nbsp;&lt;strong&gt;warning: memory region `EXTFLASH&amp;#39; not declare&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:85px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x170/__key/communityserver-discussions-components-files/4/5518.vars_5F00_loc.PNG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;On the other hand, I took a different approach removing code_relocation usage, still using a custom LD file, and declaring const variables in the defined memory region with&amp;nbsp;&lt;/span&gt;&lt;strong&gt;__attribute__((section (&amp;quot;EXTFLASH&amp;quot;&lt;/strong&gt;&lt;span&gt;&lt;strong&gt;)))&lt;/strong&gt;, which according to the documentation is basically the same in a more &amp;quot;handmade&amp;quot; way, if I didn&amp;#39;t get it wrong (without considering XIP). This code is named 1_7_1_no_code_relocation in the attached zip.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;With this approach, variables seem to be correctly mapped, both at the zephyr.map file, and at the variables addresses being printed at console. BUT, the values declared for the variables are apparently not being stored. Should I be using the flash_read() API for getting this values, instead of just trying to access to them? Is this approach somehow wrong and shouldn&amp;#39;t be considered for declaring variables?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/vars_5F00_loc.PNG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/vars_5F00_values.PNG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here are both projects attached, in case you want to try them there, I think there may not be many differences between using SDK 1.7.1 and 1.8.0. One detail to consider is that I did a little mod in the QSPI Kconfig inside zephyr directory, which was recommended in a different and older thread here at the forum.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/8712.cap.PNG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1_5F00_7_5F00_1.rar"&gt;devzone.nordicsemi.com/.../1_5F00_7_5F00_1.rar&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks a lot for your time and patience, I&amp;#39;ll keep you updated if I make any progress.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Leopoldo&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Store variable in external flash at compile time</title><link>https://devzone.nordicsemi.com/thread/403613?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2023 14:30:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7916af94-1c7a-4ad1-99ed-af3faa39aa6e</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
[quote user="lbudde"]If it is not too much to ask, could you give it a quick look just to make sure that what I have just said is correct regarding data location?[/quote]
&lt;p&gt;Thanks for sharing the code. I tested it here and it seems to work very well in v2.2.0.&lt;/p&gt;
&lt;p&gt;I also verified that the data is written to the right place by reading the variables using nrfjprog:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;C:\WINDOWS\system32&amp;gt;nrfjprog --memrd 0x1000004e --n 32
0x1000004E: 0001 0002 0003 0000 0000 0000 0000 0000   |................|
0x1000005E: 0000 0000 0000 0000 0000 0000 0000 0000   |................|

C:\WINDOWS\system32&amp;gt;nrfjprog --memrd 0x10030d8e --n 32
0x10030D8E: 000B 000C 000D 0000 0000 0000 0000 0000   |................|
0x10030D9E: 0000 0000 0000 0000 0000 0000 0000 0000   |................|&lt;/pre&gt;&lt;/p&gt;
[quote user="lbudde"]I look forward to hear&amp;nbsp;any usefull info regarding this, and also mark your answers as verified, as code_relocation_nocopy seems to be working perfectly![/quote]
&lt;p&gt;I still haven&amp;#39;t heard back, and will need to follow this up next week.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried to build the sample in v1.8.0, which was the oldest version I had readily available, but was unable to get it working here unfortunately.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I believe part of the issue is down to the ext_mem_init.c implementation, which configures the QSPI interface correctly for XIP. I tried to change this to remove the references to pinctrl, and configure the pins in the config struct instead, but I was still unable to get the variables included in the flash (confirmed by reading the flash content using nrfjprog, showing that nothing was changed).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I also get some linker warnings during the build, so it might be more work to get this running in v1.7.1 than I hoped:&lt;pre class="ui-code" data-mode="text"&gt;c:/ncs/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe:\zephyr\linker_zephyr_prebuilt.cmd:77: warning: memory region `EXTFLASH&amp;#39; not declared
c:/ncs/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe:\zephyr\linker_zephyr_prebuilt.cmd:404: warning: redeclaration of memory region `EXTFLASH&amp;#39;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Again, I will have to investigate this further next week. If you have any progress on your end in the mean time just let me know.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Store variable in external flash at compile time</title><link>https://devzone.nordicsemi.com/thread/403492?ContentTypeID=1</link><pubDate>Thu, 05 Jan 2023 22:50:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d35e9f97-5e5b-49d6-88e7-a317dc6545fa</guid><dc:creator>lbudde</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn,&lt;/span&gt;&lt;/p&gt;
[quote userid="2116" url="~/f/nordic-q-a/95302/store-variable-in-external-flash-at-compile-time/403346"]Would using the &lt;a href="https://docs.zephyrproject.org/3.2.0/hardware/peripherals/flash.html"&gt;flash interface&lt;/a&gt; be an option?[/quote]
&lt;p&gt;That sounds good, I haven&amp;#39;t tried it yet because I got&amp;nbsp;a bit messed up between linker files and code relocation. I will check it out, thanks for the advice.&lt;/p&gt;
[quote userid="2116" url="~/f/nordic-q-a/95302/store-variable-in-external-flash-at-compile-time/403346"]For playing back data over I2S you will probably have to store the data temporarily in RAM anyway, since the I2S EasyDMA controller can not read data from external flash directly.&amp;nbsp;[/quote]
&lt;p&gt;Yes there is no problem in storing temporarily some data in buffers located in RAM, we can afford that between I2S interrupts.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;I downloaded nRF Connect SDK 2.1.1 and tested the code_relocation_nocopy, modified it a little bit to declare some const big arrays located in external flash, and everything seems to work fine, their address show they are effectively located in ext_flash, and they are accessible from main() application located in primary_flash. If it is not too much to ask, could you give it a quick look just to make sure that what I have just said is correct regarding data location?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;If that&amp;#39;s the case, I will stick to this approach as you suggested in your first response, and try to addapt it to our current nRF connect SDK 1.7.1 (otherwise I would have to migrate the complete project, which may take longer).&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="2116" url="~/f/nordic-q-a/95302/store-variable-in-external-flash-at-compile-time/403346"]I see that the example has changed, but I doubt there are any changes to the build system that would make it impossible to do something similar. I will check with the developers to be sure, and get back to you.[/quote]
&lt;p&gt;I look forward to hear&amp;nbsp;any usefull info regarding this, and also mark your answers as verified, as code_relocation_nocopy seems to be working perfectly!&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Thanks a lot for your help! &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f64c.svg" title="Raised hands"&gt;&amp;#x1f64c;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/code_5F00_relocation_5F00_nocopy_5F00_v2.rar"&gt;devzone.nordicsemi.com/.../code_5F00_relocation_5F00_nocopy_5F00_v2.rar&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Store variable in external flash at compile time</title><link>https://devzone.nordicsemi.com/thread/403346?ContentTypeID=1</link><pubDate>Thu, 05 Jan 2023 09:59:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8620a75f-38bd-402f-90ce-835bf1a91e7b</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Leopoldo&lt;/p&gt;
&lt;p&gt;Would using the &lt;a href="https://docs.zephyrproject.org/3.2.0/hardware/peripherals/flash.html"&gt;flash interface&lt;/a&gt; be an option?&lt;/p&gt;
&lt;p&gt;This is a relatively low level interface, but for reading arrays from external flash it should be more than sufficient.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For playing back data over I2S you will probably have to store the data temporarily in RAM anyway, since the I2S EasyDMA controller can not read data from external flash directly.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What you would lose compared to the custom linker script method is that you would need to find some other way to determine at which address the various sounds files are stored.&amp;nbsp;&lt;/p&gt;
[quote user="lbudde"]Do you know by any chance if there is any incompatibility between that example developed for the latest zephyr version, and older ones?[/quote]
&lt;p&gt;I see that the example has changed, but I doubt there are any changes to the build system that would make it impossible to do something similar. I will check with the developers to be sure, and get back to you.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Store variable in external flash at compile time</title><link>https://devzone.nordicsemi.com/thread/403044?ContentTypeID=1</link><pubDate>Tue, 03 Jan 2023 19:04:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e520ede-9c51-412d-ba0c-3835e949d566</guid><dc:creator>lbudde</dc:creator><description>&lt;p&gt;Hi &lt;span&gt;Torbj&amp;oslash;rn&lt;/span&gt;, thanks for the quick response!&lt;/p&gt;
&lt;p&gt;Actually the variables will be declared as const, they won&amp;#39;t need to be written during runtime, just defined at compile time and being read at runtime. The arrays represent short sound samples, which will be read and fed to I2S buffers, and they are just part of a sound bank that won&amp;#39;t be modified (unless in firmware updates, which will bring all the new arrays in the new binary file, but that&amp;#39;s a sepparate issue).&lt;/p&gt;
&lt;p&gt;For example, our sounds.h header file (or sounds.c source file) will have multiple arrays as the next one:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;stdio.h&amp;gt;

const int16_t sound0[16000] = {-7, 4, 2, -2, -1, 9, 4, 9, 11, 10, 10, 10, 13, 
0, 0, 1, -1, 0, -6, -3, 3, 10, 11, 9, 12, 15, 9, 13, 17, 17, 7, 2, 1, 0, 6, -4,
5, 8, 13, 10, 14, 15, 14, 16, 13, 16, 6, 8, 7, 1, 3, 6, 8, 3, 13, 5, 6, 5, 6, 10, 
10, 13, 12, 14, 8, 13, 4, 7, 15, 11, 7, 24, 13, 21, 17, 11, 7, 2, 5, 3, 0, 0, 2, 
-5, -3, -3, -1, 5, 9, 11, 16, 17, 7, 11, 10, 6, 2, -2, -1, 6, -8, -1, 3, -2, -4,
2, 6, 18, -11, 27, -42, 72, -114, 194, -957, -286, -2293, -4880, -8960, -10727,
-11669, -14586, -15099, -17268, -18830, -20997, -22886, -22972, -22922, -25502, 
-26030, -25494, -25707, -25618 ...&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So I will take a close look at the code_relocation_nocopy you suggested. The only annoying detail is that we are working with NRF Connect SDK 1.7.1, which is based on zephyr 2.6. Do you know by any chance if there is any incompatibility between that example developed for the latest zephyr version, and older ones?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not allowed to share the complete project, but I will prepare a simplified version that I can post here, and try to modify it based on your suggested example. I&amp;#39;ll be back in a few days with the code, thank you very much!&lt;/p&gt;
&lt;p&gt;Leopoldo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Store variable in external flash at compile time</title><link>https://devzone.nordicsemi.com/thread/402968?ContentTypeID=1</link><pubDate>Tue, 03 Jan 2023 13:41:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b17cc82-024c-4bb4-bd62-b92d03c030d4</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Leopoldo&lt;/p&gt;
&lt;p&gt;It should be possible to modify the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/main/samples/application_development/code_relocation_nocopy"&gt;code_relocation_nocopy&lt;/a&gt; example to store const variables in external flash that can be easily accessed from the application, but I don&amp;#39;t think this will work so well if you need to write to the variable as well.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How are you writing to the variable in your example?&lt;/p&gt;
&lt;p&gt;How often are you planning to write to the variable during normal operation?&lt;/p&gt;
&lt;p&gt;Would you be willing to share your project with me so I can try to reproduce the issue?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>