Note: It is recommended, but not necessary, to use the most recent releases of the above software.
SEGGER Embedded Studio 3.10e
Tools -> Package Manager...
CMSIS-CORE Support Package
File -> Import IAR EWARM / Keil MDK Project...
NRF5_SDK/examples/ble_peripheral/ble_app_beacon/
pca10040/s132/arm5_no_packs/ble_app_beacon_pca10040_s132.uvprojx
Import Build Configuration
Internal Toolchain (GCC/Clang)
If you've used Keil uVision with Nordic's SDK before, you might remember that each example BLE project contains a dummy project configuration for easy flashing of the SoftDevice. We don't need this in Embedded Studio and it can cause confusion so let's delete it.
Project -> Build Configurations...
Public Configurations
flash_s132_nrf52_3.0.0_softdevice
-
Your build configurations should look like this now:
And your project explorer:
Keil uVision uses Device packs for Startup/System Setup. This pack contains the nRF5 startup assembly files arm_startup_nrf52.s and the system setup files system_nrf52.c along with some header files. We will need to manually add these files to our Embedded Studio project.
Device
arm_startup_nrf52.s
system_nrf52.c
NRF5_SDK/components/toolchain/embedded_studio/
Cortex_M_Startup.s
Internal Files
Project Explorer
Add Existing File...
NRF5_SDK/components/toolchain/
NRF5_SDK/components/toolchain/embedded_studio/ses_nrf52_startup.s
Your project explorer should look like this now:
Project -> Edit Options...
Preprocessor
../../../../../../components/device
User Include Directories
Your user include directories should look like this now:
Most of the examples in the SDK use Peer Manager. Peer Manager uses Flash Data Storage and Flash Storage. To indicate where information from Peer Manager (e.g bonding information) should be store page tags in flash (section variables) is used. These page tags need to be written to flash. To do so, flash_placement.xml and thumb_crt0.s have to be added and modified. Thanks to @RK and @HÃ¥kon Alseth in this post.
Flash_placement.xml can be located in the project folder, for example: ..\nRF5_SDK_xxx\examples\ble_peripheral\ble_app_gls\pca10040\s132\arm5_no_packs
You have to generate flash_placement.xml using text editor, notepad for example. After that you can import it by right click on the project name and choose "Import Section placement"
==========
For SDK v14 please use these updated files:
flash_placement.xml
thumb_crt0.s
flash_placement.xml should then look like the following (SDK 12):
<!DOCTYPE Linker_Placement_File> <Root name="Flash Section Placement"> <MemorySegment name="$(FLASH_NAME:FLASH)"> <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" 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" /> <ProgramSection alignment="4" keep="Yes" load="Yes" runin=".fs_data_run" name=".fs_data" /> </MemorySegment> <MemorySegment name="$(RAM_NAME:RAM);SRAM"> <ProgramSection alignment="0x100" load="No" name=".vectors_ram" start="$(RAM_START:$(SRAM_START:))" /> <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" keep="Yes" name=".fs_data_run" address_symbol="__start_fs_data" end_symbol="__stop_fs_data" /> <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" /> <ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" /> </MemorySegment> <MemorySegment name="$(FLASH2_NAME:FLASH2)"> <ProgramSection alignment="4" load="Yes" name=".text2" /> <ProgramSection alignment="4" load="Yes" name=".rodata2" /> <ProgramSection alignment="4" load="Yes" runin=".data2_run" name=".data2" /> </MemorySegment> <MemorySegment name="$(RAM2_NAME:RAM2)"> <ProgramSection alignment="4" load="No" name=".data2_run" /> <ProgramSection alignment="4" load="No" name=".bss2" /> </MemorySegment> </Root>
Thumb_crt0.s is located in the Segger Embedded studio install folder: ..\SEGGER\SEGGER Embedded Studio <v. xx>\source
In thumb_crt0.s, fs_data should be added, it can be added after tdata (thanks to @RK):
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 ...
Our project should build successfully now:
Build -> Build ble_app_beacon_pca10040_s132
F7
Notice that the compiled binary is placed at the beginning of FLASH and SRAM. This project requires a SoftDevice so let's reserve the correct amount of room for it.
FLASH
SRAM
Linker
Section Placement Macros
FLASH_START=0x1F000 SRAM_START=0x20002000
Your Project Options should look like this now:
Project Options
Build -> Rebuild ble_app_beacon_pca10040_s132
Alt + F7
Now you should see that space has been reserved in FLASH and SRAM for the SoftDevice:
NO_VTOR_CONFIG
Preprocessor Definitions
Your Preprocessor Definitions should look like this now:
Loader
NRF5_SDK/components/softdevice/s132/hex/s132_nrf52_3.0.0_softdevice.hex
Additional Load File[0]
Your Loader options should look like this now:
Debug -> Build and Run
Ctrl + F5
Your Output log should look like this now:
Output
The application should be running on your nRF5 DK and LED1 should be blinking. You should be able to scan for and find the beacon using nRF Connect.
nRF Connect
Debug -> Go
F5
You should see that you have entered the debugging interface now:
Notice that our application has ran until the first line in main() and is halted. You should experiment with debugging in Embedded Studio. It has all the debugging features you would expect from a professional IDE and more (makes sense as SEGGER makes the debuggers as well).
main()
To make peer manager (SDK 10(?), SDK 11, SDK 12) work with Segger Embedded Studio the modifications in this post are needed.
If you are stuck, previous blog posts (although deprecated) may help you fix your problem (also see the questions section):
A big problem! Waiting for a solution.
Building ‘ble_app_beacon_pca10040_s132’ from solution ‘ble_app_beacon_pca10040_s132’ in configuration ‘nrf52832_xxaa’1> Linking ble_app_beacon_pca10040_s132.elf1> 1> Diagnostics:1> remark: increasing alignment of section .vectors from 1 to 2 because it contains executable instructions1> error: undefined symbol: __data_start__Build failed
"Import Section placement" is missing from SEGGER Embedded Studio for ARMRelease 3.50 Build 2018081000.36713Windows x64
Oops - behaviour of 'Enter' when commenting on Blog posts is inconsistent with the behaviour elsewhere!
For an example of the thumb_crt0.s modification breaking a project (the LED Softblink project) see:https://devzone.nordicsemi.com/f/nordic-q-a/37535/ses-setup-advice-breaks-examples-undefined-reference-to-__fs_data_load_start__-etc
Adding the fs_data In thumb_crt0.s as shown (thanks to @RK) will break any example or project which does not use fstorage.