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

nrf51822 development using SES, S110 SoftDevice on a Mac

Total noob here using SES on a Mac to build BLE peripheral (S110) firmware for an nRF51822-based device with SDK v15.

So far I've been able to get the generic portions of the application working. I can read button state changes. I can blink LEDs. I'm using the nRF5 DK board as my programmer. It connects to the target board using the debug out port and a "plug of nails" connector. The Segger debugger in SES is working. I can compile, flash, erase, debug, etc. all from SES.

But... My next challenge is to get the BLE peripheral functionality working. I'm a bit lost on how to tell SES to flash the S110 SoftDevice along with my code. I've found several messages that seem to indicate that the nRF51 line more-or-less stopped with SDK 12.x and that there is no native support for the 51 line in SES and / or in SDK v15.

Does anyone have a recipe, or any suggestions? Would I be better off abandoning SES and trying to set up a different tool chain or use a different IDE on this Mac?

Thanks in advance,

-S

Parents
  • Hrm... Looks like my assumption of the SoftDevice is wrong - based on old information.

    What is the appropriate BLE peripheral SoftDevice for use the the nRF51822 and the v15 SDK? Or is there no such thing?

  • There is no support for the nRF51 device on sdk 15. The last sdk that supported the nRF51 device was SDK 12.3. You should take a look at the S130 softdevice located under components/softdevice/s130 in SDK 12.3. SES automatically loads the softdevice onto the board when you download the application to the nRF52 device. You can check this by opening a SES project, right clicking on your Project in the top left corner of SES, clicking "Edit Options..." & going down to the Loader tab. Clicking on Additional Load File[0] will show you the path to the softdevice hex file that is loaded to your device.

    Do you have an nRF51 or nRF52 dev kit? If I were you, I would either get another nRF52 dev kit, use the latest SDK 15 & use SES or try using GCC to compile SDK 12.3 examples on your 51 board. You will most likely have less difficulties if you choose the first option.

    We also have getting started tutorial videos with SES that could be helpful. Be sure to take a look at our Infocenter documentation here too.

  • After beating my head against GCC and Makefiles for a while, I went back and did some additional searching. I finally ran across this post, which seems to indicate that it is (or was) possible to use SES with 12.3 to build for the nRF51 family.

    I followed the tutorial in that post and have been able to compile the "ble_app_uart" example and flash it and the associated s130 SoftDevice. However, something appears to go wrong during the initialization of the application (or the SoftDevice) as the debugger never attaches. Here's the output from the console:

    Preparing target for download
    Executing script TargetInterface.resetAndStop()
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    Downloading ?s130_nrf51_2.0.1_softdevice.hex? to J-Link
    Programming 1.9 KB of addresses 00000000 ? 000007bf
    Programming 103.9 KB of addresses 00001000 ? 0001afdf
    J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (2048 bytes)
    J-Link: Flash download: Total time needed: 0.392s (Prepare: 0.045s, Compare: 0.281s, Erase: 0.043s, Program: 0.013s, Verify: 0.000s, Restore: 0.007s)
    Download successful
    Downloading ?ble_app_uart_pca10028_s130.elf? to J-Link
    Programming 30.3 KB of addresses 0001f000 ? 0002696b
    Programming 0.0 KB of addresses 0002696c ? 0002698f
    J-Link: Flash download: Bank 0 @ 0x00000000: Skipped. Contents already match
    Download successful

    And here's what I see on the screen:

    Any idea what I may have done wrong? Apparently others have managed to use the (somewhat outdated) recipe to make make (an older version of) SES work with 12.x.

  • I don't have it working, but I think I know at least part of the problem. The tutorial requires that set a Section Placement Macros value.

    If you don't do this (and you don't try to add the soft device binary) the application will load and try to run - it just fails (silently - freezes) when it attempts to initialize the BLE stack. But the debugger attaches as it should.

    If you do set the Section Placement Macros values, the application code is shifted down (you can see by looking at the Memory Usage display) and apparently the boot loader doesn't find it. (Or something like that - I'm out of my element here.)

    I am using the latest version of SES, and the v12.3 SDK. The tutorial was written for an older version of SES and so probably includes steps that are now unnecessary or omits steps that are necessary.

    For whatever its worth: the Memory Usage display doesn't appear to indicate that the soft device has been loaded - the first block of memory is clear.

    Anyone have a guess what's going on?

  • Still going. I initially had some problem with the thumb_crt0.o output, presumably generated by the changes to the thumb_crt0.s file. I assume that was due to changes since the tutorial was written and simply removed the changes. Not sure if that's the issue, but the changes are still causing errors:

    1> Linking ble_app_uart_pca10028_s130.elf
    1> Output/ble_app_uart_pca10028_s130 nrf51422_xxac/Obj/thumb_crt0.o: In function `memory_set':
    1> /Applications/SEGGER Embedded Studio for ARM 3.40/source/thumb_crt0.s:172: undefined reference to `__fs_data_load_start__'
    1> /Applications/SEGGER Embedded Studio for ARM 3.40/source/thumb_crt0.s:173: undefined reference to `__fs_data_start__'
    1> /Applications/SEGGER Embedded Studio for ARM 3.40/source/thumb_crt0.s:174: undefined reference to `__fs_data_end__'
    Build failed

    Nordic - please take the time to add full and proper support for SDK 12.3 to SES or at least publish an updated tutorial. This is becoming aggravating.

  • Hi ssokol,
     
    Sorry for the delayed response. If you take a look at the nRF51422 51822 product pages, you notice that the main difference is that the 51422 supports ANT in addition to BLE, while the 51822 supports BLE & 2.4 GHz proprietary communication.
     
    You can either use a UART or RTT based logging tool. For Windows I prefer tera term, but since you are using a Mac, something recommended here should work fine. For RTT based logging, you can either do this directly via the Segger Embedded Studio (SES) debug terminal or via a RTT viewer application (see link for more info). 
    I would definitely recommend taking a look at our SES youtube tutorial, especially the CMSIS Configuration wizard. With the CMSIS configuration wizard installed, open it up, open the nRF_Log folder, make sure that either NRF_LOG_BACKEND_SERIAL_USES_RTT is true or NRF_LOG_BACKEND_SERIAL_USES_UART is set true. Also make sure that NRF_LOG_ENABLED is set true.
     
    Regarding your constructive criticism:
     
    I agree that the downloads tab should be updated to make it simpler to use. I will mention this internally. For us in tech support, it is quite intuitive, but that is only because we have worked with Nordic products for a long, long time. I fully understand that for a beginner, it would be very helpful to simplify the documentation even further. We do have a compatibility matrix here in our Infocenter for each of our devices that could be useful.
     
    Sorry that I did not notice that you included the Development filter when you made the question. I was wrong about using "GCC, makefiles and all that stuff from 1997." Take a look at this link for importing Keil projects into SES. I would not recommend using gcc & eclipse for example, as many developers have had issues with this. I noticed that you have already found a blog post related to importing SES projects, which is a very good idea in my opinion.
     
    I fully agree that it would be very useful to make some more development tutorials & keep them updated. We have already discussed this internally, but I will mention it again. Thank you very much for the constructive criticism!
  • Hi ,

    I just finished importing the ble_app_uart example from sdk 12.3 into SES from Keil & almost got everything working. I followed the blog post you mention, as well as this infocenter documentation. The project compiles correctly. As you can see from the memory read, the softdevice & the application have been correctly loaded to the device:

    This image was taken using the Programmer app from nRF connect for pc. This is the updated version to the programming functionality in nRF go studio. Download nRF Connect for mac, install the programmer app, open the app & connect to your nRF51 device.

    From your latest build fail, it seems you are using an outdated thumb_crt0.s file maybe. What I did was copy the thumb_crt0.s file into a new folder at this location: nRF5_SDK_12.3.0_d7731ad\nRF5_SDK_12.3.0_d7731ad\examples\ble_peripheral\ble_app_uart\pca10028\s130\ses

    Then, I updated the file like mentioned in the blog post (i.e. it should look similar to this):

    // **********************************************************************
    // *                    SEGGER Microcontroller GmbH                     *
    // *                        The Embedded Experts                        *
    // **********************************************************************
    // *                                                                    *
    // *            (c) 2014 - 2018 SEGGER Microcontroller GmbH             *
    // *            (c) 2001 - 2018 Rowley Associates Limited               *
    // *                                                                    *
    // *           www.segger.com     Support: [email protected]           *
    // *                                                                    *
    // **********************************************************************
    // *                                                                    *
    // * All rights reserved.                                               *
    // *                                                                    *
    // * Redistribution and use in source and binary forms, with or         *
    // * without modification, are permitted provided that the following    *
    // * conditions are met:                                                *
    // *                                                                    *
    // * - Redistributions of source code must retain the above copyright   *
    // *   notice, this list of conditions and the following disclaimer.    *
    // *                                                                    *
    // * - Neither the name of SEGGER Microcontroller GmbH                  *
    // *   nor the names of its contributors may be used to endorse or      *
    // *   promote products derived from this software without specific     *
    // *   prior written permission.                                        *
    // *                                                                    *
    // * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             *
    // * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        *
    // * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           *
    // * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           *
    // * DISCLAIMED.                                                        *
    // * IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR        *
    // * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR           *
    // * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  *
    // * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;    *
    // * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF      *
    // * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT          *
    // * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE  *
    // * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   *
    // * DAMAGE.                                                            *
    // *                                                                    *
    // **********************************************************************
    //
    //
    //                           Preprocessor Definitions
    //                           ------------------------
    // APP_ENTRY_POINT
    //
    //   Defines the application entry point function, if undefined this setting
    //   defaults to "main".
    //
    // INITIALIZE_STACK
    //
    //   If defined, the contents of the stack will be initialized to a the
    //   value 0xCC.
    //
    // INITIALIZE_SECONDARY_SECTIONS
    //
    //   If defined, the .data2, .text2, .rodata2 and .bss2 sections will be initialized.
    //
    // INITIALIZE_TCM_SECTIONS
    //
    //   If defined, the .data_tcm, .text_tcm, .rodata_tcm and .bss_tcm sections 
    //   will be initialized.
    //
    // INITIALIZE_USER_SECTIONS
    //
    //   If defined, the function InitializeUserMemorySections will be called prior
    //   to entering main in order to allow the user to initialize any user defined
    //   memory sections.
    //
    // FULL_LIBRARY
    //
    //  If defined then 
    //    - argc, argv are setup by the debug_getargs.
    //    - the exit symbol is defined and executes on return from main.
    //    - the exit symbol calls destructors, atexit functions and then debug_exit.
    //  
    //  If not defined then
    //    - argc and argv are zero.
    //    - the exit symbol is defined, executes on return from main and loops
    //
    
    #ifndef APP_ENTRY_POINT
    #define APP_ENTRY_POINT main
    #endif
    
    #ifndef ARGSSPACE
    #define ARGSSPACE 128
    #endif
      .syntax unified
    
      .global _start
      .extern APP_ENTRY_POINT
      .global exit
      .weak exit
    
    #ifdef INITIALIZE_USER_SECTIONS
      .extern InitializeUserMemorySections
    #endif
    
      .section .init, "ax"
      .code 16
      .balign 2
      .thumb_func
    
    _start:
      /* Set up main stack if size > 0 */
      ldr r1, =__stack_end__
      ldr r0, =__stack_start__
      subs r2, r1, r0
      beq 1f
    #ifdef __ARM_EABI__
      movs r2, #0x7
      bics r1, r2
    #endif
      mov sp, r1
    #ifdef INITIALIZE_STACK
      movs r2, #0xCC
      ldr r0, =__stack_start__
      bl memory_set
    #endif
    1:
    
      /* Set up process stack if size > 0 */
      ldr r1, =__stack_process_end__
      ldr r0, =__stack_process_start__
      subs r2, r1, r0
      beq 1f
    #ifdef __ARM_EABI__
      movs r2, #0x7
      bics r1, r2
    #endif
      msr psp, r1
      movs r2, #2
      msr control, r2
    #ifdef INITIALIZE_STACK
      movs r2, #0xCC
      bl memory_set
    #endif
    1:
    
      /* Copy initialized memory sections into RAM (if necessary). */
      ldr r0, =__data_load_start__
      ldr r1, =__data_start__
      ldr r2, =__data_end__
      bl memory_copy
      ldr r0, =__text_load_start__
      ldr r1, =__text_start__
      ldr r2, =__text_end__
      bl memory_copy
      ldr r0, =__fast_load_start__
      ldr r1, =__fast_start__
      ldr r2, =__fast_end__
      bl memory_copy
      ldr r0, =__ctors_load_start__
      ldr r1, =__ctors_start__
      ldr r2, =__ctors_end__
      bl memory_copy
      ldr r0, =__dtors_load_start__
      ldr r1, =__dtors_start__
      ldr r2, =__dtors_end__
      bl memory_copy
      ldr r0, =__rodata_load_start__
      ldr r1, =__rodata_start__
      ldr r2, =__rodata_end__
      bl memory_copy
      ldr r0, =__tdata_load_start__
      ldr r1, =__tdata_start__
      ldr r2, =__tdata_end__
      bl memory_copy
      # ADD HERE ... 
      ldr r0, =__fs_data_load_start__
      ldr r1, =__fs_data_start__
      ldr r2, =__fs_data_end__
      bl memory_copy
    # TO HERE ...
    #ifdef INITIALIZE_SECONDARY_SECTIONS
      ldr r0, =__data2_load_start__
      ldr r1, =__data2_start__
      ldr r2, =__data2_end__
      bl memory_copy
      ldr r0, =__text2_load_start__
      ldr r1, =__text2_start__
      ldr r2, =__text2_end__
      bl memory_copy
      ldr r0, =__rodata2_load_start__
      ldr r1, =__rodata2_start__
      ldr r2, =__rodata2_end__
      bl memory_copy
    #endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
    #ifdef INITIALIZE_TCM_SECTIONS
      ldr r0, =__data_tcm_load_start__
      ldr r1, =__data_tcm_start__
      ldr r2, =__data_tcm_end__
      bl memory_copy
      ldr r0, =__text_tcm_load_start__
      ldr r1, =__text_tcm_start__
      ldr r2, =__text_tcm_end__
      bl memory_copy
      ldr r0, =__rodata_tcm_load_start__
      ldr r1, =__rodata_tcm_start__
      ldr r2, =__rodata_tcm_end__
      bl memory_copy
    #endif /* #ifdef INITIALIZE_TCM_SECTIONS */
    
      /* Zero the bss. */
      ldr r0, =__bss_start__
      ldr r1, =__bss_end__
      movs r2, #0
      bl memory_set
      ldr r0, =__tbss_start__
      ldr r1, =__tbss_end__
      movs r2, #0
      bl memory_set
    #ifdef INITIALIZE_SECONDARY_SECTIONS
      ldr r0, =__bss2_start__
      ldr r1, =__bss2_end__
      mov r2, #0
      bl memory_set
    #endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
    #ifdef INITIALIZE_TCM_SECTIONS
      ldr r0, =__bss_tcm_start__
      ldr r1, =__bss_tcm_end__
      mov r2, #0
      bl memory_set
    #endif /* #ifdef INITIALIZE_TCM_SECTIONS */
    
      /* Initialize the heap */
      ldr r0, = __heap_start__
      ldr r1, = __heap_end__
      subs r1, r1, r0
      cmp r1, #8
      blt 1f
      movs r2, #0
      str r2, [r0]
      adds r0, r0, #4
      str r1, [r0]
    1:
    
    #ifdef INITIALIZE_USER_SECTIONS
      ldr r2, =InitializeUserMemorySections
      blx r2
    #endif
    
      /* Call constructors */
      ldr r0, =__ctors_start__
      ldr r1, =__ctors_end__
    ctor_loop:
      cmp r0, r1
      beq ctor_end
      ldr r2, [r0]
      adds r0, #4
      push {r0-r1}  
      blx r2
      pop {r0-r1}
      b ctor_loop
    ctor_end:
    
      /* Setup initial call frame */
      movs r0, #0
      mov lr, r0
      mov r12, sp
    
      .type start, function
    start:
      /* Jump to application entry point */
    #ifdef FULL_LIBRARY
      movs r0, #ARGSSPACE
      ldr r1, =args
      ldr r2, =debug_getargs  
      blx r2
      ldr r1, =args
    #else
      movs r0, #0
      movs r1, #0
    #endif
      ldr r2, =APP_ENTRY_POINT
      blx r2
    
      .thumb_func
    exit:
    #ifdef FULL_LIBRARY  
      mov r5, r0 // save the exit parameter/return result
    
      /* Call destructors */
      ldr r0, =__dtors_start__
      ldr r1, =__dtors_end__
    dtor_loop:
      cmp r0, r1
      beq dtor_end
      ldr r2, [r0]
      add r0, #4
      push {r0-r1}
      blx r2
      pop {r0-r1}
      b dtor_loop
    dtor_end:
    
      /* Call atexit functions */
      ldr r2, =_execute_at_exit_fns  
      blx r2
    
      /* Call debug_exit with return result/exit parameter */
      mov r0, r5
      ldr r2, =debug_exit  
      blx r2
    #endif
    
      /* Returned from application entry point, loop forever. */
    exit_loop:
      b exit_loop
    
      .thumb_func
    memory_copy:
      cmp r0, r1
      beq 2f
      subs r2, r2, r1
      beq 2f
    1:
      ldrb r3, [r0]
      adds r0, r0, #1
      strb r3, [r1]
      adds r1, r1, #1
      subs r2, r2, #1
      bne 1b
    2:
      bx lr
    
      .thumb_func
    memory_set:
      cmp r0, r1
      beq 1f
      strb r2, [r0]
      adds r0, r0, #1
      b memory_set
    1:
      bx lr
    
      // default C/C++ library helpers
    
    .macro HELPER helper_name
      .section .text.\helper_name, "ax", %progbits
      .balign 2
      .global \helper_name
      .weak \helper_name  
    \helper_name:
      .thumb_func
    .endm
    
    .macro JUMPTO name
    #if defined(__thumb__) && !defined(__thumb2__)
      mov r12, r0
      ldr r0, =\name
      push {r0}
      mov r0, r12
      pop {pc}
    #else
      b \name
    #endif
    .endm
    
    HELPER __aeabi_read_tp
      ldr r0, =__tbss_start__-8
      bx lr
    HELPER abort
      b .
    HELPER __assert
      b .
    HELPER __aeabi_assert
      b .
    HELPER __sync_synchronize
      bx lr
    HELPER __getchar
      JUMPTO debug_getchar
    HELPER __putchar
      JUMPTO debug_putchar
    HELPER __open
      JUMPTO debug_fopen
    HELPER __close
      JUMPTO debug_fclose
    HELPER __write   
      mov r3, r0
      mov r0, r1
      movs r1, #1  
      JUMPTO debug_fwrite
    HELPER __read  
      mov r3, r0
      mov r0, r1
      movs r1, #1 
      JUMPTO debug_fread
    HELPER __seek
      push {r4, lr}
      mov r4, r0
      bl debug_fseek
      cmp r0, #0
      bne 1f
      mov r0, r4
      bl debug_ftell
      pop {r4, pc}
    1:
      ldr r0, =-1
      pop {r4, pc}
      // char __user_locale_name_buffer[];
      .section .bss.__user_locale_name_buffer, "aw", %nobits
      .global __user_locale_name_buffer
      .weak __user_locale_name_buffer
      __user_locale_name_buffer:
      .word 0x0
    
    #ifdef FULL_LIBRARY
      .bss
    args:
      .space ARGSSPACE
    #endif
    
      /* Setup attibutes of stack and heap sections so they don't take up room in the elf file */
      .section .stack, "wa", %nobits
      .section .stack_process, "wa", %nobits
      .section .heap, "wa", %nobits
    
    

    Then, make sure to delete the old thumb_crt0.s file in the Internal Files folder in SES & add the new thumb_crt0.s file using -> "Add Existing File...".

    I do not believe the memory usage display in SES will show you where the softdevice will be placed. It should be similar to this:

    This is what I received & the softdevice was still loaded successfully. Unfortunately my device is still not advertising for some reason. As soon as I figure out what the issue is, I will update this comment.

