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

Parents
  • UPDATE: If I remove retarget.c from project, compile succeeds, but then get linker error. See attached log.

    Thank you,

    Tim

  • Hello Tim,

    I don't know if the tutorial you point to will work for SDK10. It is quite old, and the guide was written for SDK 12 and primarily for nRF51/52 with S130/132.

    I am not saying it will not work, but I don't know the exact setup.

    Try to use the attached thumb_crt0.s file:
    thumb_crt0.s

    Try to click "import section placement in SES to generate the flash_placement.xml file. 

    I remember there were some issues with printf(). I found this workaround in an internal email. You can try to apply it:

    Note the thumb_crt0.s has added sections for loading on boot (one “nrf_section” to load them all), and the reference to debug_putchar is removed.

    If using printf + UART, add something like this to your project:

    int __putchar(int ch)
    {
      return app_uart_put(ch);
    }

    Try this, and let me know how that works.

    Best regards,

    Edvin

  • Hi Edvin. Correct, it’s ble_app_uart that I’m getting build errors after extending to support buttonless dfu.

    It looks like it's something to do with adding a second service in services_init(). I add this code:

        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);

    and the link error now occurs.

    Building ‘ble_app_uart_pca10028_s130’ from solution ‘ble_app_uart_pca10028_s130’ in configuration ‘Debug’
      Compiling ‘main.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

    If I comment out:

    err_code = ble_dfu_init(&m_dfus, &dfus_init);

    it builds successfully. I've read that when you increase the number of ble services, you need to change RAM start and size to allow more memory for the SoftDevice. Add 16 to the RAM start address and subtract 16 from the size. I understand you do this with project -> options -> Linker -> section placement macros. Current values are:

    I tried changing RAM_START to 0x20001ff8 and RAM_SIZE to 0x2008, but still link error.

    I'm using this flash_placement.xml file:

    <!DOCTYPE Linker_Placement_File>
    <Root name="Flash Section Placement">
      <MemorySegment name="FLASH" start="$(FLASH_PH_START)" size="$(FLASH_PH_SIZE)">
        <ProgramSection load="no" name=".reserved_flash" start="$(FLASH_PH_START)" size="$(FLASH_START)-$(FLASH_PH_START)" />
        <ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START)" />
        <ProgramSection alignment="4" load="Yes" name=".init" />
        <ProgramSection alignment="4" load="Yes" name=".init_rodata" />
        <ProgramSection alignment="4" load="Yes" name=".text" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_soc_observers" inputsections="*(SORT(.sdh_soc_observers*))" address_symbol="__start_sdh_soc_observers" end_symbol="__stop_sdh_soc_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_ble_observers" inputsections="*(SORT(.sdh_ble_observers*))" address_symbol="__start_sdh_ble_observers" end_symbol="__stop_sdh_ble_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".pwr_mgmt_data" inputsections="*(SORT(.pwr_mgmt_data*))" address_symbol="__start_pwr_mgmt_data" end_symbol="__stop_pwr_mgmt_data" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".log_const_data" inputsections="*(SORT(.log_const_data*))" address_symbol="__start_log_const_data" end_symbol="__stop_log_const_data" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_req_observers" inputsections="*(SORT(.sdh_req_observers*))" address_symbol="__start_sdh_req_observers" end_symbol="__stop_sdh_req_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_state_observers" inputsections="*(SORT(.sdh_state_observers*))" address_symbol="__start_sdh_state_observers" end_symbol="__stop_sdh_state_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_stack_observers" inputsections="*(SORT(.sdh_stack_observers*))" address_symbol="__start_sdh_stack_observers" end_symbol="__stop_sdh_stack_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".cli_command" inputsections="*(.cli_command*)" address_symbol="__start_cli_command" end_symbol="__stop_cli_command" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".nrf_sections" address_symbol="__start_nrf_sections" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".log_dynamic_data"  inputsections="*(SORT(.log_dynamic_data*))" runin=".log_dynamic_data_run"/>
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".fs_data"  inputsections="*(.fs_data*)" runin=".fs_data_run"/>
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".cli_sorted_cmd_ptrs"  inputsections="*(.cli_sorted_cmd_ptrs*)" runin=".cli_sorted_cmd_ptrs_run"/>
        <ProgramSection alignment="4" load="Yes" name=".dtors" />
        <ProgramSection alignment="4" load="Yes" name=".ctors" />
        <ProgramSection alignment="4" load="Yes" name=".rodata" />
        <ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" />
        <ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" />
        <ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" />
        <ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" />
      </MemorySegment>
      <MemorySegment name="RAM" start="$(RAM_PH_START)" size="$(RAM_PH_SIZE)">
        <ProgramSection load="no" name=".reserved_ram" start="$(RAM_PH_START)" size="$(RAM_START)-$(RAM_PH_START)" />
        <ProgramSection alignment="0x100" load="No" name=".vectors_ram" start="$(RAM_START)" address_symbol="__app_ram_start__"/>
        <ProgramSection alignment="4" keep="Yes" load="No" name=".nrf_sections_run" address_symbol="__start_nrf_sections_run" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".log_dynamic_data_run" address_symbol="__start_log_dynamic_data" end_symbol="__stop_log_dynamic_data" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".fs_data_run" address_symbol="__start_fs_data" end_symbol="__stop_fs_data" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".cli_sorted_cmd_ptrs_run" address_symbol="__start_cli_sorted_cmd_ptrs" end_symbol="__stop_cli_sorted_cmd_ptrs" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".nrf_sections_run_end" address_symbol="__end_nrf_sections_run" />
        <ProgramSection alignment="4" load="No" name=".fast_run" />
        <ProgramSection alignment="4" load="No" name=".data_run" />
        <ProgramSection alignment="4" load="No" name=".tdata_run" />
        <ProgramSection alignment="4" load="No" name=".bss" />
        <ProgramSection alignment="4" load="No" name=".tbss" />
        <ProgramSection alignment="4" load="No" name=".non_init" />
        <ProgramSection alignment="4" size="__HEAPSIZE__" load="No" name=".heap" />
        <ProgramSection alignment="8" size="__STACKSIZE__" load="No" place_from_segment_end="Yes" name=".stack"  address_symbol="__StackLimit" end_symbol="__StackTop"/>
        <ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" />
      </MemorySegment>
    </Root>

    Oh, and I also added this line:

    ble_enable_params.common_enable_params.vs_uuid_count = 2;

    to ble_stack_init():

    static void ble_stack_init(void)
    {
        uint32_t err_code;
    
        nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
    
        // Initialize SoftDevice.
        SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
    
        ble_enable_params_t ble_enable_params;
        err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
                                                        PERIPHERAL_LINK_COUNT,
                                                        &ble_enable_params);
        APP_ERROR_CHECK(err_code);
    
    	ble_enable_params.common_enable_params.vs_uuid_count = 2;
    
        //Check the ram settings against the used number of links
        CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT);
    
        // Enable BLE stack.
        err_code = softdevice_enable(&ble_enable_params);
        APP_ERROR_CHECK(err_code);
    
        // Subscribe for BLE events.
        err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
        APP_ERROR_CHECK(err_code);
    
        // Register with the SoftDevice handler module for BLE events.
        err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
        APP_ERROR_CHECK(err_code);
    }

    Appreciate your help Edvin. Many thanks,

    Tim

  • Hi Edvin. More info. I found this post and added to flash_placement.xml:

    <ProgramSection alignment="4" load="Yes" name=".bootloaderSettings" start="$(BOOTLOADER_SETTINGS_START:0x0003FC00)" size="$(BOOTLOADER_SETTINGS_SIZE:0x400)" />

    Now get the following build log:

    Building ‘ble_app_uart_pca10028_s130’ from solution ‘ble_app_uart_pca10028_s130’ in configuration ‘Debug’
      Generating linker script ‘ble_app_uart_pca10028_s130.ld’
      Linking ble_app_uart_pca10028_s130.elf
        .bootloaderSettings is too large to fit in RAM memory segment
        section .stack_process overlaps absolute placed section .bootloaderSettings
        .bootloaderSettings is too large to fit in RAM memory segment
        section .stack_process overlaps absolute placed section .bootloaderSettings
    Build failed

    Thanks,

    Tim

  • Try setting the bootloader settings to START: 0x3F000 and SIZE: 0x1000

  • Hi Edvin. Thanks for this. I'll try your suggestion shortly. I've recently learned a couple things. First, apparently I cannot update Simblee's Legacy DFU bootloader (over BLE) with the Secure Bootloader of SDK 12.3 because it has a larger flash footprint. I could only update the Legacy DFU bootloader to another of the same that I compile. That could be helpful because I would then have control of the SoftDevice used.

    The bootloader on Simblee is dual bank which limits the size of any image updated. Not enough space to update bootloader and SoftDevice.

    Thankfully, I learned that Simblee uses SoftDevice 110 v8.0.0. The Simblee Legacy DFU bootloader will accept images containing applications that use s110 v8.0.0. It feels like a way forward is to develop our application for Simblee to use s110 v8.0.0 with SDK 12.3. I need to learn how to add s110 v8.0.0 to SDK 12.3 and then change the ble_app_uart I have building for s130 to use s110 instead. Will start this work in the next couple days.

    Many thanks Edvin.

    Tim

  • Hi Edvin,

    I have ble_app_uart for s130 in SDK 12.3 now working with s110. I also discovered that Simblee apps are located at 0x1F000 instead of the standard location 0x18000. I don't understand why. When I change the FLASH_START address from 0x18000 to 0x1F000 and build the app, I can take the hex file, generated a zip using nrfutil and the Simblee bootloader will accept the image and the app runs properly.

    So I'm good now and will proceed with work to customize ble_app_uart for our application.

    Many thanks for your help along the way.

    Tim

Reply
  • Hi Edvin,

    I have ble_app_uart for s130 in SDK 12.3 now working with s110. I also discovered that Simblee apps are located at 0x1F000 instead of the standard location 0x18000. I don't understand why. When I change the FLASH_START address from 0x18000 to 0x1F000 and build the app, I can take the hex file, generated a zip using nrfutil and the Simblee bootloader will accept the image and the app runs properly.

    So I'm good now and will proceed with work to customize ble_app_uart for our application.

    Many thanks for your help along the way.

    Tim

Children
No Data
Related