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

nRF5 SDK 16 BLE startup, failing nrf_atfifo_item_alloc

During BLE startup call to nrf_sdh_enable_request(), nrf_atfifo_item_alloc fails and returns NULL causing a hard fault.

This sounds like an sdk_config.h problem but I don't know where to start looking.

Parents
  • Hello,

    Is the failing call to nrf_atfifo_item_alloc() being made by a SDK module or by your own code? NULL is usually handled by returning NRF_ERROR_NO_MEM back to the app, which should not lead to a fault exception. I would suggest  to first try enabling the HardFault handling library in your project and see if it could help you find out exactly where the fault occurred.

  • That's how I found out. The top level call is nrf_sdh_enable_request() from the examples which is the first call in ble_stack_init. This call chain hard faulted as a result of NULL being returned by nrf_atfifo_item_alloc. nrf_sdh_enable_request then failed with code 3 which causes the hard stop.

  • Things behaving differently - I switched to the Linux version (a treat by the way) and followed the request sequence for nrf_sdh_enable_request as follows. The error occurs in a critical region which could be a problem for the debugger but:

    nrf_sdh_enable_request
      sdh_request_observer_notify succeeds
      sd_softdevice_enable
         ser_app_hal_hw_init succeeds
         connectivity_reset_low
         nrf_queue_reset
         nrf_queue_reset
         ser_sd_transport_open fails following
           ser_hal_transport_open
            ser_phy_open fails following
             hci_timer_init fails following
               app_timer_create success
                 hci_timer_reset fails
                    app_timer_stop fails return code 4, switch error code to NRF_ERROR_INTERNAL==3 and return up

    Now sounds like something with the timers needed.

    Uploading zip problematic for sponsor.

  • I followed the app_timer_stop a bit farther, it is failing the nrf_atfifo_wspace_req call (which returns NULL). The linker claims I'm only using 25% of RAM so this  must be a memory setup problem. The code in nrf_atfifo_wspace_req is assembly that I'm not competent to interpret.

    nrf_sdh_enable_request
    sdh_request_observer_notify
    sd_softdevice_enable
    ser_app_hal_hw_init
    connectivity_reset_low
    nrf_queue_reset
    nrf_queue_reset
    ser_sd_transport_open
    ser_hal_transport_open
    ser_phy_open
    hci_timer_init
    app_timer_create
    hci_timer_reset
    app_timer_stop fails return code 4,

    further calls by app_timer_stop now...
        timer_req_schedule
          nrf_atfifo_item_alloc returns NULL
            nrf_atfifo_wspace_req --> No calls here, this is what fails.

  • I assumed you were working with a standalone application with everything running on the nRF52 device, not a  "serialized setup" with the app code running on a different CPU. Has the application been ported to a different platform (ie not a nordic nRF device)? The atfifo assembly is written for the Cortex m4 architecture.

  • This is running on an nRF52832 standalone. I'm running the SEGGER IDE (Linux version) JLINK base programmer talking to the board. I don't have a BLE application (phone based) yet, just using nrfconnect but if I can't get bluetooth started, the app is  meaningless. Is the 52832 not an M4 device?

    Am I using the wrong bluetooth code? This was setup to use softdevice S112.

  • I see. Your project is not set up correctly then. Some of the function calls you listed in your previous response are only used for serialization (ser_app_hal_hw_init, ser_sd_transport_open,..) so that is why I got confused.  I suggest you start with an existing SDK example such as ble_app_blinky and verify that it runs on your board.

Reply Children
No Data
Related