Nicla Sense ME Running out of memory

I am participating in the K-Way + Arduino challenge and I am working on a solution that include the Nicla Sense ME running and Edge Impulse model and sending data through BLE, but the board can’t support BLE together with an Edge Impulse model.

I’ve tried different precompiled (optimized) mbed OS for the Nicla from this forum

This is the error with the Original BSP of the Nicla Sense ME 3.5.4:

Edge Impulse Sensor Fusion Inference

++ MbedOS Error Info ++
Error Status: 0x80FF0144 Code: 324 Module: 255
Error Message: Assertion failed: _stack_buffer != NULL
Location: 0x4B381
File: NRFCordioHCIDriver.cpp+186
Error Value: 0x0
Current Thread: main Id: 0x20003FA0 Entry: 0x22583 StackSize: 0xC00 StackMem: 0x20003FE8 SP: 0x20004AE4 
For more info, visit:
-- MbedOS Error Info --

The 3 options shared there doesn’t work for me, just receiving hard faults when trying them.

++ MbedOS Fault Handler ++

FaultType: HardFault

R   0: 2000BA28
R   1: 00000001
R   2: 20006564
R   3: 6C646E61
R   4: 2000372C
R   5: 00000026
R   6: 0005ECD9
R   7: 00000000
R   8: 00000000
R   9: 00000000
R  10: 00000000
R  11: 00000000
SP   : 20007488
LR   : 0001F811
PC   : 6C646E60
xPSR : 21070000
PSP  : 20007468
MSP  : 2000FFC0
CPUID: 410FC241
HFSR : 40000000
MMFSR: 00000000
BFSR : 00000001
UFSR : 00000000
DFSR : 00000000
AFSR : 00000000
Mode : Thread
Priv : Privileged
Stack: PSP

-- MbedOS Fault Handler --

++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0x6C646E60
Error Value: 0x2000A594
Current Thread: main Id: 0x20003F80 Entry: 0x22557 StackSize: 0xC00 StackMem: 0x200068D0 SP: 0x20007488 
For more info, visit:
-- MbedOS Error Info --

I would appreciate it if you can help me here, please.

I think that the ArduinoBLE library I am using is very big, maybe having a simplified version of it could help.


Yes, it is usually a memory issue, try a smaller BLE stack can be the solution.

How can I define the BLE reserved stack?

1 Like

Hello guys. I’m having the same issue. The problem appears exactly when I call the function BLE.begin(). Before this everything is okey.

Is there a guide on how to modify the Stack reserved for the BLE?

1 Like

The key was using Platform IO, thanks!

1 Like

Can you give me a brief explanation of how to do that?

@Pablo9815 put an “at” sign in front of the name and @mcmchris will get an email notice.

Perfect @MMarcial I’ll do that.
@mcmchris Can you give me a brief explanation of how to do that?
Thank you

I have had the same exact issues and I am going through the same steps (the v1-3 of libmbed and mbed_config files) and those didn’t work. @mcmchris, if you could, some details would be appreciated on how you got it working on PlatformIO, for those of us who don’t use that IDE often. Thanks!

OK, I was able to figure out how to import a project into PlatformIO (an extension in VS Code) and the project does compile and run. However, I get an out of memory error (Failed to run DSP process (-1002)) as soon as I make a BLE connection to my app. I remember running into memory issues on a prior Nicla Sense ME project and I ended up just using it as a shield on the MKR Wifi 1010. Obviously, with the K-way project we can’t do that.

Has anyone been successful in running an EI model and ArduinoBLE without running out of memory? I feel I have a pretty lightweight accelerometer model with a 1 second inference window. Any suggestions? Thanks!

Hi all, apologies for the multiple messages, but I found a project that was able to figure out the memory constraint issue. See here. You have to go into the Arduino_BHY2 library and change the buffer size (WORK_BUFFER_SIZE) in BoschSensorTec.h. In his project, @nick.bild changed the value from 2048 to 64, and that worked for me as well. I can now run inference and BLE at the same time, although I’m not sure what the second order effects are of changing the buffer size. For my relatively simple project, I think that should work.

@louis and @janjongboom , I’ve seen at least 3 people, plus myself, with this issue of running inference and BLE at the same time with the limited 64 kB SRAM of the Nicla Sense ME. We might want to get the word out that this change is required in order to not run out of memory while running an EI inference + BLE. Thanks! And thanks @nick.bild for documenting the required change!


I didn’t have to do that, but I’m glad you solved your problem.

1 Like

Hello @jlutzwpi, I tried this solution, but when I change the WORK_BUFFER_SIZE the serial monitor says ERR: Failed to run DSP process (-1002), at least it doesn’t show the memory issue.
Did you only change this parameter and then the system worked correctly?

That error message means you are out of memory. See this thread:

I also built and uploaded in PlatformIO per mcmchris’s suggestion.

Hi everybody, I’m also doing a project using an Edge Impulse model and sending the data trough BLE.
@mcmchris said the solution was using Platform IO but I can’t get it to work, my question is can you use the same libraries that you used in Arduino? and also do you have to do any additional configuration in Platform IO? It’s my first time using it and I’m a littlle bit lost.
I have also tried the solution of changing the value of WORK_BUFFER_SIZE and compiling in Arduino IDE but it doesn’t work.