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

how to read the data from flashstorage which is written in flash

Hi folks,

I am working on ble_app_uart example program nRF52 SDK 15.2 Verion , in this case i am writing the data in flash for future use , Now i am to get the specific  data from flash, how to do that? 

guide me 

  • char *name[80]="hello";
      char newname[80];
        rc = nrf_fstorage_write(&fstorage, 0x3f000, name, sizeof(name), NULL);
        APP_ERROR_CHECK(rc);
        
          printf("Write data \"%s\" to flash.\n", name);
    
    
     
        rc = nrf_fstorage_read(&fstorage, 0x3f000,&newname, sizeof(newname));
        APP_ERROR_CHECK(rc);
      printf("read data \"%s\" to flash.\n", &newname);
    
        wait_for_flash_ready(&fstorage);

    In this above case, i can't able to print the read data , tell me if  i have done any mistake. my code is correct or not 

  • Hi

    Are you able to see any output at all on the terminal you're printing to? Is the problem that you're trying to print a string when name and newname are characters and not strings? You can add a loop to see if the operations succeed as well using an if loop like this, so that the application only prints if the operation was a success, and handles the error/ prints the error code if not.

    if (rc == NRF_SUCCESS)
    {
        /* The operation was accepted.
           Print your data            */
        
    }
    else
    {
        /* Handle error.*/
    }

    Best regards,

    Simon

Related