SES vs Ozone (nrf52840 BLE & UART (NUSb))

Hello Nordic community,

I'm currently working on a project that involves BLE (Bluetooth Low Energy) using UART configuration alongside FRTOS (FreeRTOS) in a PCA10056 dk (nrf52840). After diving into the topic, I've found that integrating BLE with NUS (Nordic UART Service) into an FRTOS project can be quite challenging.

In my search for a solution, I stumbled upon a helpful resource:  Creating a working BLE NUS (Nordic UART Service) example with FreeRTOS . This post suggests using a preconfigured system that already includes FRTOS and the NUS UART services.

I've experimented with this project using SES (Segger Embedded Studio), and the debugger functions smoothly. However, I'm more accustomed to working with makefiles and VSC (Visual Studio Code). Therefore, I have tried to build the project using make commands (and the same makefile of the project without any modification (which it is in the following path: usbd_ble_uart_freertos\pca10056\s140\armgcc)) and then debugging with Ozone. To my surprise, the same code did not work well. after performing:

/**
 * @brief Function for the SoftDevice initialization.
 *
 * @details This function initializes the SoftDevice and the BLE event interrupt.
 */
static void ble_stack_init(void)
{
    ret_code_t err_code;

    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);

the error code returned  from  nrf_sdh_enable_request(); is 8. But when I run the same project in SES, I do not have this error.

Could my issue be related to how the SoftDevice is being flashed? Just to reiterate, I'm utilizing the makefile provided by the SDK, found in the example directory at "usbd_ble_uart_freertos\pca10056\s140\armgcc". The only difference is that I added this line to get an .elf file output:

$(OUTPUT_DIRECTORY)/nrf52840_xxaa.elf: $(OUTPUT_DIRECTORY)/nrf52840_xxaa.out
  @mv $< $@

I am using the latest version of the SDK: nRF5_SDK_17.1.0_ddde560

  • Hi,

    When you flash a Segger Embedded Studio example project using the SoftDevice the SoftDevice .hex is also automatically programmed (as it is added as an additional load file in the project). When you use make flash, that is not the case. However, most example Makefile projects includes a "make flash_softdevice" target, which you can use to program the SoftDevice. So you need to do that as well (or program the SoftDevice in another way).

  • Hi, Einar.

    Yes, you are right. However, if I execute the command "make", the resulting .elf file should work as well, right? (for debugging with ozone, I do need the .elf file).

    The problem is, when compiling and building the project with SES, it works fine, but when I compile it with make (using make -j24), I have that error exposed above (nrf_sdh_enable_request() returns error code 8).

    do you have any clue why this happens?

  • The resulting .elf file does not include the SoftDevice. So if your project needs the SoftDevice (like any BLE project), it will not work without you also flashing the SoftDevice. In other words, you must explicitly flash the SoftDevice.

    Moreover, debugging SoftDevice projects via Ozone does work and shold work well if you attach to a runnign target. But by default it will start executing from the start address of the .elf file, which for a SfotDevice project is not address 0, but the application start address. And in this case, the MBR will not have run and the MBR and SoftDevice is in a bad state. So you need to ensure that you configure ozone to start from address 0.

    (I would recomend that you sick with SES as that way you get all this working out of the box. You can still program in VS Code or your other faviourite editor or IDE, but build and debug from SES. That is of course up to you, but that way everythign would simply work out of the box, particularily i fyou use the SES version that is described in the SDK release notes, as that is what was used for release testing the SDK).

Related