nRF51 SDK - S310 SoftDevice
|
The Bootloader/DFU project can be built using Keil uVision.
The project file contains three targets
Target | Description |
---|---|
dfu_dual_bank_hci | Project target using dual bank solution and image is transferred using HCI Transport layer on UART. See Serial (HCI) |
dfu_single_bank_hci | Project target using single bank solution and image is transferred using HCI Transport layer on UART. See Serial (HCI) |
dfu_dual_bank_ble (s110) | Project target using dual bank solution and image is transferred using BLE with the S110 SoftDevice. See BLE |
dfu_dual_bank_ble (s310) | Project target using dual bank solution and image is transferred using BLE with the S310 SoftDevice. See BLE |
The target can be selected in the project chooser in Keil as seen in Figure 1.
The single bank principle is described further in Single Bank Flash Layout.
Dual bank description is found in Dual Bank Flash Layout.
In the nRF51 series, a SoftDevice will be placed at Code Region 0, starting at address 0x00000000
.
In the Bootloader/DFU example, the S110 SoftDevice is used and thus it must be present a this address, (see the nRF51822 DK User Guide on how to flash the SoftDevice).
The SoftDevice will usually start the application located at the beginning of code region 1, which is 0x00016000
. In order for the SoftDevice to be able to initiate a bootloader, instead of an application, the UICR.BOOTLOADERADDR register must be written. This register is located at address 0x10001014
.
The Bootloader/DFU is located at address 0x0003C000
, as seen in Figure 2..
In the Bootloader/DFU project, the writing of the UICR.BOOTLOADERADDR is linked into the HEX file and will be written automatically when flashing the bootloader with nrfjprog.exe
, see Bootloader/DFU Flashing.
This is ensured by the following code in bootloader_util_arm.c
BOOTLOADER_REGION_START
must point to the correct location of the bootloader in the flash. The location in this example is 0x0003C000
.
The J-Link Target Driver used for flashing other example applications in the nRF51 SDK does not support writing of the UICR register.
Therefore it is necessary to use the nrfjprog.exe
tool for programming the nRF51 with the Bootloader/DFU project.
The nrfjprog.exe
is delivered as part of the nRF51 SDK installer, and should therefore already be present.
The Bootloader/DFU project is configured to use nrfjprog.exe
per default, and is expecting the tool to be present in windows' system path. nrfjprog.exe
programs the compiled and linked HEX file to the nRF51 chip when flashing from Keil uVision.
Figure 3 shows the settings for nrfjprog.exec
in Keil.
If more than one J-Link is present in the system, a pop-up windows will appear requiring the user to choose which to use. Choose the J-Link attached to the Development Kit containing the nRF51 Chip to be flashed with Bootloader/DFU. See Figure 5.
The DFU supports only binary images for data transfer as described in DFU Transport Layers.
When compiling an application, such as Heart Rate Measurement, two images are created.
Keil uVision contains a command line tool, fromelf.exe
, which can convert the AXF file into a binary image.
The tool is located in the Keil installation folder as:
<Keil-folder>\ARM\ARMCC\bin\fromelf.exe
Converting an AXF image into BIN file can be done as:
<Keil-folder>\ARM\ARMCC\bin\fromelf.exe --bin --output <outfile.bin> <infile.axf>
In case the Bootloader/DFU software is extended with additional functionality and a larger code size is needed, then it is possible to move the start address of the Bootloader/DFU. If moving the bootloader to a different location, as example 0x00038000
, then the BOOTLOADER_REGION_START
defined in dfu_types.h
must be updated accordingly.
For the linker to work correctly, then changing BOOTLOADER_REGION_START
also requires change to the Keil project. In Keil, go to project->options for target
, and change the IROM1 Start address to the new value. Also remember to increase the Size field (default 0x4000
).
As example, moving from address 0x0003C000
, Size 0x4000
to new address 0x00038000
gives 0x4000 additional bytes (10 pages), thus the new size becomes 0x8000
.
nrfjprog.exe
Figure 5 shows the setting in Keil to modify, if the Bootloader/DFU start address must be changed.