This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SES import of SDK 10.0 examples ble_app_uart

Hello,

I need to develop two applications for nRF51822 using SES version 4.18 (macOS). One is a DFU bootloader. The other is an application based on the ble_app_uart (ble_peripheral) example of SDK 10.0. I will be using SoftDevice 110 and I understand that SDK 10.0 is that latest version compatible with S110.

I've been following this blog post to import a Keil project. Seems it is written for nRF52 development using an older version of SES (v3.10e) and is, therefore, inaccurate in some ways.

I would be grateful for some assistance in importing/building the ble_app_uart example from SDK 10.0 into SES.

The first step asks to install the CMSIS-CORE Support Package. In SES 4.18, it appears this package is already installed.

After importing the file nRF51SDK/examples/ble_peripheral/ble_app_uart/pca10028/s110/arm5_no_packs/ble_app_uart_s110_pca10028.uvprojx, I see a project configuration named nrf51422_xxac_s110. As I am developing for nRF51822, I wonder about additional project configuration changes needed? I understand that the nRF51422 is an nRF51822 with ANT support. I will be developing/testing with an nRF51 DK.

In the section Adding nRF5 MDK Files ...

I create embedded_studio folder inside nRF51SDK/components/toolchain.

I download ses_nrf51_startup.s and ses_nrf52_startup.s and save them into nRF51SDK/components/toolchain/embedded_studio/

When I download ses_nrf51_startup.s and ses_nrf52_startup.s, they download as 3324.ses_nrf51_startup.s and 5543.ses_nrf52_startup.s. I rename to ses_nrf51_startup.s and ses_nrf52_startup.s.

I remove Cortex_M_Startup.s from Internal Files in project explorer.

I notice that the remaining file in Internal Files is SEGGER_THUMB_Startup.s and I do not see thumb_crt0.s.

Next instructed to add NRF5_SDK/components/toolchain/system_nrf52.c to Internal Files. I assume that since I'm importing a project for nRF51, I should add system_nrf51.c instead, which I do. Same for NRF5_SDK/components/toolchain/embedded_studio/ses_nrf52_startup.s - I add ses_nrf51_startup.s instead.

As instructed, I add ../../../../../../components/device to the Preprocessor User Include Directories, which results in the following:

../../../../../../components/device
../../../config
../../../../../bsp
../../../../../../components/toolchain
../../../../../../components/ble/ble_advertising
../../../../../../components/ble/ble_services/ble_nus
../../../../../../components/ble/common
../../../../../../components/drivers_nrf/common
../../../../../../components/drivers_nrf/delay
../../../../../../components/drivers_nrf/gpiote
../../../../../../components/drivers_nrf/hal
../../../../../../components/drivers_nrf/pstorage
../../../../../../components/drivers_nrf/uart
../../../../../../components/drivers_nrf/config
../../../../../../components/libraries/button
../../../../../../components/libraries/fifo
../../../../../../components/libraries/timer
../../../../../../components/libraries/trace
../../../../../../components/libraries/uart
../../../../../../components/libraries/util
../../../../../../components/softdevice/common/softdevice_handler
../../../../../../components/softdevice/s110/headers

It appears that Peer Manager/Flash Data Storage applies if the application uses Peer Manager. It appears that ble_app_uart example of SDK 10.0 does not use Peer Manager, so I'm not sure if any of the instructions in Peer Manager/Flash Data Storage apply.

I see no flash_placement.xml file inside nRF51SDK/examples/ble_peripheral/ble_app_uart/pca10028/s110/arm5_no_packs. Do I still need to create this file?

I do see thumb_crt0.s inside SEGGER_app_folder/source, but not sure if the changes for fs_data should be added. I presume no.

I notice that there's no sdk_config.h file and appears this file was added to the SDK architecture after SDK 10.0?

So I do NOT do any of the steps in Peer Manager/Flash Data Storage and proceed to attempt to build the application. I got the compile error "nrf.h No such file or directory". I found that this file exists inside nRF51SDK/components/toolchain/gcc so I added that to the User Include Directories and build proceeds but then I get the compile error seen in attached compile log. I'm now lost.

