This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Flash Address change issue in nRF connect SDK

Hi,

I need to store the 1kB of data in the flash storage and it need to be read anytime and change the data anywhere.

I am using nrf52840 DK and also nrf5340 DK to perform these Flash storage

I found the example code in this link

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/storage/nvs/nvs.html?highlight=flash%20storage

and i have tested the code.

I have difficulty to change the data storage address. where we need to change the starting address. size of flash storage. If i use DFU how to assign the flash storage

I have checked this and print the info value

but I tried to change the value but it not write the given address

/cfs-file/__key/communityserver-discussions-components-files/4/6646.pastedimage1622046017015v1.png

/cfs-file/__key/communityserver-discussions-components-files/4/0383.pastedimage1622046034387v2.png

Did i need to change any thing ?

Parents Reply Children
  • Hi Håkon,

    from nRF52840

    reg = <0x000f8000 0x00008000>;

    f8000 - flash start address

    8000 - flash storage size

    isn't it ?

    and during addition of DFU Bootloader how do i measure and change the flash address

  • Hi,

     

    Sunil vignesh said:
    isn't it ?

    Yes, that is true. 

     

    Sunil vignesh said:
    and during addition of DFU Bootloader how do i measure and change the flash address

    Do you really want to change the address of the storage_partition? This will make the layout of the images differ, which is normally not a wanted scenario.

    Kind regards,

    Håkon 

  • Hi ,

    I found this lines in nrf52dk_nrf52832.dts

    boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x00000000 0xc000>;
    		};
    		slot0_partition: partition@c000 {
    			label = "image-0";
    			reg = <0x0000C000 0x32000>;
    		};
    		slot1_partition: partition@3e000 {
    			label = "image-1";
    			reg = <0x0003E000 0x32000>;
    		};
    		scratch_partition: partition@70000 {
    			label = "image-scratch";
    			reg = <0x00070000 0xa000>;
    		};
    		storage_partition: partition@7a000 {
    			label = "storage";
    			reg = <0x0007a000 0x00006000>;
    		};

    there it show the

    storage_partition: partition@7a000 {
                label = "storage";
                reg = <0x0007a000 0x00006000>;
            };

    if 0x7a000 then what is 0x00006000  (storage size?) how it calculate in kB.

    and if i change the start address from 0x7a000 to 0x7000 then what will be the storage size .

    My case i need to store the

    1. Bond state PM address

    2. 1 KB (Kilo Byte) sensor data

    3. 2 KB second sensor data

  • Hi,

     

    Sunil vignesh said:
    if 0x7a000 then what is 0x00006000  (storage size?) how it calculate in kB.

    0x7a000 is the start address, and 0x6000 is the size (1 page = 4k (0x1000), thus 6 flash pages). 

    Convert to decimal, and you will get the amount of bytes available in the given partition.

     

    Sunil vignesh said:

    and if i change the start address from 0x7a000 to 0x7000 then what will be the storage size .

     It will be out-of-bounds. you will go outside of the total flash area of the nRF52832.

     

    Kind regards,

    Håkon

  • Hi Håkon,

    Thanks for the fast response.

    I have one last question

    I worked in nRF5 SDK flash_fstorage

    int8_t mas[12];
          for (int i = 0; i<12; i++)
          {
              mas[i] = i+1;
          }
          /* Let's write to flash. */
          NRF_LOG_INFO("Writing \"%x\" to flash.", mas);
          rc = nrf_fstorage_write(&fstorage, 0x3f500, &mas, sizeof(mas), NULL);
          APP_ERROR_CHECK(rc);
    
          wait_for_flash_ready(&fstorage);
          NRF_LOG_INFO("Done.");
        
        NRF_LOG_INFO("Writing \"%s\" to flash.", m_hello_world);
        rc = nrf_fstorage_write(&fstorage, 0x3f000, m_hello_world, sizeof(m_hello_world), NULL);
        APP_ERROR_CHECK(rc);
    

    Like this

    How can I write the array of data in the particular address

    example

    Storage partition
    Flash start : 0x7a000

    Flash size : 0x0006000


    i want to write the int8_t arr[1000]; to the particular 0x7b000

    How can i assign 0x7b000 to write the array data

    In nrf connect sdk

    #define ADDRESS_ID 1
    #define KEY_ID 2
    #define RBT_CNT_ID 3
    #define STRING_ID 4
    #define LONG_ID 5
    
    
    
    	/* ADDRESS_ID is used to store an address, lets see if we can
    	 * read it from flash, since we don't know the size read the
    	 * maximum possible
    	 */
    	rc = nvs_read(&fs, ADDRESS_ID, &buf, sizeof(buf));
    	if (rc > 0) { /* item was found, show it */
    		printk("Id: %d, Address: %s\n", ADDRESS_ID, buf);
    	} else   {/* item was not found, add it */
    		strcpy(buf, "192.168.1.1");
    		printk("No address found, adding %s at id %d\n", buf,
    		       ADDRESS_ID);
    		(void)nvs_write(&fs, ADDRESS_ID, &buf, strlen(buf)+1);
    	}

    How the Address_ID 1 

    this 1 2 3 4 5  are noting Pages or any other how the address is assigned

Related