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

nrf52 flash erase problem

Hi, i use the original ble_app_template (sdk11) with two lines of code added by me (See below) which erase the last page in flash (flash_page_erase((uint32_t *)(pg_size * pg_num))). First line executes ok, but the second line not. I would like to be able to erase the flash page after the ble_stack is initialized.

int main(void) { uint32_t err_code; bool erase_bonds;

// Initialize.
timers_init();
buttons_leds_init(&erase_bonds);

	erase_flash_page();     // 1st line added -> all ok

ble_stack_init();

       erase_flash_page();  // 2nd  line added -> device resets

device_manager_init(erase_bonds);
gap_params_init();
advertising_init();
services_init();
conn_params_init();

// Start execution.
application_timers_start();
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);

// Enter main loop.
Related