I have a use for the pstorage module and while going over the implementations in the Nordic examples and libraries, I found a use-case of pstorage_register() in bootloader_init() (SDK11, file "nRF52_SDK\components\libraries\bootloader_dfu\bootloader.c").
Here's the relevant code:
uint32_t bootloader_init(void)
{
uint32_t err_code;
pstorage_module_param_t storage_params = {.cb = pstorage_callback_handler};
//
err_code = pstorage_init();
VERIFY_SUCCESS(err_code);
//
m_bootsettings_handle.block_id = BOOTLOADER_SETTINGS_ADDRESS;
err_code = pstorage_register(&storage_params, &m_bootsettings_handle);
return err_code;
}
I was looking into the pstorage docs and there are 2 things I do not understand:
- According to the API spec, the second argument is an output parameter BUT, "bootloader_init()" is setting the "block_id" parameter.
- For the first argument, the parameters "block_size" and "block_count" are not configured before calling register.
"dfu_init()" does something similar.
I am confused... Am I looking at this the wrong way?
Cheers, Dirk