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
  • 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)

  • I see, this means the memory access violation was not triggered from accessing the RADIO as I claimed, but POWER. I forgot that the info value is not starting at 0, but 1. 

    As a fix you can try to add the_DSB() instruction to the end of your mwu_disable routine as shown here:  RE: Disable Softdevice sandboxing in fault handler  

  • 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;
    __DSB();
    }

    THAT can not fix this issue.

    but ı change  from *((volatile uint32_t *)0x40000E00) = m_anomaly_198_preserved_value; to *((volatile uint32_t *)0x40002000) = m_anomaly_198_preserved_value; in anomaly_198_disable and enable  now not crash my responder continues advertise but dwm3001c module that has a responder code can not receive frame .

    responder can frame only one time in 15-20 loop.

    but if ı do not use SD AND BLE , my RESPONDER CAN RECEİVE FRAME WELL.

    now how can I fix to receive frame issue?

  • I see now that you already have an open ticket on this issue with Hung here:  I use a module that has nrf52833 . this is DWM3001C . My responder software not working with BLE and SD.  You need to continue the discussion there and update it with the information you have provided here.

Related