peripheral-and-central-uart-sample-crash

Hi,

I did respond to this:

https://devzone.nordicsemi.com/f/nordic-q-a/86426/peripheral-and-central-uart-sample-crash-when-sending-longer-messages

I do not see a update on a response, maybe that im not part of this ticket ??

Could you please have a look at this?

Thanks,

Best Regards,

Theo  

  • Hi,

    As I said in the ticket you linked, we are working on a fix and I will update you when I have more to share.

    probably not THE sollution, but when i empty (remove the code) of  the routine: 
    static void ble_data_sent(struct bt_nus_client *nus, uint8_t err,
                        const uint8_t *const data, uint16_t len)
    the the crash is gone, and the send data i see on the peripheral.   
    ...but,  probably i have now a missing feature ???? 

    Removing the k_sem_give() in that callback would not be good, but it looks like it would mostly slow the sample down and produce a lot of warnings.

    Removing the rest of the code, along with the k_free() would cause a memory leak and the sample would crash after enough messages were sent.

  • Ok Thanks ,  Looking forward to the update

    Best Regards,

    Theo

  • Hi ,

    I have now only removed the k_free(), to prevent the crash, at the beginning.

    After further working with the Central_uart AND the Peripheral_uart.. after some communication running it reveals an other-crash on both sides.

    I found a memory leakage situation  in the central AND in the peripheral...

    ->in the central_uart:  in ble_data_received()  there is a 
    struct uart_data_t *tx = k_malloc(sizeof(*tx));
    but there is no  k_free(tx) ;
    ->in the periferal_uart in bt_recive_cb() there is a
    struct uart_data_t *tx = k_malloc(sizeof(*tx));
    but there is no  k_free(tx) ;
    After i added these k_free()'s   i had a continiously running communication...
    -----
    Do i now have earned a free nrf5340_DK board ?? :-),  or several nrf52840-dongles.. ?? :-)
    Best Regards,
    Theo
     
  • Hi,

    Great to see that you are trying to figure out what the issue is, but I unfortunately have to inform you that both those buffers already have an associated k_free().

    The buffers allocated in central_uart's ble_data_received() and in peripheral_uart's bt_receive_cb() are later passed to k_free in the UART_TX_DONE case of uart_cb().

    If you are seeing improvements from your changes, you should double check that uart_cb is getting the UART_TX_DONE event and freeing the buffer properly.

  • Ah Ok i see, thanks

    it is becoming more clear now

Related