Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory allocation issue on the NRF51DK board. #76

Closed
marcuschangarm opened this issue Nov 20, 2015 · 4 comments
Closed

Memory allocation issue on the NRF51DK board. #76

marcuschangarm opened this issue Nov 20, 2015 · 4 comments

Comments

@marcuschangarm
Copy link
Contributor

After upgrading from v0.4.8 to v2.0.7 I'm getting hard faults when using GattClient.

I can circumvent the problem by reverting these two functions from:

https://github.com/ARMmbed/ble-nrf51822/blob/master/source/nRF5xGattClient.cpp#L19-L26
https://github.com/ARMmbed/ble-nrf51822/blob/master/source/nRF5xSecurityManager.cpp#L19-L25

To:

nRF5xGattClient &nRF5xGattClient::getInstance(void) {
    static nRF5xGattClient nRFGattClientSingleton;
    return nRFGattClientSingleton;
}

nRF5xSecurityManager &nRF5xSecurityManager::getInstance(void) {
    static nRF5xSecurityManager m_instance;
    return m_instance;
}

The test application used: https://github.com/ARMmbed/ble-blocktransfer-mbed

@rgrover
Copy link
Contributor

rgrover commented Nov 23, 2015

@marcuschangarm are the getInstance methoda for GattClient or SecurityManager getting called from an interrupt context? Does the fault happen on a central or a peripheral? Can you provide more information about the context in which the fault happens? Have you got a stack trace?

I'm not too tied to the current implementation using new. I'm also happy with a yotta-config based elimination of GattClient (or even GattServer features).

@andresag01 Could you please work with @marcuschangarm to reproduce/investigate this issue?

@marcuschangarm
Copy link
Contributor Author

All my calls are through minar. The problem seems to surface in the gatt client event handler, but this feels more like a memory corruption problem since the location changes when I change the application.

#0  HardFault_Handler () at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/mbed-hal-nrf51822-mcu/bootstrap_gcc/startup_nRF51822.S:164
#1  <signal handler called>
#2  0x0411ffde in ?? ()
#3  0x00026332 in processHVXEvent (this=<optimized out>, params=<optimized out>)
    at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/ble/ble/GattClient.h:308
#4  bleGattcEventHandler (p_ble_evt=p_ble_evt@entry=0x20002c64 <btle_init::BLE_EVT_BUFFER>)
    at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/ble-nrf51822/source/btle/btle_discovery.cpp:91
#5  0x0001dfb0 in btle_handler (p_ble_evt=0x20002c64 <btle_init::BLE_EVT_BUFFER>)
    at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/ble-nrf51822/source/btle/btle.cpp:138
#6  0x0001e426 in intern_softdevice_events_execute ()
    at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/ble-nrf51822/source/nordic-sdk/components/softdevice/common/softdevice_handler/softdevice_handler.c:149
#7  0x000248fc in mbed::util::FunctionPointer0<void>::staticcaller (object=<optimized out>, member=<optimized out>, arg=<optimized out>)
    at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/core-util/core-util/FunctionPointer.h:113
#8  0x00020d0e in call (arg=<optimized out>, this=<optimized out>)
    at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/core-util/core-util/FunctionPointerBase.h:80
#9  call (this=<optimized out>) at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/core-util/core-util/FunctionPointerBind.h:44
#10 operator() (this=<optimized out>) at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/core-util/core-util/FunctionPointerBind.h:104
#11 minar::SchedulerData::start (this=0x20003670) at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/minar/source/minar.cpp:471
#12 0x00020d3c in minar::Scheduler::start () at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/minar/source/minar.cpp:296
#13 0x00020874 in main () at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/mbed-drivers/source/retarget.cpp:458
(gdb) f 4
#4  bleGattcEventHandler (p_ble_evt=p_ble_evt@entry=0x20002c64 <btle_init::BLE_EVT_BUFFER>)
    at /Users/marcha01/mbed/sdk/ble-blocktransfer-mbed/yotta_modules/ble-nrf51822/source/btle/btle_discovery.cpp:91
91                  nRF5xGattClient::getInstance().processHVXEvent(&params);
(gdb) list
86                  params.handle     = p_ble_evt->evt.gattc_evt.params.hvx.handle;
87                  params.type       = static_cast<HVXType_t>(p_ble_evt->evt.gattc_evt.params.hvx.type);
88                  params.len        = p_ble_evt->evt.gattc_evt.params.hvx.len;
89                  params.data       = p_ble_evt->evt.gattc_evt.params.hvx.data;
90  
91                  nRF5xGattClient::getInstance().processHVXEvent(&params);
92              }
93              break;
94      }
95  

@ciarmcom
Copy link
Member

ARM Internal Ref: IOTSFW-1284

@andresag01
Copy link

It seems that this commit fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants