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

Hardfault triggered after p nrf_fstorage_erase

Hi!

Writing to flash memory.

After calling nrf_fstorage_erase (...) a hardfault happens. It only NOT happens if JLink is enabled (using dbg or rtt logs).
So I can not debug it deeply. I did simple de-bug procedure, with LED flashing the number of cfsr_msgs[]. This number is 10,
meaning [10] = "Data bus error (return address in the stack frame is not related to the instruction that caused the error)".

Looks like the flash area is not erased as the result.

Looks like it happens not every time. I load the program into debugger (it works good), then I go out of the debugger session.
The program continues to run, and after 2 or 3 erase/write cycles it fails and calls for hardfault.

This piece of the program is taken from a working program, so looks like the problem depends on the code size, or RAM map, or
FLASH map. Can not understand.

I know this situation happens with NRF52832 not in first time, as there are some answers in this community already. But it does not help.

Anybody could help me?

Alex. 

  • Hello.

    I do the following:

    1) Use the board with NRF52832, which has SD + my application loaded into;

    2) Load the project from "... nRF5_SDK_17.0.0_9d13099\examples\dfu\secure_bootloader\pca10040_s132_ble\arm5_no_packs"

    3) Set breakpoint and call the function:
    ret_code_t nrf_bootloader_flash_protect(uint32_t address, uint32_t size)

    4) See "size" parameter. size = 0x0006F000

    0x0006F000 is the end address of my application.

    What could I do wrong?

    For now - I just do not call this procedure form the Bootloader, I do it from my application.

    Alex.

  • Check this define NRF_DFU_APP_DATA_AREA_SIZE in the "sdk_config.h" of the bootloader.

    Based on that the protection is calculated

  • I checked, in Bootloader project:

    // </h>
    //==========================================================

    // <h> Misc DFU settings

    //==========================================================
    // <o> NRF_DFU_APP_DATA_AREA_SIZE - The size (in bytes) of the flash area reserved for application data.
    // <i> This area is found at the end of the application area, next to the start of
    // <i> the bootloader. This area will not be erased by the bootloader during a
    // <i> firmware upgrade. The size must be a multiple of the flash page size.

    #ifndef NRF_DFU_APP_DATA_AREA_SIZE
    #define NRF_DFU_APP_DATA_AREA_SIZE 12288
    #endif

    ... and ...

    #ifndef NRF_DFU_APP_DATA_AREA_SIZE
    #define NRF_DFU_APP_DATA_AREA_SIZE (CODE_PAGE_SIZE * 3)
    #endif

    =============
    It does not equal to my App's End address

Related