Appreciate any assistance to getting ble_app_uart (ble_peripheral) of SDK 10.0 successfully imported/built for nRF51 DK (compatible with nRF51822).

I see that using S130 would mean I could use SDK 12.3 instead of 10.0. All my application needs is basic peripheral support plus access to the Timeslot API. I presume S130 would add unnecessary capabilities and size, so would prefer to stick with S110 and SDK 10.0.

Many thanks,

Tim

  • Thanks Edvin. --no-backup fixed the mergehex issue. When I merge bootloader_s130+buttonless_app and program nRF51 DK and reset, LED 3 (of 4) blinks (500 ms on, 500 ms off) and it appears the bootloader does not run the app (no advertising of "Nordic_Buttonless"). Then I built ble_app_uart example and used it instead of experimental_ble_app_buttonless_dfu and it worked. The bootloader starts the app, it advertises, I can connect/disconnect with iOS nRF Connect.

    Next I'll try extending ble_app_uart for buttonless dfu using experimental_ble_app_buttonless_dfu as a guide and also this Nordic Infocenter content. Any other useful resources?

    Thanks to Jimmy Wong, I have ble_app_uart working in SES so I can debug.

    Many thanks,

    Tim

  • Hello,

     

    Tim said:
    --no-backup fixed the mergehex issue.

     Good.

     

    Tim said:
    LED 3 (of 4)

     Hehe, I struggle at quite a bit with this, since the DK marks them 1-4, some parts of the SDK uses 1-4, but others use 0-3 :) But I understand what you mean.

    Actually, I saw this yesterday, when I did some testing. I assumed I had introduced some errors in the buttonless examples at an earlier point in time, so I tested the ble_app_uart example instead of the ble_app_buttonless. The reqson for my suspicion was that I tested the pca10040_debug bootloader (I don't have an nRF51 DK in the home office). The log said that the application was valid, and that the bootloader started the app, but then the log comes from the bootloader again, suggesting that the application has failed, and triggered a reset.

    Can you try with another application? e.g. the ble_app_uart example? There is something fishy with this bootloader since it prints "app is valid" several times before "starting application" (this is only printed in the RTT log if you use the pca100[40/28]_debug bootloader project).

    Can you try to use the ble_app_uart application instead of the buttonless example, just to check whether this works on the 51DK (since I can't do that).

    BR,

    E

  • Thanks Edvin. Yes, I built ble_app_uart and used it in place of experimental_ble_app_buttonless_dfu and it works - the bootloader runs the app. The ble_app_uart is not buttonless dfu enabled so it doesn't offer the dfu service, which is necessary for buttonless dfu to be triggered by iOS central. So I proceeded to extend ble_app_uart with buttonless dfu support by following the experimental_ble_app_buttonless_dfu example. Here are the steps:

    Added the following source files to the project:

    nrf_dfu_flash_buttonless.c
    components/ble/ble_services/ble_dfu/ble_dfu.c
    components/libraries/bootloader/dfu/nrf_dfu_settings.c
    components/lobraries/crc32/crc32.c

    Added required paths to user include directories:

    ./../../../../../../components/libraries/bootloader/dfu
    ./../../../../../../components/ble/ble_services/ble_dfu

    Added to c_preprocesor_definitions:

    NRF_DFU_SETTINGS_VERSION=1

    In sdkconfig.h, defined:

    #define CRC32_ENABLED 1

    Modifications to main.c:

    Added:

    #include "ble_dfu.h"

    Added:

    static ble_dfu_t m_dfus;   /**< Structure used to identify the DFU service. */
    
    static void ble_dfu_evt_handler(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt)
    {
        switch (p_evt->type)
        {
            case BLE_DFU_EVT_INDICATION_DISABLED:
                NRF_LOG_INFO("Indication for BLE_DFU is disabled\r\n");
                break;
    
            case BLE_DFU_EVT_INDICATION_ENABLED:
                NRF_LOG_INFO("Indication for BLE_DFU is enabled\r\n");
                break;
    
            case BLE_DFU_EVT_ENTERING_BOOTLOADER:
                NRF_LOG_INFO("Device is entering bootloader mode!\r\n");
                break;
            default:
                NRF_LOG_INFO("Unknown event from ble_dfu\r\n");
                break;
        }
    }

    Added to services_init(void):

        ble_dfu_init_t dfus_init;
    
        // Initialize the Device Firmware Update Service.
        memset(&dfus_init, 0, sizeof(dfus_init));
    
        dfus_init.evt_handler                               = ble_dfu_evt_handler;
        dfus_init.ctrl_point_security_req_write_perm        = SEC_SIGNED;
        dfus_init.ctrl_point_security_req_cccd_write_perm   = SEC_SIGNED;
    
        err_code = ble_dfu_init(&m_dfus, &dfus_init);
        APP_ERROR_CHECK(err_code);

    Added to ble_evt_dispatch(ble_evt_t * p_ble_evt):

    ble_dfu_on_ble_evt(&m_dfus, p_ble_evt);

    Changed define:

    #define IS_SRVC_CHANGED_CHARACT_PRESENT 1

    Here's the build log and errors:

    Building ‘ble_app_uart_pca10028_s130’ from solution ‘ble_app_uart_pca10028_s130’ in configuration ‘Debug’
      Compiling ‘nrf_log_frontend.c’
      Compiling ‘nrf_log_backend_serial.c’
      Compiling ‘app_button.c’
      Compiling ‘app_error.c’
      Compiling ‘app_error_weak.c’
      Compiling ‘app_uart_fifo.c’
      Compiling ‘app_timer.c’
      Compiling ‘app_fifo.c’
      Compiling ‘app_util_platform.c’
      Compiling ‘fstorage.c’
      Compiling ‘hardfault_implementation.c’
      Compiling ‘nrf_assert.c’
      Compiling ‘retarget.c’
      Compiling ‘sdk_errors.c’
      Compiling ‘app_scheduler.c’
      Compiling ‘boards.c’
      Compiling ‘crc32.c’
      Compiling ‘app_timer_appsh.c’
      Compiling ‘nrf_drv_clock.c’
      Compiling ‘nrf_drv_common.c’
      Compiling ‘nrf_drv_adc.c’
      Compiling ‘nrf_drv_uart.c’
      Compiling ‘nrf_drv_gpiote.c’
      Compiling ‘bsp.c’
      Compiling ‘main.c’
      Compiling ‘bsp_nfc.c’
      Compiling ‘bsp_btn_ble.c’
      Compiling ‘SEGGER_RTT.c’
      Compiling ‘nrf_dfu_flash_buttonless.c’
      Compiling ‘ble_advertising.c’
      Compiling ‘ble_advdata.c’
      Compiling ‘ble_srv_common.c’
      Compiling ‘ble_conn_params.c’
      Compiling ‘ble_dfu.c’
      Compiling ‘SEGGER_RTT_Syscalls_SES.c’
      Compiling ‘nrf_dfu_settings.c’
      Compiling ‘ble_bas.c’
      Compiling ‘ble_nus.c’
      Compiling ‘softdevice_handler.c’
      Linking ble_app_uart_pca10028_s130.elf
        Output/Debug/Exe/ble_app_uart_pca10028_s130.elf section `.bootloaderSettings' will not fit in region `UNPLACED_SECTIONS'
        region `UNPLACED_SECTIONS' overflowed by 1024 bytes
    Build failed

    I found this post but don't understand exactly what needs to be added to memory segments. How can I learn about this?

    Also, I find it odd that in both SDK 10.0 and 15.3, buttonless DFU extensions for apps requires a function to gracefully shutdown the app, yet I don't see this in the experimental_ble_app_buttonless_dfu example in SDK 12.3. Confused.

    Thanks for your help with my build errors, and for your guidance in extending ble_app_uart for buttonless dfu.

    Tim

Related