ENOMEM error

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
Post Reply
kbrenner
Posts: 46
Joined: Mon Jan 20, 2020 8:05 pm

ENOMEM error

Post by kbrenner » Mon Jan 11, 2021 3:00 am

I am using a PYBD-SF6W and am running into an error while sending BLE messages. The REPL prompt just gets flooded with the following messages:
ENOMEM error.PNG
ENOMEM error.PNG (19.66 KiB) Viewed 5449 times
Does anyone know where these get generated? If there isn't a way right now to avoid them, is there a way to recognize that the error is occurring and reset something to make them go away (i.e. ensure they only occur on one frame and then get back on track)? Thanks!

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: ENOMEM error

Post by jimmo » Mon Jan 11, 2021 3:37 am

Confusingly, ENOMEM here comes from the BLE stack being unable to allocate internal buffers. It doesn't (necessarily) mean that the Python heap ran out of memory.

Generally this shouldn't be possible from user code (i.e. we should turn these errors into something easier to debug).

Are you able to share any more details about what your code is doing? Is it a GATT server or client? Peripheral or central? Using any more advanced features (l2cap, pairing/bonding, etc)? Can you share your code?

I did fix a bug late last year in https://github.com/micropython/micropython/pull/6717 but not sure that explains what your'e seeing.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: ENOMEM error

Post by jimmo » Mon Jan 11, 2021 3:39 am

Another option... are you compiling your own firmware? If so, a build with DEBUG_printf enabled (line 55 of extmod/nimble/modbluetooth_nimble.c) would probably be useful for tracking this down.

monquarter
Posts: 15
Joined: Sat Jan 11, 2020 2:31 pm

Re: ENOMEM error

Post by monquarter » Mon Jan 11, 2021 4:50 pm

Additionally, I notice that it is not possible to configure that rxbuf parameter associated with the ble.

Code: Select all

>>>
MPY: sync filesystems
MPY: soft reboot
MicroPython v1.13-268-gf7aafc062 on 2021-01-11; PYBD-SF6W with STM32F767IIK
Type "help()" for more information.
>>> import ubluetooth
>>> ble = ubluetooth.BLE()
>>> ble.active(True)
True
>>> ble.config('rxbuf')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: unknown config param
>>> ble.config(rxbuf=1024)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: unknown config param
>>>

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: ENOMEM error

Post by jimmo » Mon Jan 11, 2021 11:48 pm

monquarter wrote:
Mon Jan 11, 2021 4:50 pm
Additionally, I notice that it is not possible to configure that rxbuf parameter associated with the ble.
Since v1.13 (i.e. the current unstable code) on STM32 and Unix when using the NimBLE stack, there is no longer a ringbuffer of pending events. The events get delivered directly via the scheduler.

I will update the docs.

monquarter
Posts: 15
Joined: Sat Jan 11, 2020 2:31 pm

Re: ENOMEM error

Post by monquarter » Tue Jan 12, 2021 2:44 pm

I made a build as suggested by jimmo with debug flag enabled, and modified the ble_temperature to send data more quickly to a second pyboard-DSF6 running ble_central.py example. See viewtopic.php?f=20&t=8844 for more info on the test setup.

Code: Select all

nimble: characteristic_access_cb: conn_handle=65535 value_handle=21 op=0
nimble: gap_event_cb: type=13
nimble: gap_event_cb: notify_tx: 0 0
nimble: ble_hs_err_to_errno: 0
nimble: characteristic_access_cb: conn_handle=65535 value_handle=21 op=0
nimble: gap_event_cb: type=13
nimble: gap_event_cb: notify_tx: 0 0
nimble: ble_hs_err_to_errno: 0
nimble: gap_event_cb: type=13
nimble: gap_event_cb: notify_tx: 0 6
nimble: ble_hs_err_to_errno: 6
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "ble_temperature.py", line 91, in demo
  File "ble_temperature.py", line 72, in set_temperature
OSError: [Errno 12] ENOMEM

Post Reply