Reply
  • Hi ,

    I just finished importing the ble_app_uart example from sdk 12.3 into SES from Keil & almost got everything working. I followed the blog post you mention, as well as this infocenter documentation. The project compiles correctly. As you can see from the memory read, the softdevice & the application have been correctly loaded to the device:

    This image was taken using the Programmer app from nRF connect for pc. This is the updated version to the programming functionality in nRF go studio. Download nRF Connect for mac, install the programmer app, open the app & connect to your nRF51 device.

    From your latest build fail, it seems you are using an outdated thumb_crt0.s file maybe. What I did was copy the thumb_crt0.s file into a new folder at this location: nRF5_SDK_12.3.0_d7731ad\nRF5_SDK_12.3.0_d7731ad\examples\ble_peripheral\ble_app_uart\pca10028\s130\ses

    Then, I updated the file like mentioned in the blog post (i.e. it should look similar to this):

    // **********************************************************************
    // *                    SEGGER Microcontroller GmbH                     *
    // *                        The Embedded Experts                        *
    // **********************************************************************
    // *                                                                    *
    // *            (c) 2014 - 2018 SEGGER Microcontroller GmbH             *
    // *            (c) 2001 - 2018 Rowley Associates Limited               *
    // *                                                                    *
    // *           www.segger.com     Support: [email protected]           *
    // *                                                                    *
    // **********************************************************************
    // *                                                                    *
    // * All rights reserved.                                               *
    // *                                                                    *
    // * Redistribution and use in source and binary forms, with or         *
    // * without modification, are permitted provided that the following    *
    // * conditions are met:                                                *
    // *                                                                    *
    // * - Redistributions of source code must retain the above copyright   *
    // *   notice, this list of conditions and the following disclaimer.    *
    // *                                                                    *
    // * - Neither the name of SEGGER Microcontroller GmbH                  *
    // *   nor the names of its contributors may be used to endorse or      *
    // *   promote products derived from this software without specific     *
    // *   prior written permission.                                        *
    // *                                                                    *
    // * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             *
    // * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        *
    // * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           *
    // * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           *
    // * DISCLAIMED.                                                        *
    // * IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR        *
    // * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR           *
    // * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  *
    // * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;    *
    // * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF      *
    // * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT          *
    // * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE  *
    // * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   *
    // * DAMAGE.                                                            *
    // *                                                                    *
    // **********************************************************************
    //
    //
    //                           Preprocessor Definitions
    //                           ------------------------
    // APP_ENTRY_POINT
    //
    //   Defines the application entry point function, if undefined this setting
    //   defaults to "main".
    //
    // INITIALIZE_STACK
    //
    //   If defined, the contents of the stack will be initialized to a the
    //   value 0xCC.
    //
    // INITIALIZE_SECONDARY_SECTIONS
    //
    //   If defined, the .data2, .text2, .rodata2 and .bss2 sections will be initialized.
    //
    // INITIALIZE_TCM_SECTIONS
    //
    //   If defined, the .data_tcm, .text_tcm, .rodata_tcm and .bss_tcm sections 
    //   will be initialized.
    //
    // INITIALIZE_USER_SECTIONS
    //
    //   If defined, the function InitializeUserMemorySections will be called prior
    //   to entering main in order to allow the user to initialize any user defined
    //   memory sections.
    //
    // FULL_LIBRARY
    //
    //  If defined then 
    //    - argc, argv are setup by the debug_getargs.
    //    - the exit symbol is defined and executes on return from main.
    //    - the exit symbol calls destructors, atexit functions and then debug_exit.
    //  
    //  If not defined then
    //    - argc and argv are zero.
    //    - the exit symbol is defined, executes on return from main and loops
    //
    
    #ifndef APP_ENTRY_POINT
    #define APP_ENTRY_POINT main
    #endif
    
    #ifndef ARGSSPACE
    #define ARGSSPACE 128
    #endif
      .syntax unified
    
      .global _start
      .extern APP_ENTRY_POINT
      .global exit
      .weak exit
    
    #ifdef INITIALIZE_USER_SECTIONS
      .extern InitializeUserMemorySections
    #endif
    
      .section .init, "ax"
      .code 16
      .balign 2
      .thumb_func
    
    _start:
      /* Set up main stack if size > 0 */
      ldr r1, =__stack_end__
      ldr r0, =__stack_start__
      subs r2, r1, r0
      beq 1f
    #ifdef __ARM_EABI__
      movs r2, #0x7
      bics r1, r2
    #endif
      mov sp, r1
    #ifdef INITIALIZE_STACK
      movs r2, #0xCC
      ldr r0, =__stack_start__
      bl memory_set
    #endif
    1:
    
      /* Set up process stack if size > 0 */
      ldr r1, =__stack_process_end__
      ldr r0, =__stack_process_start__
      subs r2, r1, r0
      beq 1f
    #ifdef __ARM_EABI__
      movs r2, #0x7
      bics r1, r2
    #endif
      msr psp, r1
      movs r2, #2
      msr control, r2
    #ifdef INITIALIZE_STACK
      movs r2, #0xCC
      bl memory_set
    #endif
    1:
    
      /* Copy initialized memory sections into RAM (if necessary). */
      ldr r0, =__data_load_start__
      ldr r1, =__data_start__
      ldr r2, =__data_end__
      bl memory_copy
      ldr r0, =__text_load_start__
      ldr r1, =__text_start__
      ldr r2, =__text_end__
      bl memory_copy
      ldr r0, =__fast_load_start__
      ldr r1, =__fast_start__
      ldr r2, =__fast_end__
      bl memory_copy
      ldr r0, =__ctors_load_start__
      ldr r1, =__ctors_start__
      ldr r2, =__ctors_end__
      bl memory_copy
      ldr r0, =__dtors_load_start__
      ldr r1, =__dtors_start__
      ldr r2, =__dtors_end__
      bl memory_copy
      ldr r0, =__rodata_load_start__
      ldr r1, =__rodata_start__
      ldr r2, =__rodata_end__
      bl memory_copy
      ldr r0, =__tdata_load_start__
      ldr r1, =__tdata_start__
      ldr r2, =__tdata_end__
      bl memory_copy
      # ADD HERE ... 
      ldr r0, =__fs_data_load_start__
      ldr r1, =__fs_data_start__
      ldr r2, =__fs_data_end__
      bl memory_copy
    # TO HERE ...
    #ifdef INITIALIZE_SECONDARY_SECTIONS
      ldr r0, =__data2_load_start__
      ldr r1, =__data2_start__
      ldr r2, =__data2_end__
      bl memory_copy
      ldr r0, =__text2_load_start__
      ldr r1, =__text2_start__
      ldr r2, =__text2_end__
      bl memory_copy
      ldr r0, =__rodata2_load_start__
      ldr r1, =__rodata2_start__
      ldr r2, =__rodata2_end__
      bl memory_copy
    #endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
    #ifdef INITIALIZE_TCM_SECTIONS
      ldr r0, =__data_tcm_load_start__
      ldr r1, =__data_tcm_start__
      ldr r2, =__data_tcm_end__
      bl memory_copy
      ldr r0, =__text_tcm_load_start__
      ldr r1, =__text_tcm_start__
      ldr r2, =__text_tcm_end__
      bl memory_copy
      ldr r0, =__rodata_tcm_load_start__
      ldr r1, =__rodata_tcm_start__
      ldr r2, =__rodata_tcm_end__
      bl memory_copy
    #endif /* #ifdef INITIALIZE_TCM_SECTIONS */
    
      /* Zero the bss. */
      ldr r0, =__bss_start__
      ldr r1, =__bss_end__
      movs r2, #0
      bl memory_set
      ldr r0, =__tbss_start__
      ldr r1, =__tbss_end__
      movs r2, #0
      bl memory_set
    #ifdef INITIALIZE_SECONDARY_SECTIONS
      ldr r0, =__bss2_start__
      ldr r1, =__bss2_end__
      mov r2, #0
      bl memory_set
    #endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
    #ifdef INITIALIZE_TCM_SECTIONS
      ldr r0, =__bss_tcm_start__
      ldr r1, =__bss_tcm_end__
      mov r2, #0
      bl memory_set
    #endif /* #ifdef INITIALIZE_TCM_SECTIONS */
    
      /* Initialize the heap */
      ldr r0, = __heap_start__
      ldr r1, = __heap_end__
      subs r1, r1, r0
      cmp r1, #8
      blt 1f
      movs r2, #0
      str r2, [r0]
      adds r0, r0, #4
      str r1, [r0]
    1:
    
    #ifdef INITIALIZE_USER_SECTIONS
      ldr r2, =InitializeUserMemorySections
      blx r2
    #endif
    
      /* Call constructors */
      ldr r0, =__ctors_start__
      ldr r1, =__ctors_end__
    ctor_loop:
      cmp r0, r1
      beq ctor_end
      ldr r2, [r0]
      adds r0, #4
      push {r0-r1}  
      blx r2
      pop {r0-r1}
      b ctor_loop
    ctor_end:
    
      /* Setup initial call frame */
      movs r0, #0
      mov lr, r0
      mov r12, sp
    
      .type start, function
    start:
      /* Jump to application entry point */
    #ifdef FULL_LIBRARY
      movs r0, #ARGSSPACE
      ldr r1, =args
      ldr r2, =debug_getargs  
      blx r2
      ldr r1, =args
    #else
      movs r0, #0
      movs r1, #0
    #endif
      ldr r2, =APP_ENTRY_POINT
      blx r2
    
      .thumb_func
    exit:
    #ifdef FULL_LIBRARY  
      mov r5, r0 // save the exit parameter/return result
    
      /* Call destructors */
      ldr r0, =__dtors_start__
      ldr r1, =__dtors_end__
    dtor_loop:
      cmp r0, r1
      beq dtor_end
      ldr r2, [r0]
      add r0, #4
      push {r0-r1}
      blx r2
      pop {r0-r1}
      b dtor_loop
    dtor_end:
    
      /* Call atexit functions */
      ldr r2, =_execute_at_exit_fns  
      blx r2
    
      /* Call debug_exit with return result/exit parameter */
      mov r0, r5
      ldr r2, =debug_exit  
      blx r2
    #endif
    
      /* Returned from application entry point, loop forever. */
    exit_loop:
      b exit_loop
    
      .thumb_func
    memory_copy:
      cmp r0, r1
      beq 2f
      subs r2, r2, r1
      beq 2f
    1:
      ldrb r3, [r0]
      adds r0, r0, #1
      strb r3, [r1]
      adds r1, r1, #1
      subs r2, r2, #1
      bne 1b
    2:
      bx lr
    
      .thumb_func
    memory_set:
      cmp r0, r1
      beq 1f
      strb r2, [r0]
      adds r0, r0, #1
      b memory_set
    1:
      bx lr
    
      // default C/C++ library helpers
    
    .macro HELPER helper_name
      .section .text.\helper_name, "ax", %progbits
      .balign 2
      .global \helper_name
      .weak \helper_name  
    \helper_name:
      .thumb_func
    .endm
    
    .macro JUMPTO name
    #if defined(__thumb__) && !defined(__thumb2__)
      mov r12, r0
      ldr r0, =\name
      push {r0}
      mov r0, r12
      pop {pc}
    #else
      b \name
    #endif
    .endm
    
    HELPER __aeabi_read_tp
      ldr r0, =__tbss_start__-8
      bx lr
    HELPER abort
      b .
    HELPER __assert
      b .
    HELPER __aeabi_assert
      b .
    HELPER __sync_synchronize
      bx lr
    HELPER __getchar
      JUMPTO debug_getchar
    HELPER __putchar
      JUMPTO debug_putchar
    HELPER __open
      JUMPTO debug_fopen
    HELPER __close
      JUMPTO debug_fclose
    HELPER __write   
      mov r3, r0
      mov r0, r1
      movs r1, #1  
      JUMPTO debug_fwrite
    HELPER __read  
      mov r3, r0
      mov r0, r1
      movs r1, #1 
      JUMPTO debug_fread
    HELPER __seek
      push {r4, lr}
      mov r4, r0
      bl debug_fseek
      cmp r0, #0
      bne 1f
      mov r0, r4
      bl debug_ftell
      pop {r4, pc}
    1:
      ldr r0, =-1
      pop {r4, pc}
      // char __user_locale_name_buffer[];
      .section .bss.__user_locale_name_buffer, "aw", %nobits
      .global __user_locale_name_buffer
      .weak __user_locale_name_buffer
      __user_locale_name_buffer:
      .word 0x0
    
    #ifdef FULL_LIBRARY
      .bss
    args:
      .space ARGSSPACE
    #endif
    
      /* Setup attibutes of stack and heap sections so they don't take up room in the elf file */
      .section .stack, "wa", %nobits
      .section .stack_process, "wa", %nobits
      .section .heap, "wa", %nobits
    
    

    Then, make sure to delete the old thumb_crt0.s file in the Internal Files folder in SES & add the new thumb_crt0.s file using -> "Add Existing File...".

    I do not believe the memory usage display in SES will show you where the softdevice will be placed. It should be similar to this:

    This is what I received & the softdevice was still loaded successfully. Unfortunately my device is still not advertising for some reason. As soon as I figure out what the issue is, I will update this comment.

