NimBLE msys runs out of free blocks on ESP32C6

spikeyamk
Posts: 2
Joined: Mon Nov 27, 2023 3:36 pm

NimBLE msys runs out of free blocks on ESP32C6

Postby spikeyamk » Tue Feb 27, 2024 7:38 pm

Hello, I can't seem to figure out how to send packets over BLE with ble_gatts_notify_custom at full speed. When I try and use

Code: Select all

int ble_hs_mbuf_to_flat(const struct os_mbuf *om, void *flat, uint16_t max_len, uint16_t *out_copy_len);
this function fails if the msys is full. But when it fails it seems like the whole NimBLE fails and I can't send any more packets over BLE no matter what. I've looked at the example here: https://github.com/espressif/esp-idf/tr ... throughput and they use this function there:

Code: Select all

if (os_msys_num_free() >= MIN_REQUIRED_MBUF) {
To detect whether there's enough free blocks in the msys for another packet to be fed into msys. But this function doesn't seem to do much on my EPS32C6. It just reports total number of blocks MSYS1 + MSYS2 specified by me in the sdkconfig . The value it returns does in fact decrease after I fill the msys with data but at that point it's already too late and everything fails.

Can anyone suggest a fix for this?

Thanks in advance!

MicroController
Posts: 1707
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: NimBLE msys runs out of free blocks on ESP32C6

Postby MicroController » Wed Feb 28, 2024 11:50 am

1) ble_hs_mbuf_to_flat is used to extract data from an mbuf; it doesn't allocate any memory. Are you sure this is where your problem is? (Notice that ble_hs_mbuf_to_flat returns BLE_HS_EMSGSIZE if you pass it a max_len that is less than the size of data currently held in the mbuf.)
2) Check who owns which mbuf when, specifically who is responible for releasing it. Make sure you release/return the mbufs passed into your code's ownership.
3) You can adjust NimBLE's "Memory Settings" via menuconfig to increase the number of available mbufs.

Who is online

Users browsing this forum: Baidu [Spider] and 114 guests