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

Adding fstorage functionality to project

Good day.

I am trying to add flash storage functionality to a project based on the ANT asynchronous transmitter example and the ANT back ground channel example of the SDK v16.0.0. That using the softdevice s340. My setup consist of a computer running windows 7, and I am using SEGGER to program the development kit. With the flash_fstorage example as a guideline I have performed the following actions in my project:

include the libraries:

      - nrf_fstorage.h

      - nrf_fstorage_sd.h

include the files on the folder nRF_Libraries

      - nrf_fstorage.c

      - nrf_fstorage_sd.c

add the path to user include directories in the project common configuration

      ../../../../../../components/libraries/fstorage

and finally I added the fstorage configuration to the sdk_config.h file.

// <e> NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library
//==========================================================
#ifndef NRF_FSTORAGE_ENABLED
#define NRF_FSTORAGE_ENABLED 1
#endif
// <h> nrf_fstorage - Common settings

// <i> Common settings to all fstorage implementations
//==========================================================
// <q> NRF_FSTORAGE_PARAM_CHECK_DISABLED  - Disable user input validation
 

// <i> If selected, use ASSERT to validate user input.
// <i> This effectively removes user input validation in production code.
// <i> Recommended setting: OFF, only enable this setting if size is a major concern.

#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED
#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0
#endif

// </h> 
//==========================================================

// <h> nrf_fstorage_sd - Implementation using the SoftDevice

// <i> Configuration options for the fstorage implementation using the SoftDevice
//==========================================================
// <o> NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations 
// <i> Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM.

#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE
#define NRF_FSTORAGE_SD_QUEUE_SIZE 4
#endif

// <o> NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy 
// <i> Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error.
// <i> The SoftDevice might fail to schedule flash access due to high BLE activity.

#ifndef NRF_FSTORAGE_SD_MAX_RETRIES
#define NRF_FSTORAGE_SD_MAX_RETRIES 8
#endif

// <o> NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation 
// <i> This value must be a multiple of four.
// <i> Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity.
// <i> This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write.
// <i> That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs.

#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE
#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096
#endif

This last step produced various unexpected compilation errors

When I compile I get the following output:

Compiling ‘nrf_sortlist.c’
Compiling ‘nrf_strerror.c’
Compiling ‘nrf_queue.c’
Compiling ‘nrf_fstorage.c’
Compiling ‘nrf_drv_uart.c’
Compiling ‘nrf_fstorage_sd.c’
sdk_common.h
nrf_fstorage_sd.c
    'NRF_SDH_SOC_ENABLED' undeclared here (not in a function); did you mean 'NRF_SDH_LOG_ENABLED'?
    in definition of macro '_SELECT_ASSERT_FUNC'
    in expansion of macro 'STATIC_ASSERT_MSG'
    in expansion of macro 'STATIC_ASSERT'
    in expansion of macro 'NRF_SDH_SOC_OBSERVER'
    expression in static assertion is not an integer
    in definition of macro '_SELECT_ASSERT_FUNC'
    in expansion of macro 'STATIC_ASSERT_MSG'
    in expansion of macro 'STATIC_ASSERT'
    in expansion of macro 'NRF_SDH_SOC_OBSERVER'
    'NRF_SDH_SOC_OBSERVER_PRIO_LEVELS' undeclared here (not in a function); did you mean 'NRF_SDH_STACK_OBSERVER_PRIO_LEVELS'?
    in definition of macro '_SELECT_ASSERT_FUNC'
    in expansion of macro 'STATIC_ASSERT_MSG'
    in expansion of macro 'STATIC_ASSERT'
    in expansion of macro 'NRF_SDH_SOC_OBSERVER'
    expression in static assertion is not an integer
    in definition of macro '_SELECT_ASSERT_FUNC'
    in expansion of macro 'STATIC_ASSERT_MSG'
    in expansion of macro 'STATIC_ASSERT'
    in expansion of macro 'NRF_SDH_SOC_OBSERVER'
  Compiling ‘nrfx_atomic.c’
  Compiling ‘nrfx_gpiote.c’
Build failed

Any Idea on how to solve this?

Parents Reply Children
  • Hi,

    Thank you Amanda, that worked.

    I'll take the opportunity to make a question unrelated to the previous topic. I have tried different methods of power supply on the nRF52840 DK. I noticed that when I use the Vin pin (3-5V) to supply the board the current consumption increases considerably. When I change the supply from external supply, on pin 21, to supply on the Vin pin, the current goes from 9uA in sleep mode to around 400uA. I noticed that when supplying on Vin, VDD voltage is regulated to 3.0V, is this the cause of the increment of power consumption?

  • Great to hear that worked. 

    Please create a new ticket for this, as it will be easier for future users with similar problems to find the tickets if they consist of one issue each.

    Please also kindly verify the answer to benefit other users. Thanks. Slight smile

    -Amanda H.

Related