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

SOFTDEVICE: INVALID MEMORY ACCESS

I am trying to migrate BLE peripheral implementation code from nRF52832 (SDK 132)  to nRF52840 (SDK 140)  using nRF52840 Preview-DK (PCA10056).

The application is based on freeRTOS and BLE is running as one of the tasks.

When I ran it I got error message " SOFTDEVICE: INVALID MEMORY ACCESS". 

During debug I comment out all BLE related functions calls it ran without error.

but when I uncomment ble_init()  function (see below function code) I received again the error message.

 

What can be the reason for this issue?

Thanks in advance

 

 

int
main(void)
{
...

   if (pdPASS != xTaskCreate(BLETask, "BLETask", BLE_TASK_STACK_DEPTH, NULL, BLE_TASK_PRIORITY,       &m_oBLETaskHandle))
  {
    NRF_LOG_WARNING("Init - BLE task creation failed");
    APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
  }

...

}


void BLETask (void * pvParameter)
{
   UNUSED_PARAMETER(pvParameter);
   LOGPRINT(LOG_PRINT_BLE, "BLE init");

   ble_init();

#ifdef BLE_ENABLE
   LOGPRINT(LOG_PRINT_BLE, "BLE enable - start advertising");
   // ble_start();
#endif

   while (true)
  {
    // ble_queue_service ();

    LOGPRINT(LOG_PRINT_BLE, "BLE Running");
    taskYIELD();
  }
}

void ble_init (void)
{
  ble_stack_init();
  gap_params_init();
  gatt_init();
  services_init();
  advertising_init();
  conn_params_init();
}


 

Parents Reply Children
  • What is the "info" value in your case? You can edit the log message to include it: NRF_LOG_ERROR("SOFTDEVICE: INVALID MEMORY ACCESS. INFO 0x%x", info)

  • Hi,

    first of all, thanks you for response.

    info=1

    NRF_MWU->PERREGION[0].SUBSTATWA=1

    NRF_MWU->PERREGION[0].SUBSTATRA=0

    NRF_MWU->EVENTS_REGION->WA=0

    NRF_MWU->EVENTS_REGION->RA=0

    NRF_MWU->EVENTS_PREGION->WA=1

    NRF_MWU->EVENTS_PREGION->RA=0

  • Hi,

    This means the application is trying to write to one of the RADIO registers while the Softdevice is enabled. To fix this you need to find out where this illegal write is taking place in your application.

  • But I can't debug step by step because I have softdevice.How can I that?

  • Hi,

    the pc is 0x49eac as hex,

    the pc is 302764 as uint32_t.

    this show me that problem occur when calling app_mwu_enable

    and screenshoot is in follow .

    what can I do for solve?

    that func is defined in nrfx_spim.c then  that is called only two where in all project.

    I addt that(Segmentation fault after enabling BLE stack - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com)) to my code for a issue one week ago.

    my nrfx_spim.c   :

    void app_mwu_enable(void) //WORKAROUND ADDED 2-1-2019
    {
    NRF_MWU->REGIONENSET
    = ((MWU_REGIONENSET_RGN0WA_Set << MWU_REGIONENSET_RGN0WA_Pos) | (MWU_REGIONENSET_PRGN0WA_Set << MWU_REGIONENSET_PRGN0WA_Pos));
    NRF_MWU->REGIONEN;
    }

    void app_mwu_disable(void) //WORKAROUND ADDED 2-1-2019
    {
    NRF_MWU->REGIONENCLR
    = ((MWU_REGIONENCLR_RGN0WA_Clear << MWU_REGIONENCLR_RGN0WA_Pos) | (MWU_REGIONENCLR_PRGN0WA_Clear << MWU_REGIONENCLR_PRGN0WA_Pos));
    NRF_MWU->REGIONEN;
    }


    static uint32_t m_anomaly_198_preserved_value;

    static void anomaly_198_enable(uint8_t const * p_buffer, size_t buf_len)
    {
    m_anomaly_198_preserved_value = *((volatile uint32_t *)0x40000E00);

    if (buf_len == 0)
    {
    return;
    }
    uint32_t buffer_end_addr = ((uint32_t)p_buffer) + buf_len;
    uint32_t block_addr = ((uint32_t)p_buffer) & ~0x1FFF;
    uint32_t block_flag = (1UL << ((block_addr >> 13) & 0xFFFF));
    uint32_t occupied_blocks = 0;

    if (block_addr >= 0x20010000)
    {
    occupied_blocks = (1UL << 8);
    }
    else
    {
    do {
    occupied_blocks |= block_flag;
    block_flag <<= 1;
    block_addr += 0x2000;
    } while ((block_addr < buffer_end_addr) && (block_addr < 0x20012000));
    }

    app_mwu_disable(); //WORKAROUND ADDED 2-1-2019

    *((volatile uint32_t *)0x40000E00) = occupied_blocks;
    app_mwu_enable(); //WORKAROUND ADDED 2-1-2019
    }

    static void anomaly_198_disable(void)
    {
    app_mwu_disable(); //WORKAROUND ADDED 2-1-2019
    *((volatile uint32_t *)0x40000E00) = m_anomaly_198_preserved_value;
    app_mwu_enable(); //WORKAROUND ADDED 2-1-2019
    }
    #endif // NRFX_CHECK(NRFX_SPIM3_NRF52840_ANOMALY_198_WORKAROUND_ENABLED)

Related