nrf_fstorage_erase hardfault after use nordic flash loader

Hi,

We use nrf52840 and SDK 17.0.2 with Softdevice S340

   We have a very strange problem and need help from Nordic. Below is my source code.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
uint32_t bootloader_start_addr = 0xF2000;
static void power_manage(void)
{
#ifdef SOFTDEVICE_PRESENT
(void) sd_app_evt_wait();
#else
__WFE();
#endif
}
void wait_for_flash_ready(nrf_fstorage_t const * p_fstorage)
{
/* While fstorage is busy, sleep and wait for an event. */
while (nrf_fstorage_is_busy(p_fstorage))
{
power_manage();
}
}
static void fstorage_evt_handler(nrf_fstorage_evt_t * p_evt)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I don't have any Bootloader and My application flash range is 0x31000 - 0xF1ffff

After I build and download by IAR. Everything is OK. I can erase internal flash 1 block form 0xF2000

But If I click option -> Debugger -> Use flash loader and Override default .board file 

I go to run the same source code. Erase action will cause Hardfault in below function

/* Erase flash page(s). */
static uint32_t erase_execute(nrf_fstorage_sd_op_t const * p_op)
{
return sd_flash_page_erase(p_op->erase.page + p_op->erase.progress);
}

Why? We don't have any idea how to debug this problem. Can you help me to try this problem using my source code?

Thank you.

John.