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

pstorage_store not invoking callback function

I am able to use pstorage_clear and pstorage_load without any problems, but whenever I try to do a pstorage_store the callback function is not being invoked. This problem occurs regardless of the current state of the Bluetooth module--idle, advertising, or connected.

Parents
  • Just added this to potentially help out someone else who may have had this problem. It turns out that pstorage_store actually checks whether the source data (the stuff you're saving to FLASH) and even the offset (passed as the last parameter to the function) are word aligned.

    The problem turned out that my source buffer was inside of a structure:

    typedef struct { pstorage_handle_t blockBase; pstorage_handle_t cBlock; pstorage_handle_t waitBlock; bool wait; uint8_t state; uint8_t buffer[NVRAM_BLOCK_SIZE]; } nvram_t;

    I don't know why the pstorage_store function cares whether or not the source data is word aligned as long as the destination will be word aligned, but apparently it does. Pstorage_store was actually returning the error NRF_ERROR_INVALID_ADDR. Searching around this devzone I found the changing: uint8_t buffer[NVRAM_BLOCK_SIZE]; to: uint8_t buffer[NVRAM_BLOCK_SIZE] attribute((aligned(4)));

    made everything work.

Reply
  • Just added this to potentially help out someone else who may have had this problem. It turns out that pstorage_store actually checks whether the source data (the stuff you're saving to FLASH) and even the offset (passed as the last parameter to the function) are word aligned.

    The problem turned out that my source buffer was inside of a structure:

    typedef struct { pstorage_handle_t blockBase; pstorage_handle_t cBlock; pstorage_handle_t waitBlock; bool wait; uint8_t state; uint8_t buffer[NVRAM_BLOCK_SIZE]; } nvram_t;

    I don't know why the pstorage_store function cares whether or not the source data is word aligned as long as the destination will be word aligned, but apparently it does. Pstorage_store was actually returning the error NRF_ERROR_INVALID_ADDR. Searching around this devzone I found the changing: uint8_t buffer[NVRAM_BLOCK_SIZE]; to: uint8_t buffer[NVRAM_BLOCK_SIZE] attribute((aligned(4)));

    made everything work.

Children
No Data
Related