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

Hi the flash_fstorage example isn't working properly as expected.

I am running read str 0x3e000 12 via UART line but there is nothing which gets printed on the terminal.

Even if i write some hex value to a particular flash memory location and read that also the data is completely different

Parents
  • Hi,

    I am running read str 0x3e000 12 via UART line but there is nothing which gets printed on the terminal.

     Does the program interpret it as a read command? Try setting a breakpoint in read_cmd()  and see if the program enters the read function. 

     

    Even if i write some hex value to a particular flash memory location and read that also the data is completely different

     But something is actually read? Are you using a completely unmodified example?

    regards

    Jared 

  • Yes i haven't modified anything in the example

  • How are you sending the commands via Uart? Is the board connected to a PC? If the example is unmodified then the fault most probably relies in how you give the input or receive the output.

    Also, please answer this:

     

    Jared said:

     Does the program interpret it as a read command? Try setting a breakpoint in read_cmd()  and see if the program enters the read function. 

     

    Even if i write some hex value to a particular flash memory location and read that also the data is completely different

     But something is actually read? Are you using a completely unmodified example?

Reply
  • How are you sending the commands via Uart? Is the board connected to a PC? If the example is unmodified then the fault most probably relies in how you give the input or receive the output.

    Also, please answer this:

     

    Jared said:

     Does the program interpret it as a read command? Try setting a breakpoint in read_cmd()  and see if the program enters the read function. 

     

    Even if i write some hex value to a particular flash memory location and read that also the data is completely different

     But something is actually read? Are you using a completely unmodified example?

Children
  • Hi Jared,

    I am writing 0x11 in memory location 0x3e000 as you can see in the below code snippet, but when i see in the memory browser the data isn't written

    int main(void)
    {
        ret_code_t rc;
    
    #ifndef SOFTDEVICE_PRESENT
        clock_init();
    #endif
    
        timer_init();
        log_init();
        cli_init();
    
        NRF_LOG_INFO("fstorage example started.");
    
        nrf_fstorage_api_t * p_fs_api;
    
    #ifdef SOFTDEVICE_PRESENT
        NRF_LOG_INFO("SoftDevice is present.");
        NRF_LOG_INFO("Initializing nrf_fstorage_sd implementation...");
        /* Initialize an fstorage instance using the nrf_fstorage_sd backend.
         * nrf_fstorage_sd uses the SoftDevice to write to flash. This implementation can safely be
         * used whenever there is a SoftDevice, regardless of its status (enabled/disabled). */
        p_fs_api = &nrf_fstorage_sd;
    #else
        NRF_LOG_INFO("SoftDevice not present.");
        NRF_LOG_INFO("Initializing nrf_fstorage_nvmc implementation...");
        /* Initialize an fstorage instance using the nrf_fstorage_nvmc backend.
         * nrf_fstorage_nvmc uses the NVMC peripheral. This implementation can be used when the
         * SoftDevice is disabled or not present.
         *
         * Using this implementation when the SoftDevice is enabled results in a hardfault. */
        p_fs_api = &nrf_fstorage_nvmc;
    #endif
    
        rc = nrf_fstorage_init(&fstorage, p_fs_api, NULL);
        APP_ERROR_CHECK(rc);
    
        print_flash_info(&fstorage);
    
        /* It is possible to set the start and end addresses of an fstorage instance at runtime.
         * They can be set multiple times, should it be needed. The helper function below can
         * be used to determine the last address on the last page of flash memory available to
         * store data. */
        (void) nrf5_flash_end_addr_get();
        uint8_t m_data = 0x11;
        /* Let's write to flash. */
        NRF_LOG_INFO("Writing \"%x\" to flash.", m_data);
        rc = nrf_fstorage_write(&fstorage, 0x3e000, &m_data, sizeof(m_data), NULL);
        APP_ERROR_CHECK(rc);
    

  • Manoj S said:
    Yes i haven't modified anything in the example

     This contradicts with this:

    Manoj S said:
    I am writing 0x11 in memory location 0x3e000 as you can see in the below code snippet,

    Could you just try running the example without any modifications. Are you able to read and write then? Before modifying it, you should be sure that you're able to run and test the unmodified example. And again:

    Jared said:
    How are you sending the commands via Uart? Is the board connected to a PC?

    regards

    Jared 

Related