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

libuarte issue: nrf_balloc_alloc retuns NULL after a while.

Hi.

I'm having an issue with the libuarte library. It seems to work perfectly but after some hours of running the program crashes because nrf_balloc_alloc returns NULL inside the rx_buffer_scheduile function which is called from the uart_evt_handler under the NRF_LIBUARTE_DRV_EVT_RX_BUF_REQ event.

I tried enabling the RX pullup. Increasing the RX buffer (count 16, size 250) but still getting the NULL pointer. I receive very little data @ 1125200 (it's an AT command module so there's not much being sent/received).

Any idea on how I can debug or fix this? Maybe increasing the ISR priority?? 


Thanks a lot.

  • I did some more testing.

    This happens after I get an NRF_LIBUARTE_ASYNC_EVT_OVERRUN_ERROR error, so obviously I'm not handling the error correctly.

    When I get an NRF_LIBUARTE_ASYNC_EVT_OVERRUN_ERROR, what should I do?? Should I clear manually the error registers? or should I uninit and reinit the libuarte?


    Thanks.

  • I tried calling libuarte uninit and init inside the overrun case in the event handler but it later crashes when I try to access the data of received data from UART, so I guess that's not the right way of doing it.

    Does anyone know how to clear or handle the LIBUARTE OVERRUN error? I was not able to find in the documentation the proper way of handling it. In other architectures I used to clear the flag and reenable the receiver. But I'm not sure how to do something similar with the libuarte async library.

    Thanks!!

  • I activated the debug logs in the libuarte library and I got the following:

    RX buf response (mp_next_rx not NULL:0x20005AC4), Provided buffer:0x20005BC4
    (evt) RX dma_cnt:4294901761, endrx_cnt:0, stop_cnt:0
    RX END chunk0:255, chunk1:-65790, data[0]=13 10
    Freeing full buffer 0x20005CC4, 255, (currently allocated:2).
    RX END Chunk1:-65790

    dma_cnt: 4294901761 is 0xFFFF0001 (which appear to be a rater specific value, could it be a -1 in 16 bit?).

    I believe this overrun is not an uart overrun but instead a library defined overrun since the dma read more bytes that it could handle? 


    By the way, I am not using a Soft Device. I'm not using BLE.

    Any ideas?

    Thanks

  • More info.

    When I reinit the libuarte async driver, it works for like 5-6 receptions and then it crashes, but there is something strange.

    Usually the RX buffers I get are in the range of 0x20005A00 to 0x20005D00, but after some receptions I get buffers in the range 0x2000FF00 onwards and that is when it crashes, probably goes above the 0x20010000 address but I have no idea why it goes there. I tried putting a flag in the libuarte library so that it only inits the nrf_balloc once (even if I call uninit and init again for the libuarte) but that didn't help.

    I hope this information is useful and thanks in advance for any help.

  • Hello, 

    My apologies for the late reply. Our team is currently understaffed due to summer vacations. I will have a look at your case within today or tomorrow. 

    Sorry for the inconvenience. 

    Kind regards,
    Øyvind

Related