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

SOFTDEVICE: INVALID MEMORY ACCESS. error coming up while doing erase operation in NRF52832

Hi,

I am using a custom NRF52832 board. I am using Nordic SDK + BLE code, and whenever I am trying to do an erase of flash memory with start address as 0x70000 and end address as 0x70100, I am getting "SOFTDEVICE: INVALID MEMORY ACCESS" error. I checked like whether I was trying to erase a memory area in the soft device protected area, but I found like the flash memory area does not belong to the softdevice protected region. 

Can you please guide me on how to resolve this issue.

I am using nrf_nvmc_page_erase() function to erase the flash memory area.

Parents
  • Hi.

    You cannot use nrf_nvmc_page_erase() when you use the SoftDevice.

    You have to use sd_flash_page_erase():

    /**@brief Flash Erase page
    *
    * Commands to erase a flash page
    * If the SoftDevice is enabled:
    *  This call initiates the flash access command, and its completion will be communicated to the
    *  application with exactly one of the following events:
    *      - @ref NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
    *      - @ref NRF_EVT_FLASH_OPERATION_ERROR   - The command could not be started.
    *
    * If the SoftDevice is not enabled no event will be generated, and this call will return @ref NRF_SUCCESS when the
    * erase has been completed
    *
    * @note
    *      - This call takes control over the radio and the CPU during flash erase and write to make sure that
    *        they will not interfere with the flash access. This means that all interrupts will be blocked
    *        for a predictable time (depending on the NVMC specification in the device's Product Specification
    *        and the command parameters).
    *      - This call will make the SoftDevice trigger a hardfault when the page is erased, if it is
    *        protected.
    *
    *
    * @param[in]  page_number           Page number of the page to erase
    *
    * @retval ::NRF_ERROR_INTERNAL      If a new session could not be opened due to an internal error.
    * @retval ::NRF_ERROR_INVALID_ADDR  Tried to erase to a non existing flash page.
    * @retval ::NRF_ERROR_BUSY          The previous command has not yet completed.
    * @retval ::NRF_ERROR_FORBIDDEN     Tried to erase a page outside the application flash area.
    * @retval ::NRF_SUCCESS             The command was accepted.
    */
    SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number));

    Best regards,

    Andreas

  • Hi Andreas,

    Thanks for the reply.

    I tried using sd_flash_page_erase() function and was getting the error as "NRF_ERROR_INVALID_ADDR". I checked and provided the start address as 0x70000 in the nrf_fstorage_t's start_addr element, but still I was getting the invalid address error. 

    Kindly give your insights on this issue.

Reply Children
Related