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

  • Thanks Edvin. My only experience is in building applications with SES on macOS. How do I build using armgcc? Do I need Keil on Windows?

    Thank you,

    Tim

  • You need an armgcc compiler, which is a command line tool. The version you need is mentioned in:

    SDK\components\toolchaing\gcc\makefile.windows for windows. For mac, perhaps it is in the makefile.posix. 

    These compilers are usually found here:

    https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads

    But it is a fairly old SDK, so I can't find it in the list. For SDK12.3.0, you would need gnu version 4.9 2015q3, version 4.9.3.

    Check out this one:

    https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q3-update

    To compile, on windows you would open a cmd terminal in the folder where the project's makefile is located and type "make"

  • Hi Edvin,

    Thanks. I've made some progress. To start, I built ble_app_uart example for pca10028 using armgcc make. (I already had armgcc installed and used it to build micro-ecc.) Then on nRF51 DK I used nrfjprog to:

    nrfjprog --recover
    nrfjprog -f nrf51 --program s130_nrf51_2.0.1_softdevice.hex
    nrfjprog -f nrf51 --program ble_app_uart_nrf51422_xxac.hex
    nrfjprog --reset

    ble_app_uart runs and I can connect/disconnect using nRF Connect (iOS). So I know I have a stable environment for building with armgcc.

    Next, I built bootloader_secure dfu example for pca10028. I used my public key and also needed to add to Makefile:

    $(SDK_ROOT)/external/micro-ecc/micro-ecc/micro-ecc \

    to INC_FOLDERS so uECC.h could be found.

    Next, I built experimental_ble_app_buttonless_dfu application.

    I now have:

    ble_app_buttonless_dfu_nrf51422_xxac.hex
    bootloader_secure_nrf51422_xxac_s130.hex

    Next I make the bootloader settings file:

    nrfutil settings generate --family NRF51 --application ble_app_buttonless_dfu_nrf51422_xxac.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 bl_settings.hex

    Output is:

    Generated Bootloader DFU settings .hex file and stored it in: bl_settings.hex

    Bootloader DFU Settings:
    * File: bl_settings.hex
    * Family: nRF51
    * Start Address: 0x0003FC00
    * CRC: 0xC5344558
    * Settings Version: 0x00000001 (1)
    * App Version: 0x00000001 (1)
    * Bootloader Version: 0x00000001 (1)
    * Bank Layout: 0x00000000
    * Current Bank: 0x00000000
    * Application Size: 0x0000ADD4 (44500 bytes)
    * Application CRC: 0x3A1674DE
    * Bank0 Bank Code: 0x00000001
    * Softdevice Size: 0x00000000 (0 bytes)
    * Boot Validation CRC: 0x00000000
    * SD Boot Validation Type: 0x00000000 (0)
    * App Boot Validation Type: 0x00000000 (0)


    Next I attempt to merge the bootloader settings file with the bootloader and SoftDevice:

    mergehex --merge bl_settings.hex bootloader_secure_nrf51422_xxac_s130.hex s130_nrf51_2.0.1_softdevice.hex --output bl_settings_s130.hex

    Get output/error:

    Parsing input hex files.
    Merging files.
    ERROR: The hex files cannot be merged since there are conflicts.

    I found that merging bootloader settings file with application (ble_app_buttonless_dfu_nrf51422_xxac.hex) and SoftDevice (s130_nrf51_2.0.1_softdevice.hex) works. So the conflict is between settings file and bootloader (bootloader_secure_nrf51422_xxac_s130.hex).

    I've attached the hex files.

    Separately, I tried programming nRF51 DK with SoftDevice and bootloader and, after reset, the bootloader runs, I can connect with nRF Connect and see the DFU service, characteristics, etc. I've not tried creating a DFU image and initiating DFU with nRF Connect. I presume the bootloader settings file is necessary for this to work.

    This was all with SDK 12.3.

    Thanks for ongoing help. Much appreciated.

    Tim

    bl_settings.hex

    bootloader_secure_nrf51422_xxac_s130.hex

    ble_app_buttonless_dfu_nrf51422_xxac.hex

  • Hello Tim,

    Try to use the option --no-backup when you generate the bootloader settings hex file. The older SDK's bootloaders didn't use this, so there is not set aside space for it.

    Let me know if it doesn't work.

    Best regards,

    Edvin

Reply Children
Related