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

fstorage page info

I am attempting to integrate examples/peripheral/flash_fstorage into my project (SDK 14.1.0).

When calling nrf_fstorage_write I get NRF_ERROR_INVALID_LENGTH in response. I assume because I am only trying to write 20 bytes not ~2K. However, for some reason the example can write m_hello_world which is only a handful of bytes. Additionally, a minimum erase size of 536MiB seems too large to be correct. Diffing the example sdk_config.h with the default didn't reveal anything interesting I could change.

nrf5_flash_end_addr_get returns 1048576 (dec?) AKA 0x10000.

print_flash_info displays the following:

erase unit: 536871936 bytes

program unit: 2277 bytes

Any help on why the minimums are so large would be appreciated. Thanks.

Parents
  • The program unit should be the word size, which is 4 bytes. The length has to be a multiple of 4 bytes, like the length of m_hello_world.

    Edit 29.11.2017:

    This is a bug. The fix is (as you figured out) to put p_fs->p_flash_info = &m_flash_info; before the if in the init function of nrf_fstorage_sd.c

    This will be fixed in the next SDK release.


  • #include <app_error.h>
    #include <nrf_fstorage.h>                                                                                                                                                         
    #include <nrf_fstorage_sd.h>                                                                                                                                                      
    #include <nrf_soc.h>
    
    #define ETH_FLASH_START 0x3e000                                                                                                                                     
    #define ETH_FLASH_END   0x3ffff
     
    static void fstorage_evt_handler(nrf_fstorage_evt_t * p_evt);
    
    NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =                                                                                                                                       
      {                                                                                                                                                                                 
          /* Set a handler for fstorage events. */                                                                                                                                      
          .evt_handler = fstorage_evt_handler,                                                                                                                                          
                                                                                                                                                                                        
          /* These below are the boundaries of the flash space assigned to this instance of fstorage.                                                                                   
           * You must set these manually, even at runtime, before nrf_fstorage_init() is called.                                                                                        
           * The function nrf5_flash_end_addr_get() can be used to retrieve the last address on the                                                                                     
           * last page of flash available to write data. */                                                                                                                             
          .start_addr = ETH_FLASH_START,                                                                                                                                                
       };
    
    void main() {
    ...
    ret_code_t rc;
          rc = nrf_fstorage_init(&fstorage, &nrf_fstorage_sd, NULL);
          APP_ERROR_CHECK(rc);
    ...
    }
    
Reply

  • #include <app_error.h>
    #include <nrf_fstorage.h>                                                                                                                                                         
    #include <nrf_fstorage_sd.h>                                                                                                                                                      
    #include <nrf_soc.h>
    
    #define ETH_FLASH_START 0x3e000                                                                                                                                     
    #define ETH_FLASH_END   0x3ffff
     
    static void fstorage_evt_handler(nrf_fstorage_evt_t * p_evt);
    
    NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =                                                                                                                                       
      {                                                                                                                                                                                 
          /* Set a handler for fstorage events. */                                                                                                                                      
          .evt_handler = fstorage_evt_handler,                                                                                                                                          
                                                                                                                                                                                        
          /* These below are the boundaries of the flash space assigned to this instance of fstorage.                                                                                   
           * You must set these manually, even at runtime, before nrf_fstorage_init() is called.                                                                                        
           * The function nrf5_flash_end_addr_get() can be used to retrieve the last address on the                                                                                     
           * last page of flash available to write data. */                                                                                                                             
          .start_addr = ETH_FLASH_START,                                                                                                                                                
       };
    
    void main() {
    ...
    ret_code_t rc;
          rc = nrf_fstorage_init(&fstorage, &nrf_fstorage_sd, NULL);
          APP_ERROR_CHECK(rc);
    ...
    }
    
Children
No Data
Related