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

HardFault Error after calling nrf_nvmc_page_erase

Hello Support

When calling the function nrf_nvmc_page_erase(0xF7000) (In nrf_nvmc.c) I immediately get a Hardfault error when the code reaches the line where it calls wait_for_flash_ready(); which reads the NRF_NVMC->READY register.

This is my setup:

MBR calls my Bootloader (address 0xE0000). 

Bootloader works fine, it can erase and write the internal FLASH with no problems. The Bootloader is not using softdevice (not defining -DSOFTDEVICE_PRESENT).

Bootloader calls Application image using the function nrf_bootloader_app_start(), jumping to image at address 0x26000.

Application image then runs executing from main()

When calling nrf_nvmc_page_erase(0xF7000) in the Application image (e.g. as the first line in main(void) i get the HardFault error.

Application has defined -DSOFTDEVICE_PRESENT but softdevice is not enabled (never called nrf_sdh_enable_request();)

Question: What can cause this Hardfault? Some clock not enabled? Why can the bootloader call the erase page and not the application image? Some restriction when executing from Application area?

 

  • Hi,

    What data are you trying to erase at 0xF7000 ? 

    Are you sure that your bootloader is at 0xE0000 ? If yes, how big is the bootloader ?

    If you are using the bootloader variant pca10056_s140_ble_debug, it will by default occupy the flash at 0xF7000, and since the bootloader is using ACL to protect itself from being overwritten(nrf_bootloader_flash_protect), a busfault will happen if you try to erase 0xF7000, or any other page that is protected by ACL.

  • Hello Sigurd. I solved the issue by using your hint that ACL is in use. It was indeed the ACL block that prohibited me to write at the area I had designed to use for a proprietary data.

    So my bootloader called nrf_bootloader_app_start_final which again called nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, BOOTLOADER_SIZE + NRF_MBR_PARAMS_PAGE_SIZE, NRF_BOOTLOADER_READ_PROTECT);

    So I solved the issue by decreasing the BOOTLOADER_SIZE value thereby allowing my application to erase the data at 0xF7000 where my proprietary data resides.

Related