Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Adding NUS to existing profile - how to get a 'link context' ?

Hi, 

I'm trying to add the NUS service to an existing application (freertos based, SDK15.2, already use a custom service)

  • I copied the relevant code snippets from the example
  • Modified the project setup - Add ble_nus.c & ble_link_ctx_manager.c, increased start address + 0x10 bytes (for the additional service uuid)
  • Updated sdk_config.h - increased NRF_SDH_BLE_VS_UUID_COUNT to 2 (was 1 for the prev proprietary service), BLE_NUS_ENABLED = 1

The app builds and runs to the point where I do BLE connect.

The program crash when ble_nus.c on_connect() function calls blcm_link_ctx_get(), as the 1st parameters p_nus->p_link_ctx_storage == NULL.

I had to add ble_link_ctx_manager.c to the project following the example project. However, I couldn't find what it does and how it is used/initialized

Any advice will be appreciated.

Thanks

Parents
  • Hi,

    Please check sdk_config.h. NRF_SDH_BLE_VS_UUID_COUNT parameter should  be greater than zero

    Softdevice should be configured to accept Vendor Specific UUIDs, like NUS Nordic UART Service.

    -Amanda H.

  • Hi, 

    NRF_SDH_BLE_VS_UUID_COUNT is set to 2 (see OP) as I have a proprietary service + NUS.

    Any insight about the 'packing' issue described above?

    Thanks

  • Hi, 

    After adding NUS to the project, you would need to allocate more RAM to the SoftDevice.

    Which version of SDK do you use?

    Could you provide the J-Link RTT log?

    -Amanda H.

  • you would need to allocate more RAM to the SoftDevice.

    I did. Otherwise one if the sd calls would have asserted (probably sd_ble_uuid_vs_add())

    Which version of SDK do you use?

    SDK 15.2, nRF52832, a project that is based on ble_app_hrs_freertos example

    Could you provide the J-Link RTT log?

    Attached RTT Client prints (after turning on BLE_NUS_CONFIG_LOG_ENABLED in sdk_config.h)

    ###RTT Client: ************************************************************
    ###RTT Client: *               SEGGER Microcontroller GmbH                *
    ###RTT Client: *   Solutions for real time microcontroller applications   *
    ###RTT Client: ************************************************************
    ###RTT Client: *                                                          *
    ###RTT Client: *       (c) 2012 - 2016  SEGGER Microcontroller GmbH       *
    ###RTT Client: *                                                          *
    ###RTT Client: *     www.segger.com     Support: [email protected]       *
    ###RTT Client: *                                                          *
    ###RTT Client: ************************************************************
    ###RTT Client: *                                                          *
    ###RTT Client: * SEGGER J-Link RTT Client   Compiled Aug 30 2018 17:38:24 *
    ###RTT Client: *                                                          *
    ###RTT Client: ************************************************************
    
    ###RTT Client: -----------------------------------------------
    ###RTT Client: Connecting to J-Link RTT Server via localhost:19021 .... Connected.
    SEGGER J-Link V6.46 - Real time terminal output
    J-Link OB-SAM3U128-V2-NordicSemi compiled Jan  7 2019 14:07:15 V1.0, SN=682324592
    Process: UV4.exe
    <info> app: *** myApp started [Jul  9 2019 22:52:34] ***
    <info> app: <<<===  myApp 0.20.28.CF771A (Jul  9 2019 22:52:34) starting... ===>>>
    <info> app: *** myApp started [Jul  9 2019 22:52:34] ***
    <info> app: <<<===  myApp 0.20.28.CF771A (Jul  9 2019 22:52:34) starting... ===>>>
    <info> app: Fast advertising.
    <warning> app:  !! Pulse fault: status code = 0x40
    <warning> app:     Pulse fault cleared
    <error> hardfault: HARD FAULT at 0x0002E286                //  << This line triggered on connection
    <error> hardfault:   R0:  0x00000000  R1:  0x00000000  R2:  0x200067F0  R3:  0x00000000
    <error> hardfault:   R12: 0x000001F3  LR:  0x0003886F  PSR: 0x61000000
    <error> hardfault: Cause: Data bus error (PC value stacked for the exception return points to the instruction that caused the fault).
    <error> hardfault: Bus Fault Address: 0x00200028

Reply
  • you would need to allocate more RAM to the SoftDevice.

    I did. Otherwise one if the sd calls would have asserted (probably sd_ble_uuid_vs_add())

    Which version of SDK do you use?

    SDK 15.2, nRF52832, a project that is based on ble_app_hrs_freertos example

    Could you provide the J-Link RTT log?

    Attached RTT Client prints (after turning on BLE_NUS_CONFIG_LOG_ENABLED in sdk_config.h)

    ###RTT Client: ************************************************************
    ###RTT Client: *               SEGGER Microcontroller GmbH                *
    ###RTT Client: *   Solutions for real time microcontroller applications   *
    ###RTT Client: ************************************************************
    ###RTT Client: *                                                          *
    ###RTT Client: *       (c) 2012 - 2016  SEGGER Microcontroller GmbH       *
    ###RTT Client: *                                                          *
    ###RTT Client: *     www.segger.com     Support: [email protected]       *
    ###RTT Client: *                                                          *
    ###RTT Client: ************************************************************
    ###RTT Client: *                                                          *
    ###RTT Client: * SEGGER J-Link RTT Client   Compiled Aug 30 2018 17:38:24 *
    ###RTT Client: *                                                          *
    ###RTT Client: ************************************************************
    
    ###RTT Client: -----------------------------------------------
    ###RTT Client: Connecting to J-Link RTT Server via localhost:19021 .... Connected.
    SEGGER J-Link V6.46 - Real time terminal output
    J-Link OB-SAM3U128-V2-NordicSemi compiled Jan  7 2019 14:07:15 V1.0, SN=682324592
    Process: UV4.exe
    <info> app: *** myApp started [Jul  9 2019 22:52:34] ***
    <info> app: <<<===  myApp 0.20.28.CF771A (Jul  9 2019 22:52:34) starting... ===>>>
    <info> app: *** myApp started [Jul  9 2019 22:52:34] ***
    <info> app: <<<===  myApp 0.20.28.CF771A (Jul  9 2019 22:52:34) starting... ===>>>
    <info> app: Fast advertising.
    <warning> app:  !! Pulse fault: status code = 0x40
    <warning> app:     Pulse fault cleared
    <error> hardfault: HARD FAULT at 0x0002E286                //  << This line triggered on connection
    <error> hardfault:   R0:  0x00000000  R1:  0x00000000  R2:  0x200067F0  R3:  0x00000000
    <error> hardfault:   R12: 0x000001F3  LR:  0x0003886F  PSR: 0x61000000
    <error> hardfault: Cause: Data bus error (PC value stacked for the exception return points to the instruction that caused the fault).
    <error> hardfault: Bus Fault Address: 0x00200028

Children
Related