Developing for the nRF52805 with nRF5 SDK

Introduction

The nRF52805 SoC is a low-cost member of the nRF52 Series with a subset of the features of the nRF52811 and nRF52810 SoCs. As the nRF52805 has a feature subset of the nRF52810/11 SoCs, which in turn has a feature subset of the nRF52832, you can use the nRF52832 on the nRF52 DK to emulate the functionality of nRF52805 during development. 

This blog post will show you how to emulate the nRF52805 on the nRF52 Development Kit and show you how to transfer the emulated project to nRF52805 hardware. 

Detailed information on the SoC can be found in the nRF52805 Product Specification  and a detailed comparison of the features of the various nRF52 Series chips can be seen in the nRF52 Series comparison table on the Nordic Infocenter. 

Required software

To support development for the nRF52805 the following versions are required.

Hardware emulation of nRF52805 on the nRF52 DK 

You can fully emulate nRF52805 features using an nRF52 Development Kit (PCA10040), there are however, some differences that developers should be aware of when transferring emulated projects to nRF52805 hardware. 

EasyDMA

The EasyDMAbit MAXCNT bit length for some of the digital serial interfaces differs between the nRF52832 and the nRF52805. This means that the emulated project running on the nRF52 832 may only be able to use an EasyDMA MAXCNT bit length of 8 bits, while on the nRF52805 you may use EasyDMA MAXCNT bit length of up to 14 bits, see the table below for which peripherals that are affected. 

Peripheral nRF52832 nRF52805
RADIO 8-bits 8-bits
SAADC 15-bits 15-bits
SPIM 8-bits 14-bits
SPIS 8-bits 14-bits
TWIM 8-bits 14-bits
TWIS 8-bits 14-bits
UARTE 8-bits 10-bits

SAADC

The SAADC on the nRF52805 only has a limited number of channels compared to the nRF52832

nRF52832 nRF52805
SAADC Channels  8 2

PPI

The number of PPI channels on the nRF52805 is lower than on the nRF52832

nRF52832 nRF52805
PPI Channels  20 10

GPIO

The number of GPIOs available on the nRF52805 is lower than the nRF52805. 

Package nRF52832 nRF52805
6x6 QFN48 Up-to 32 GPIOs N/A
2.5x2.5 wlCSP N/A Up-to 10 GPIOs

When running an emulated nRF52805 example on the nRF52 DK you will be able to use the buttons and LEDs, but when transferring the emulated project to nRF52805 hardware you will need to remap the GPIOs used on the nRF52832 to available GPIOs on the nRF52805 wlCSP package, see table below. 

nRF52805 wlCSP
GPIOs
Type

P0.00

XL1

Digital I/O

Analog input


General purpose I/O

Connection for 32.768 kHz crystal (LFXO)

P0.01

XL2

Digital I/O

Analog input


General purpose I/O

Connection for 32.768 kHz crystal (LFXO)

P0.04

AIN2

Digital I/O

Analog input


General purpose I/O

SAADC input

P0.05

AIN3

Digital I/O

Analog input


General purpose I/O

SAADC input

P0.12

Digital I/O


General purpose I/O

P0.14

Digital I/O


General purpose I/O

P0.16

Digital I/O


General purpose I/O

P0.18

Digital I/O


General purpose I/O

P0.20 Digital I/O


General purpose I/O

P0.21

nRESET

Digital I/O

General purpose I/O

Configurable as pin reset

Software emulation of nRF52805

All examples that are hardware compatible with the nRF52805 can be set up to emulate the nRF52805 on the nRF52832. Hardware compatibility means that a project uses only the resources present in nRF52805, including peripherals and memory. Note that the nRF52805 does not have cache and hardware floating-point support. It is also important to note that the nRF52805 has reduced flash and RAM size compared to the nRF52832, hence not all nRF52 DK examples may fit on the nRF52805. 

See the nRF52 Series comparison table on the Nordic Infocenter for a full overview of which peripherals that are present on the nRF52805 compared to the nRF52832.

The following SoftDevices are supported on the nRF52805

SoftDevice Version
S112 v7.0.1

this is also listed in the SDKs and SoftDevices Compatibility Matrix for the nRF52805.

