adding Softdevice BLE (S140) with GPIO attached coprocessor to project without softdevice. hardfault calling existing code after Softdevice active

I am extending one of Qorvo's UWB platforms.. adding Softdevice BLE functions..  (which work ok) (this is on sdk 17_1_0)


the coprocessor uses a GPIO connected signaling mechanism,  using interrupts..

calling the existing code after BLE is active causes a hardfault.. 

this is running freetos,  we are in a freetos task. 

I've debugged (using ozone) it to  attempting to setup the interrupt handler for the GPIO pins. 

the existing code calls the nrfx libs 

       return qgpio_pin_irq_configure(&qm33_irq, QGPIO_IRQ_DISABLED);  //according to the doc, a gpio interrupt disable shouldn't impact softdevice.. 

```

enum qerr qgpio_pin_irq_configure(const struct qgpio *qgpio_pin, uint32_t flags)
{
nrfx_err_t r;
enum qerr err;
struct qgpio_cb_data *cb_data;
nrfx_gpiote_in_config_t trigger_config;
uint32_t abs_pin = NRF_GPIO_PIN_MAP(qgpio_pin->port, qgpio_pin->pin_number);  // this sets abs_pin = 25 

/* Init GPIOTE at least once. */
if (!nrfx_gpiote_is_init()) {   // this causes the hardfault.   
   r = nrfx_gpiote_init();
   if (r)
   return QERR_EBUSY;
}

if (flags & QGPIO_IRQ_DISABLED) {
   nrfx_gpiote_in_event_disable(abs_pin);
   nrfx_gpiote_in_uninit(abs_pin);
   return QERR_SUCCESS;
}
```
hardfault window
```
The target stopped in HardFault exception state.

Reason: A fault with configurable priority has been escalated to a HardFault exception at 0x00000000.
```

I don't see any mechanism to cause hardfault on a GPIO pin  with SD active. 
if SD is not active this code works as written 

what am I missing

if I run this code BEFORE setup of softdevice, it works, but softdevice init fails. 

Parents
  • Hi Sam, 
    So it seems that it didn't crash in nrfx_gpiote_is_init() ? 
    But it has something with the SPI transfer/IRQ handler instead ? 
    Could you check what's the context (interrupt priority) when this function is called ? 
    Also could you check how flash is handled in the code ? Note that when the softdevice is enabled, flash operation has to be handled by Softdevice's flash API

Reply
  • Hi Sam, 
    So it seems that it didn't crash in nrfx_gpiote_is_init() ? 
    But it has something with the SPI transfer/IRQ handler instead ? 
    Could you check what's the context (interrupt priority) when this function is called ? 
    Also could you check how flash is handled in the code ? Note that when the softdevice is enabled, flash operation has to be handled by Softdevice's flash API

Children
  • the title  is more correct.. 

    oh, spim relates to flash.. ??

    I can only assume that the project I built on does not have FDS enabled, and checking the sdk_config.h that is true. 

    a lot of knowledge needed. 

    they have a project that has SD peripheral mode, and put the FDS segments at 7D000-800000

    but that is in the middle of the large 52840 flash space.. 

    on the non-SD project, they don't have any space for FDS so I'll have to figure out  all that and how to indicate to use the SD apis for it.  part of my extensions need small amount of persistent storage

  • Hi Sam, 
    Could you explain more why SPIM related to flash ? Maybe check the interrupt priority of SPI interrupt?

    Note that the requirement is only about internal flash. The reason I mentioned that is that I noticed "nrfx_nvmc_page_erase " call in your log. 

    Note that FDS uses fstorage under the hood and you can choose between fstorage and fstorage_sd when you use it without or with Softdevice. 

    I will be a away for vacation until the end of the year. So there will be delay in the answer unfortunately.
    Wish you a Merry Xmas ! 

  • after thinking about it overnight, I don't think FDS is involved..  I am debugging again now.. I think there might be another address optimization problem.. cause we fault in the SPIM interrupt handler

    I WILL need FDS and have adjusted the ld file to reserve the space when I get there..

    and I understand about using the fstorage api and letting the backend handle it.. 

    happy holidays. 

  • Hi Sam,
    Let's us know if you find out something wrong with the SPIM interrupt handler. Again, check the interrupt priority level and check if there is anything not expected calling inside that handler. 

    To narrow down the root cause I would suggest to try turning off SPIM to see if you can start the softdevice and do BLE correctly first. 

    Happy holidays ! 

  • BLE thru softdevice works great. Pair w phone, scan and connect downstream peripherals, send/receive data, notifications

    now I want to execute other code, unchanged from the Qorvo distribution. have found two code optimization problems, and this crash in the interrupt handler looks similar , if I stop in ozone there the pointer looks good,

    course sd is unhappy with the delay 

    if I don’t stop I get an access fault trying to write to the flash in code space.  Makes no sense. Tried different compiler versions, optimization settings.  Weird

    also, if I do this setup BEFORE SD init, then SD fails, BUT the other code does NOT..

    I don't see any shared resources.. interrupts, levels, ...

Related