This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How can we use nrf51822 BLE services with RIOT OS without accessing to the lower layers ?

Hello,

We are French students in a school of engineers. We are developing a project based on the nrf51822.

Actually, we implemented RIOT OS on this SoC and we would like to use nrf51822 BLE features. Nordic Semiconductors provides SoftDevices (s110, s120,…) allowing the use of BLE.

How can we use nrf51822 BLE services with RIOT OS without accessing to the lower layers ? Do lirbraries exist allowing us to use nrf51822 BLE services under RIOT OS ?

Thank you for the further answers.

Parents
  • There is no existing libraries in RIOT OS for handling the s110 BLE stack. Maybe you could try to use the libraries in the nRF SDK. I successfully managed to compile RIOT OS while including the softdevice_hander.h.

    You need to add the INCLUDES and some CFLAGS to the Makefile:

    INCLUDES += -I../../sdk7.2/components/toolchain/gcc
    INCLUDES += -I../../sdk7.2/components/toolchain
    INCLUDES += -I../../sdk7.2/components/libraries/button
    INCLUDES += -I../../sdk7.2/components/libraries/sensorsim
    INCLUDES += -I../../sdk7.2/components/ble/ble_services/ble_hrs
    INCLUDES += -I../../sdk7.2/components/ble/ble_services/ble_dis
    INCLUDES += -I../../sdk7.2/components/ble/ble_services/ble_bas
    INCLUDES += -I../../sdk7.2/components/softdevice/s110/headers
    INCLUDES += -I../../sdk7.2/components/ble/common
    INCLUDES += -I../../sdk7.2/components/libraries/timer
    INCLUDES += -I../../sdk7.2/components/libraries/gpiote
    INCLUDES += -I../../sdk7.2/components/drivers_nrf/hal
    INCLUDES += -I../../sdk7.2/components/ble/device_manager
    INCLUDES += -I../../sdk7.2/components/ble/device_manager/config
    INCLUDES += -I../../sdk7.2/components/softdevice/common/softdevice_handler
    INCLUDES += -I../../sdk7.2/components/libraries/scheduler
    INCLUDES += -I../../sdk7.2/components/drivers_nrf/pstorage
    INCLUDES += -I../../sdk7.2/components/drivers_nrf/pstorage/config
    INCLUDES += -I../../sdk7.2/components/libraries/util
    INCLUDES += -I../../sdk7.2/components/libraries/trace
    INCLUDES += -I../../sdk7.2/components/drivers_nrf/uart
    INCLUDES += -I../../sdk7.2/components/libraries/fifo
    INCLUDES += -I../../sdk7.2/examples/bsp
    
    CFLAGS += -DNRF51
    CFLAGS += -DBLE_STACK_SUPPORT_REQD
    CFLAGS += -DS110
    CFLAGS += -DSOFTDEVICE_PRESENT
    

    In the RIOT/cpu/nrf51822/nrf51822qfaa_linkerscript.ld linker script, you need to change the start address of the ROM and RAM:

    rom (rx)    : ORIGIN = 0x00016000, LENGTH = 256K
    ram (rwx)   : ORIGIN = 0x20002000, LENGTH = 16K
    

    Also, the softdevice must be flashed on to the chip.

    By compiling the following main.c code, I was able to get a response from the SoftDevice and print the value over UART.

    #include <stdio.h>
    #include "softdevice_handler.h"
    
    int main(void)
    {
        puts("Hello World!");
        uint8_t a;
        uint16_t b;
        char ret = sd_ble_evt_get(&a,&b);
        printf("output %i\n",ret);
        return 0;
    }
    

    If it is possible to use the whole BLE stack I don't know, I guess you just have to try.

Reply
  • There is no existing libraries in RIOT OS for handling the s110 BLE stack. Maybe you could try to use the libraries in the nRF SDK. I successfully managed to compile RIOT OS while including the softdevice_hander.h.

    You need to add the INCLUDES and some CFLAGS to the Makefile:

    INCLUDES += -I../../sdk7.2/components/toolchain/gcc
    INCLUDES += -I../../sdk7.2/components/toolchain
    INCLUDES += -I../../sdk7.2/components/libraries/button
    INCLUDES += -I../../sdk7.2/components/libraries/sensorsim
    INCLUDES += -I../../sdk7.2/components/ble/ble_services/ble_hrs
    INCLUDES += -I../../sdk7.2/components/ble/ble_services/ble_dis
    INCLUDES += -I../../sdk7.2/components/ble/ble_services/ble_bas
    INCLUDES += -I../../sdk7.2/components/softdevice/s110/headers
    INCLUDES += -I../../sdk7.2/components/ble/common
    INCLUDES += -I../../sdk7.2/components/libraries/timer
    INCLUDES += -I../../sdk7.2/components/libraries/gpiote
    INCLUDES += -I../../sdk7.2/components/drivers_nrf/hal
    INCLUDES += -I../../sdk7.2/components/ble/device_manager
    INCLUDES += -I../../sdk7.2/components/ble/device_manager/config
    INCLUDES += -I../../sdk7.2/components/softdevice/common/softdevice_handler
    INCLUDES += -I../../sdk7.2/components/libraries/scheduler
    INCLUDES += -I../../sdk7.2/components/drivers_nrf/pstorage
    INCLUDES += -I../../sdk7.2/components/drivers_nrf/pstorage/config
    INCLUDES += -I../../sdk7.2/components/libraries/util
    INCLUDES += -I../../sdk7.2/components/libraries/trace
    INCLUDES += -I../../sdk7.2/components/drivers_nrf/uart
    INCLUDES += -I../../sdk7.2/components/libraries/fifo
    INCLUDES += -I../../sdk7.2/examples/bsp
    
    CFLAGS += -DNRF51
    CFLAGS += -DBLE_STACK_SUPPORT_REQD
    CFLAGS += -DS110
    CFLAGS += -DSOFTDEVICE_PRESENT
    

    In the RIOT/cpu/nrf51822/nrf51822qfaa_linkerscript.ld linker script, you need to change the start address of the ROM and RAM:

    rom (rx)    : ORIGIN = 0x00016000, LENGTH = 256K
    ram (rwx)   : ORIGIN = 0x20002000, LENGTH = 16K
    

    Also, the softdevice must be flashed on to the chip.

    By compiling the following main.c code, I was able to get a response from the SoftDevice and print the value over UART.

    #include <stdio.h>
    #include "softdevice_handler.h"
    
    int main(void)
    {
        puts("Hello World!");
        uint8_t a;
        uint16_t b;
        char ret = sd_ble_evt_get(&a,&b);
        printf("output %i\n",ret);
        return 0;
    }
    

    If it is possible to use the whole BLE stack I don't know, I guess you just have to try.

Children
  • Can you go into more detail as to how you got this to work? I have done exactly as you did above and am using the command "BOARD=pca10005 make -B clean flash" but am getting the following error: ***** Error: Programming failed @ address 0x00000000 (block verification error) Error while programming flash: Programming failed.

    It seems that it is still trying to program flash at 0x0 even though I changed the linker script file. Any thoughts or suggestions?

Related