Patching nRF5 SDK v17.0.0 to support the nRF52805

The following files in the nRF5 SDK v17.0.0 need to be patched or added to support the nRF52805: 

  • Patch nrfx_irqs.h in nRF5_SDK_17.0.0_9d13099\modules\nrfx\soc\
  • Add nrfx_irqs_nrf52805.h to nRF5_SDK_17.0.0_9d13099\modules\nrfx\soc\
  • Patch nrfx_coredep.h in nRF5_SDK_17.0.0_9d13099\modules\nrfx\soc\
  • Patch nrfx_prs.h in nRF5_SDK_17.0.0_9d13099\modules\nrfx\drivers\src\prs\
  • Patch nrf_dfu_types.h in nRF5_SDK_17.0.0_9d13099\components\libraries\bootloader\dfu\
  • Patch nrf_bootloader_info.h in nRF5_SDK_17.0.0_9d13099\components\libraries\bootloader\

The patched and added files are available in this zip: SDK_v17.0.0_nRF52805_Patch.zip

Creating an emulated project for the nRF52805 on the nRF52 DK

This section will show you how to convert the emulated nRF52810 (pca10040e) examples in the nRF5 SDK to emulated nRF52805 (pca10040e_nrf52805) examples. Instructions for Keil, Segger Embedded Studio, and GCC with Makefiles are given below.

Keil

  1. Open the Keil example project 
  2. Open the Project Settings, click the Device tab, and change to device "NordicSemiconductor->nRF52805_xxaa".
  3. In the Preprocessor Definitions under the C/C++  tab, remove the "NRF52" and NRF52_PAN_74 defines if present.
  4. Replace the preprocessor define "NRF52810_XXAA" with  "NRF52805_XXAA".
  5. Replace the preprocessor define FLOAT_ABI_HARD with FLOAT_ABI_SOFT.
  6. Add NRFX_COREDEP_DELAY_US_LOOP_CYCLES=7 and DEVELOP_IN_NRF52832 and to the preprocessor definitions.
  7. Adjust the Read/Only Memory  Areas and Read/Write Memory Areas to match SoftDevice release notes and the maximum RAM and flash size of nRF52805.
    • IROM1 Start: 0x19000 ( S112 v7.0.1)
    • IROM1 Size: IROM1 Start+ IROM1 Size <= 0x30000
    • IRAM1 Start: 0x20002B00 ( Can be lowered at a later stage)
    • IRAM1 Size: IRAM1 Start+ IRAM1 Size <= 0x20006000
    • IRAM2 Start: Remove values and untick the default box
    • IRAM2 Size: Remove values and untick the default box

Segger Embedded Studio

  1. Open the example project 
  2. Open the Project Options and select the Common configuration 
  3. Under Code > Preprocessor > Preprocessor Definitions, remove the NRF52810_XXAA and FLOAT_ABI_HARD defines.
  4. Add NRF52805_XXAA and FLOAT_ABI_SOFT to the Preprocessor Definitions.
  5. Under Code > Preprocessor > Preprocessor Definitions Add the DEVELOP_IN_NRF52832 define to the compile flags. Adding this define will apply the necessary nRF52832 workarounds in SystemInit when you are developing for the nRF52805 on the  nRF52832.
  6. Under Code > Preprocessor > Preprocessor Definitions add NRFX_COREDEP_DELAY_US_LOOP_CYCLES=7 define to ensure correct timing when using nrf_delay_us function.
  7. Under Code > Code Generation set the ARM FP ABI Type to Soft and ARM FPU Type to None
  8. Under Code > Linker > Section Placement Macros, adjust the linker script to match the maximum RAM and flash size of nRF52805.
    • FLASH_PH_SIZE=0x30000
    • RAM_PH_SIZE=0x6000
  9. Modify the FLASH_SIZE and RAM_SIZE macros so that
    • FLASH_START + FLASH_SIZE <= FLASH_PH_SIZE
    • RAM_START + RAM_SIZE <= (RAM_PH_START + RAM_PH_SIZE)
  10. Under Code > Build > Memory Segments adjust the values to the following:
    • FLASH RX 0x0 0x30000;RAM RWX 0x20000000 0x6000
  11. Remove the following files from the project: ses_startup_nrf52810.s and system_nrf52810.c.
  12. Add the following files to the project: ses_startup_nrf52805.s and system_nrf52805.c.

