Open jerryneedell opened 1 year ago
Do you see the same memory issues on nRF52840 in the second case? Development on the BLE support on ESP32-S3 got stalled because we couldn't add services dynamically. We are considering how to fix this but it's a big job.
I wonder if this is a core bug.
I see it on both the esp32s3 and on the nrf52840 with both programs. It is intermittent - sometimes it occurs frequently and sometimes it takes a 10s of seconds. on the last try of the simplest I saw this after quite awhile
<Address 6f:8a:18:3d:83:4b> <Advertisement >
Advertisement(data=b"\x17\x16\x9f\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x03\x9f\xfe")
<Address d9:fe:c2:95:3a:37> <Advertisement >
Advertisement(data=b"\x1e\xff\x4c\x00\x12\x19\x10\x1c\xd7\xfa\x85\xa9\xee\xbc\x47\x59\x09\x63\x37\x49\xbf\x8b\xcb\xb0\x2e\x79\xda\x2a\x5a\x02\x37")
<Address f1:46:54:ba:ea:9e> <Advertisement >
Advertisement(data=b"\x07\xff\x4c\x00\x12\x02\x00\x02")
<Address d5:f8:0d:66:20:3f> <Advertisement >
Advertisement(data=b"\x1e\xff\x4c\x00\x12\x19\x50\x32\x26\x0c\x78\x38\xd8\x49\x00\xc0\xdb\x60\x48\x4c\x82\xc2\xd2\x6e\xa9\xbf\x2c\xd5\x39\x02\xce")
<Address a4:c1:38:2b:6d:3b> <Advertisement >
Advertisement(data=b"\x12\x16\x1a\x18\x3b\x6d\x2b\x38\xc1\xa4\xe1\x07\x2d\x0c\x6b\x0b\x50\x59\x0f")
<Address 0c:fe:9a:0e:10:01> <Advertisement >
Advertisement(data=b"\x9c\x88\xab\xd1\x28\xde\xdf\xbd\xfa\xbc\x90\xd2\xae\xec\x54\x00\x8a\x98\x08\x00\x00\x00\x00\x00\xc5\xf6\xf5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ble_simpletest.py", line 15, in <module>
File "adafruit_ble/__init__.py", line 270, in start_scan
MemoryError: memory allocation failed, allocating 60122 bytes
>>>
Could it be reacting to a particularly odd packet?
It is working - with the try/except - on both the esp32s3 and on the nrf52840.
Do you see this on 7.3.3 as well, on nRF52840?
So far, I have not been able to reproduce it on the nrf52840 with 7.3.3
Is it always 60k bytes to allocate?
I have this issue on a nRF52840DK too, running a slightly modified BLE UART example:
# SPDX-FileCopyrightText: 2020 Dan Halbert for Adafruit Industries
#
# SPDX-License-Identifier: MIT
# Connect to an "eval()" service over BLE UART.
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService
ble = BLERadio()
uart_connection = None
while True:
print("Reading adverts forever..")
#advIter = ble.start_scan(ProvideServicesAdvertisement)
advIter = ble.start_scan() # get any advertisements
i = 0
for adv in advIter:
print("Adv %i" %i)
i = i+1
I eventually get the memory allocation error:
Traceback (most recent call last): File "code.py", line 21, in
File "adafruit_ble/init.py", line 271, in start_scan MemoryError: memory allocation failed, allocating 65293 bytes
Where line 21 was for adv in advIter:
I have been testing BLE on both a feather_esp32s3 no-psram and on an itsybitsy_nrf52840 and I am seeing the same failure when running the ble_simplest.py. It scans for awhile, then crashes with a memory failure. The failure can happen immediately or after some time. Is this a known issue?
this was run with
Adafruit CircuitPython 8.0.3 on 2023-02-23; Adafruit Feather ESP32S3 No PSRAM with ESP32S3
with the example from the bundleresults
I also have a test program to receive beacon packets and it has the same issue. I have implemented a try/except workaround, but is there something else I should be doing?
using this code