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

Flash write

Hello,

I'm trying to write value to a specified address with ble_flash_page_write .

I'm using ble_flash_page_write after ble disconnect event. I've tested different page address to be sure i'm not writing on application or s110 areas and page address are multiples of 4.

At execution, an Hard fault occur at the ble_flash_page_write line... Any idea about this error ? Is there others solutions to write values to a precise flash address ?

int32_t page = 200;
uint8_t word_count = 1;
uint32_t data_array[2]={0x81ABACAB};
data_array[1] = 0x81ABACAB;
		
err_code = ble_flash_page_write(page,(uint32_t *) &data_array,1);
APP_ERROR_CHECK(err_code);
Parents
  • Hi Thomas,

    You should know that ble_flash module cannot be used when SoftDevice is enabled. This was done post SoftDevice 6.0.0 release, when flash access was offered as a part of SoftDevice functionality.

    Also, in case you need the address, in pstorage block_id of pstorage_handle_t contains actual flash access. Accessing the flash access yourself is not recommended for typical use cases.

    In case you do want to access all flash yourself, raw mode is appropriate. In this case, you need follow the following steps: a. Initilaize pstorage using pstorage_init(); b. Register the application in raw mode using the pstorage_raw_register() with appropriate parameters. You will provided a handle here. The module id in this handle identifies your application. Block id of the handle can be manipulated to any flash access to desire to access subsequently. c. Assign block_id field of the handle to an appropriate word aligned flash address (not page number). And call pstorage_raw_store. Do ensure that your source data lies in resident memory as flash access is no longer blocking.

    For an example usage of raw mode, you can look at the boot-loader included in the SDK. This is the only application using raw mode.

    Hope this helps!

    Regards, Krishna

Reply
  • Hi Thomas,

    You should know that ble_flash module cannot be used when SoftDevice is enabled. This was done post SoftDevice 6.0.0 release, when flash access was offered as a part of SoftDevice functionality.

    Also, in case you need the address, in pstorage block_id of pstorage_handle_t contains actual flash access. Accessing the flash access yourself is not recommended for typical use cases.

    In case you do want to access all flash yourself, raw mode is appropriate. In this case, you need follow the following steps: a. Initilaize pstorage using pstorage_init(); b. Register the application in raw mode using the pstorage_raw_register() with appropriate parameters. You will provided a handle here. The module id in this handle identifies your application. Block id of the handle can be manipulated to any flash access to desire to access subsequently. c. Assign block_id field of the handle to an appropriate word aligned flash address (not page number). And call pstorage_raw_store. Do ensure that your source data lies in resident memory as flash access is no longer blocking.

    For an example usage of raw mode, you can look at the boot-loader included in the SDK. This is the only application using raw mode.

    Hope this helps!

    Regards, Krishna

Children
No Data
Related