Children
  • Hi Bjørn,

    Apologies for the delayed response on this ticket. I was able to work my way through the Kiel import process and managed to get SES working with the changes to the flash_placement.xml file, the thumb_crt0.s file and the Section Placement Macros values in the Linker configuration. With those changes I have a working environment.

    How difficult would it be for someone (someone at Nordic - hopefully an intern with a good deal of patience) to go through that process for each of the examples, for each of the SoftDevices, for each of the development boards and then publish a v12.3.1 release of the SDK with SES project files?

    I know the nRF51 line isn't the going forward product, but there many modules out there that are built on that legacy line and which are still being incorporated into new products - mine included.

    Please feel free to close this ticket.

    Thanks!

    -S

  • Hi ,

    Great to hear that you got it working! Unfortunately, it is unlikely that we will make updates to an old sdk. I can mention it internally, but I am not sure it will get much traction. What we can do though is update the blog post to work on sdk 12.3 examples. 

    I have also mentioned your other two pieces of constructive feedback regarding the small changes to the download tab in nrf sdk 15 & creating an updated getting started guide for nRF51/2 on each of the three development platforms (Windows, Mac, Linux).

    Kind Regards,

    Bjorn

     

  • Just wanted to let you know that we have updated the nrf5 sdk download tab thanks to you. We really appreciate honest feedback from customers such as yourself.

Related