<?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>Writing uint64_t on a specific memory address.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/115088/writing-uint64_t-on-a-specific-memory-address</link><description>Hello all, 
 i need to save uint64_t in to a specific memory address. 
 in main. c 
 
 i have create my .ld file named: my_memory.ld 
 
 
 i have edited CMakeList.txt as follow: 
 
 but when i build the project i can not see in zephyr.hex the number that</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 Oct 2024 14:45:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/115088/writing-uint64_t-on-a-specific-memory-address" /><item><title>RE: Writing uint64_t on a specific memory address.</title><link>https://devzone.nordicsemi.com/thread/506175?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2024 14:45:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30d8a0ac-c704-4986-b605-bfe796be92a7</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;Here&amp;#39;s the partition manager documentation:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.6.2/page/nrf/scripts/partition_manager/partition_manager.html#configuring_static_partitions"&gt;https://docs.nordicsemi.com/bundle/ncs-2.6.2/page/nrf/scripts/partition_manager/partition_manager.html#configuring_static_partitions&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: Writing uint64_t on a specific memory address.</title><link>https://devzone.nordicsemi.com/thread/506173?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2024 14:37:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2261e593-fcd2-43c4-90a0-773cccd03e75</guid><dc:creator>Epasta</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;can you provide me a sample or documentation?&lt;br /&gt;This is very unclear fo me.&lt;/p&gt;
