Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    Nicla Sense ME Large Array Crash

    Nicla Sense ME Large Array Crash


    Hi, when uploading the code below, which is using a "large" array, to the Arduino Nicla Sense ME, the following error message comes up:

    ++ MbedOS Error Info ++
    Error Status: 0x80FF0144 Code: 324 Module: 255
    Error Message: Assertion failed: _stack_buffer != NULL
    Location: 0x430B9
    File: ./mbed-os/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp+186
    Error Value: 0x0
    Current Thread: main Id: 0x200051B4 Entry: 0x19E6F StackSize: 0xC00 StackMem: 0x20004590 SP: 0x2000508C
    For more info, visit:
    -- MbedOS Error Info --

    This does not happen if the array is small (e.g. 2 instead of 800), or if the line "BHY2.begin();" is commented out. The example sketches work, but just adding a large array to the code leads to this error.
    The Code:

    #include "Arduino_BHY2.h"
    int all_readings[800];
    void setup() {
    all_readings[0] = 0;
    BHY2.begin(); // if this command is commented out: no error is thrown

    void loop() {
    BHY2.update(); // this line does not impact the error, so commenting it out has no effect on the error.

    19 REPLIES 19

    Long-established Member

    hi @hkayan

    The mbed-os library could be compiled using the github repo:

    You could follow the documentation within the README. Hopefully this helps a little bit and you get a smooth build.





    Thanks @zgg, I am trying that but confused how to build one for Nicla as it is not supported. The closest one seems like NFR52_DK, however when I generate my own library with that, it generates tons of error when trying to compile. The README states:

    For boards not supported by mainline Mbed OS, the same applies but you should provide the path of your Mbed OS fork:

    cd $sketchbook/hardware/arduino-git/mbed
    mkdir -p variants/$BRAND_NEW_BOARD_NAME/{libs,conf}
    ./mbed-os-to-arduino -r /path/to/mbed-os/fork/that/supports/new/board $BRAND_NEW_BOARD_NAME:$BRAND_NEW_BOARD_NAME

    There is mbed-os-nicla provided by Arduino, when I use that fork with the following command,


    command still generates the Nicla is not supported error. I would be really grateful if you can explain the steps.

    Long-established Member


    When I was building the mbed-os lib last time, it was based on repo (same but private at that time) which has fallen behind the public repo quite a lot now.

    I was basically running the script "./mbed-os-to-arduino " with proper arguments, with BOARD_NAME set as "NICLA".


    ./mbed-os-to-arduino -a -r ~/prj/mbed-os/ NICLA:NICLA


     Since it has been a long time since my last build I am not sure the command still works with the public repo.  When I get a chance I will see if I can build the lib with the latest public repo. 


    Long-established Member


    some update to share with you, I tried to build the libmbed.a from the source based on the public repo of the mbed-os core, and it worked well w/o any issues.

    Here are some details.

    Compile mbed-os from source

    This is useful if the user wants to custom the mbed-os and apply the changes to Arduino core.

    • Prerequisites
      • python 3.x: as a reference, I used 3.9.6
      • mbed CLI (1.x): as a reference, I used 1.10.5
    • Step 1 - Clone the repos
      • Clone the ArduinoCore-mbed 

        mkdir -p ~/Arduino/hardware/arduino

        cd ~/Arduino/hardware/arduino

        git clone

        cd ArduinoCore-mbed

      • Clone the Arduino-API repo

        mkdir -p ~/Arduino

        cd ~/Arduino

        git clone

        git clone


        cd ~/Arduino/hardware/arduino/ArduinoCore-mbed/cores/arduino 

        ln -sf ~/Arduino/ArduinoCore-API/api .

      • Clone mbed-os repo

        export mbed_os_repo=~/prj/mbed-os
        mkdir -p ~/prj
        cd ~/prj
        git clone

    • Step 2 - mbed-os-to-arduino [optional]
    This step is optional and can be tried when something goes wrong in the build process.
    change the "set -ef" to "set -xf" in file mbed-to-arduino
    • Step 3 - Preparation
    export arduino_core=~/Arduino/hardware/arduino/ArduinoCore-mbed
    cd $arduino_core
    ./mbed-os-to-arduino -a -r $mbed_os_repo NICLA:NICLA
    Note: in this step, the script  tries to apply some patches to the mbed-os repo, and this might cause some trivial failures (errors such as patches that cannot be applied), and this kind of errors could be ignored.
    • Step 4 - Make Configuration Changes if needed
    edit the file ./variants/NICLA/conf/mbed_app.json
    Changes such as stack size etc could be changed.
    This would affect the libmbed.a generated
    • Step 5 - Build the core (including the libmbed.a)
    ./mbed-os-to-arduino -r $mbed_os_repo NICLA:NICLA
    • Step 6 - Check result
    The script should say: "exit 0" at the end of the process, otherwise some errors have occured and should be fixed accordingly. Check the build environement (mbed CLI, python version etc)
    zg@ZG-TC:~/Arduino/hardware/arduino/ArduinoCore-mbed$ ls -lha variants/NICLA/libs/
    total 5.3M
    drwxrwxr-x 2 zg zg 4.0K Oct 24 20:09 .
    drwxrwxr-x 4 zg zg 4.0K Oct 24 20:19 ..
    -rw-rw-r-- 1 zg zg 5.3M Oct 24 20:19 libmbed.a

    Many thanks for this @zgg , but sadly, I coudn't get that working even if customized libs deployed. I have done some tests and found this. We are only allowed to use the 70% of the ram.

    RAM: [======= ] 70.9% (used 45608 bytes from 64288 bytes) -> If I pass 70% and activate both BLE and BHY sensors, I get memory error.

    I would really appreciate any lead on how to make use of BHI260AP's RAM as you suggested in your earlier replies.