I am writing a library for Nordic nrf52832 and it uses some of the functionality from fstorage (fstorage_nvmc implementation) to access the NVM. The library creates only one instance of fstorage from the start_addr of 0x0 to the end addr of 0x80000. This library should be able to write any where on the flash space (512kb)
The issue is when I create an instance of fstorage and compile, everything works fine. But when I run and debug the code, I see that the fstorage instance that I created (fstorage_instance) doesn't have the correct values for .start_addr and .end_addr. Both of these values are 0x0 instead of 0x0 and 0x80000. As a matter of fact, the whole fstorage_instance is 0x0. It seems like it never got initialized using the NRF_FSTORAGE_DEF macro.
The project that I am using my library in does not have a main function.It is an interrupt driven bootloader.
If I copy this same library to an example in the SDK14.2, let's say, peripheral/blinky/, the fstorage instance has the correct addresses and works fine.
What could be the issue here that the instance does not get initialized with the NRF_FSTORAGE_DEF macro? Is it because I don't have a main and I can't statically initialize it? Is it some other build configuration that needs to be present for the NRF_FSTORAGE_DEF macro to properly initialize the fstorage_instance.
I am using:
nrf52832 with SDK14.2 and nrf_fstorage_nvmc implementation. There is no SoftDevice present.
My nvmlibrary.c file looks something like this:
nvmlibrary.c //some include files #include "nrf_fstorage.h" #include "nrf_fstorage_nvmc.h" #include "nrf_nvmc.h" //create an fstorage instance //the library only uses one fstorage instance NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage_instance) = { /* Set a handler for fstorage events. */ .evt_handler = NULL, /* These below are the boundaries of the flash space assigned to this instance of fstorage.*/ .start_addr = 0x0, .end_addr = 0x80000, }; void NvmFunc1(){ ...}