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

flash memory with different parameter

hi:

In my extent application, I would like to save other data which is got from BLE to flash memory with different parameter(block size, block count) using pstorage. Could you please show me how to config for the memory?

1:just one pstorage_init() right?

2:and two pstorage_register() for Device Manager and My Application.

3:If I use just one page. (PSTORAGE_NUM_OF_PAGES = 1) what happened? two module in one page?

4:or, I need to make PSTORAGE_NUM_OF_PAGES = 2, so Device Manager and My application have 1 page each.

5:like this is right?

void my_flash_init(void){
uint32_t err_code;
pstorage_module_param_t param;
param.block_count = 1;
param.block_size = NAME_SIZE;
param.cb = my_cb;
err_code = pstorage_init();
err_code = pstorage_register(&param, &my_name_addr);
err_code = pstorage_load(device_name, &my_name_addr, NAME_SIZE, 0);

}
 void my_data_init(void)
{
uint32_t err_code;
pstorage_module_param_t param;
param.block_count = 1;
param.block_size = DATA_SIZE;
param.cb = my_data_cb;
//     err_code = pstorage_init();
err_code = pstorage_register(&param, &my_data_addr);
err_code = pstorage_load(device_name, &my_name_addr, NAME_SIZE, 0);

}

Thank you very much!!!

  • Hello micele

    You can find the documentation regarding pstorage here, you should find the answers to all of your questions there.

    To summarize

    1. Yes

    2. Yes, the device manager registers during when you call dm_init(), you need to register your application code separately.

    3. The number of pages are the total number of physical flash pages the pstorage module is allowed to work with, in addition to the swap page. Each page is then divided into blocks, and the blocks are allocated to the different users. The amount of memory given to a user is set as number of blocks upon registering. If you only give pstorage one page, all users will be given blocks within that page.

    4. No, unless you intend the block size for each user to be equal to a physical flash page.

    5. The code seems correct, though I have not tested it. Do note that pstorage_load reads data, and pstorage_store stores data. See the headerfile pstorage.h for a summary of the functions.

    Best regards

    Jørn Frøysa

Related