GCC and Makefiles 

  1. Open the Makefile for the example project you want to convert to an emulated nRF52820 example. 
  2. Remove CFLAGS += -DNRF52810_XXAA from the compiler flags and ASMFLAGS += -DNRF52810_XXAA from the Assembler flags.
  3. Add the following compiler flag CFLAGS += -DNRF52805_XXAA and the following assembler flag ASMFLAGS += -DNRF52805_XXAA
  4. Add the DEVELOP_IN_NRF52832 define to the compiler and assembler flags, i.e. 
    CFLAGS += -DDEVELOP_IN_NRF52832 
    ASMFLAGS += -DDEVELOP_IN_NRF52832 

    Adding this define will add extra code in SystemInit needed for nRF52805.
  5. Add the NRFX_COREDEP_DELAY_US_LOOP_CYCLES=7 define to ensure correct timing when using nrf_delay_us function, i.e.
    CFLAGS += -DNRFX_COREDEP_DELAY_US_LOOP_CYCLES=7
    ASMFLAGS += -DNRFX_COREDEP_DELAY_US_LOOP_CYCLES=7
  6. Change CFLAGS += -DFLOAT_ABI_HARD to CFLAGS += -DFLOAT_ABI_SOFT and ASMFLAGS += -DFLOAT_ABI_HARD to ASMFLAGS += -DFLOAT_ABI_SOFT
  7. Change CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 to CFLAGS += -mfloat-abi=soft and ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 to ASMFLAGS += -mfloat-abi=soft
  8. Change the Linker flag LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 to LDFLAGS += -mfloat-abi=soft
  9. Remove the following lines from the SRC_FILES:
    • $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52810.S \
    • $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52810.c \
  10. Add the following lines to SRC_FILES
    • $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52805.S \
    • $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52805.c \
  11. In the linker script(.ld file locate in the same folder as the Makefile), adjust the linker script to match the maximum RAM and flash size of nRF52805, i.e. make sure that
    • FLASH : ORIGIN + LENGTH == 0x30000 
    • RAM: ORIGIN + LENGTH == 0x20006000

Transferring an emulated project to nRF52805 hardware

If you have developed your application using the emulated project as a starting point, there are only two steps you need to perform before you can run it natively on nRF52805:

  1. In your IDE, remove the DEVELOP_IN_NRF52832 and NRFX_COREDEP_DELAY_US_LOOP_CYCLES defines from the compile flags.
  2. Remap GPIOs used in your project to pins available on the nRF52805 wlCSP. See the table under Hardware emulation of nRF52805 on the nRF52 DK.

Emulated nRF52805 (pca10040e_nrf52805) Project examples 

Below you will find some of the BLE examples from SDK v17.0.0 where a pca10040e_nrf52805 project has been added with support for Keil 5, Segger Embedded Studio.

  • BLE Peripheral Examples are available for the S112 v7.0.1 and S113 v7.0.1

Peripheral UART/Serial Port Emulation over BLE (ble_app_uart)

  1. Download: ble_app_uart.zip
  2. Unzip the zip
  3. Place the pca10040e_nrf52805 folder in nRF5_SDK_17.0.0_9d13099\examples\ble_peripheral\ble_app_uart folder

Buttonless DFU 

  1. Download: ble_app_buttonless_dfu.zip
  2. Unzip the zip
  3. Place the pca10040e_nrf52805 folder in the nRF5_SDK_17.0.0_9d13099\examples\ble_peripheral\ble_app_buttonless_dfu folder.

Secure BLE Bootloader 

  1. Download: secure_bootloader_ble_sdk_v17.0.0.zip
  2. Unzip the zip
  3. Place the pca10040e_nrf52805 folder in nRF5_SDK_17.0.0_9d13099\examples\dfu\secure_bootloader

Secure UART Bootloader 

  1. Download: secure_bootloader_uart_sdk_v17.0.0.zip
  2. Unzip the zip
  3. Place th epca10040e_nrf52805 folder in nRF5_SDK_17.0.0_9d13099\examples\dfu\secure_bootloader folder.
Parents Comment Children
No Data