&lt;p&gt;thanks&lt;br /&gt;best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing uint64_t on a specific memory address.</title><link>https://devzone.nordicsemi.com/thread/506172?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2024 14:29:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b89cffb-090b-4929-8d77-978a67fae9a8</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;You should use the original&amp;nbsp;build folders build/&lt;span&gt;partitions&lt;/span&gt;.yml as a static layout for future DFU images.&lt;/p&gt;
&lt;p&gt;This means that you shall copy the original_project/build-folder/&lt;span&gt;partitions.yml to my_updated_project/pm_static.yml to keep the original static partition layout.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&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;Håkon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing uint64_t on a specific memory address.</title><link>https://devzone.nordicsemi.com/thread/506067?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2024 10:33:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e67de511-0fab-4d59-a090-900869e7b16d</guid><dc:creator>Epasta</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;it is difficult that can change but could be.&lt;/p&gt;
&lt;p&gt;I did it with overlay file and it works perfectly how I would like.&lt;/p&gt;
&lt;p&gt;Now I have enabled ota, but overlay file it does not work anymore. &lt;br /&gt;Which is the correct file now to handle?&lt;/p&gt;
&lt;p&gt;I read that i have to change pm_static.yml but i doesn&amp;#39;t have this file in my project.&lt;br /&gt;I tried to change partitions.yml but when I build it come back to default.&lt;/p&gt;
&lt;p&gt;can you help me?&lt;/p&gt;
&lt;p&gt;Thanks again for your time.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing uint64_t on a specific memory address.</title><link>https://devzone.nordicsemi.com/thread/504365?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2024 12:54:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1263ebf-1467-4191-9141-4e5467257cc9</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;It is unclear to me if this variable/number can change or not, based on your description.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you cannot use UICR, then I would recommend the settings subsys, or set aside a specific page/section for your user-specified data at the end of 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: Writing uint64_t on a specific memory address.</title><link>https://devzone.nordicsemi.com/thread/504361?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2024 12:34:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:107de440-c7aa-468f-b608-98b9a59aa115</guid><dc:creator>Epasta</dc:creator><description>&lt;p&gt;No, I do not need to be able to erase and re-write &amp;quot;my_id_number&amp;quot;.&lt;br /&gt;I just need to set it one time, keep it in a specific memory address and read it every time at power on.&lt;/p&gt;
&lt;p&gt;It can happens that this number could be change in the future.&amp;nbsp;&lt;span&gt;UICR.OTP[] is not good for us.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Can you provide me a sample?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing uint64_t on a specific memory address.</title><link>https://devzone.nordicsemi.com/thread/504324?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2024 10:31:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bae1f104-5fc3-492b-9a14-c2d464c30ddb</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;Using a linker script to place a variable at a absolute address is possible, but you have to be aware that the linker does not handle fragmentation well. For example, if you place a var inside a region, such as &amp;quot;FLASH&amp;quot;, the linker will not split up the region and handle any gaps in address space.&lt;/p&gt;
&lt;p&gt;The recommendation if you need to both read and write to a region is to place the region at the end of your flash layout, and address it.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you need to be able to erase and re-write the &amp;quot;my_id_number&amp;quot;? If not, I would then recommend to look at the UICR.OTP[] area for storing a specific ID.&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: Writing uint64_t on a specific memory address.</title><link>https://devzone.nordicsemi.com/thread/504323?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2024 10:10:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cde571b0-0332-41ab-9d78-e8fe236fde48</guid><dc:creator>Epasta</dc:creator><description>&lt;p&gt;Hello all,&lt;/p&gt;
&lt;p&gt;i have edited main.c like follow:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;void write_memory_id_number_(void){
    const struct device *flash_id;
    struct flash_area *fa;
    uint64_t my_id_number = 0x1500080507032592;
    uint64_t data_read;
    int rc;
    
    /*DON&amp;#39;T REMOVE THE COMMENTS HERE BELOW... IT WILL NOT WORK*/
    /*flash_id = device_get_binding(&amp;quot;flash_id_number&amp;quot;);
    if (!flash_id) {
        printk(&amp;quot;Error\n&amp;quot;);
        return;
    }*/

    rc = flash_area_open(FLASH_AREA_ID(flash_id_number), &amp;amp;fa);
    if (rc != 0) {
        printk(&amp;quot;Error flash_id_number: %d\n&amp;quot;, rc);
        return;
    }

    rc = flash_area_erase(fa, 0, fa-&amp;gt;fa_size);
    if (rc != 0) {
        printk(&amp;quot;Error flash_id_number: %d\n&amp;quot;, rc);
        flash_area_close(fa);
        return;
    }

    rc = flash_area_write(fa, 0, &amp;amp;my_id_number, sizeof(my_id_number));
    if (rc != 0) {
        printk(&amp;quot;Errore flash_id_number: %d\n&amp;quot;, rc);
    } 

    rc = flash_area_read(fa, 0, &amp;amp;data_read, sizeof(data_read));
    if (rc != 0) {
        printk(&amp;quot;Error: %d\n&amp;quot;, rc);
    } else if (data_read == my_id_number) {
        printk(&amp;quot;OK \n&amp;quot;);
    } else {
        printk(&amp;quot;Error:  0x%x no equals to 0x%x\n&amp;quot;, data_read, my_id_number);
    }

    flash_area_close(fa);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;edited .overlay file like follow:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;    partitions {
        compatible = &amp;quot;fixed-partitions&amp;quot;;
        #address-cells = &amp;lt; 0x1 &amp;gt;;
        #size-cells = &amp;lt; 0x1 &amp;gt;;
        boot_partition: partition@0 {
            label = &amp;quot;mcuboot&amp;quot;;
            reg = &amp;lt; 0x0 0xc000 &amp;gt;;
        };
        slot0_partition: partition@c000 {
            label = &amp;quot;image-0&amp;quot;;
            reg = &amp;lt; 0xc000 0x75000 &amp;gt;;
        };

        flash_id_number: partition@81000 {
            label = &amp;quot;flash_id_number&amp;quot;;
            reg = &amp;lt; 0x81000 0x1000 &amp;gt;;
        };
        slot1_partition: partition@82000 {
            label = &amp;quot;image-1&amp;quot;;
            reg = &amp;lt; 0x82000 0x76000 &amp;gt;;
        };
        storage_partition: partition@f8000 {
            label = &amp;quot;storage&amp;quot;;
            reg = &amp;lt; 0xf8000 0x8000 &amp;gt;;
        };
    };&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I can save data in flash file. But if i change memory address doesn&amp;#39;t on hex file.&amp;nbsp;&lt;br /&gt;It is correct what i do?&lt;br /&gt;Where I&amp;#39;m wrong?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing uint64_t on a specific memory address.</title><link>https://devzone.nordicsemi.com/thread/504279?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2024 07:07:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b56bc52-774f-4303-b4bf-f75bee34240b</guid><dc:creator>Epasta</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think I will use .overlay file, but, is there a guide that show how change the memory in .overlay file?&lt;br /&gt;Do you have an example?&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing uint64_t on a specific memory address.</title><link>https://devzone.nordicsemi.com/thread/504248?ContentTypeID=1</link><pubDate>Sat, 28 Sep 2024 08:36:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1e9fbb8-1c58-4ab4-b56b-0b602e65d295</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Use either partiton manager or DTS (device tree overlay) if you don&amp;#39;t use a bootloader. These allow modifications to code size and locations.&lt;/p&gt;
&lt;p&gt;There is a config option that enables the linker to use the dts information for code size+location, but IIRC it only works when bootloader was not enabled.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>