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

Problems with programming a third-party nRF51822 board

I am new to Nordic products. I have a custom nRF51822 board and I want to flash it with Keil uVision and ST-Link V/2. 

As I understood, I have to program the SoftDevice firmware first. I have downloaded nRFgo Studio and got s112_nrf52_6.1.0_softdevice.hex file. Since I don't have Nordic DKs, my device is not shown in Device Manager part. How should I download the hex file to my chip? 

  • Hi, I new in Nordic products too, my board is BLE400 (nRF51822 based) from www.waveshare.com/.../BLE400.
    I testing Blinky example in SDK 12.3.0 via GCC, compilation it's correct, load via bnRFGo v1.21.2.10 it's correct too, but nothing happend.
    Could you please help me?

    Thanks in advance.


    Files updated:

    -------------------------------------------------------------------------------------------------
    * File: C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\components\toolchain\gcc\Makefile.windows
    -------------------------------------------------------------------------------------------------
    GNU_INSTALL_ROOT := C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major
    GNU_VERSION := 7.2.1
    GNU_PREFIX := arm-none-eabi

    -------------------------------------------------------------------------------------------------
    * File: C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\components\boards\boards.h
    -------------------------------------------------------------------------------------------------
    ...
    #elif defined (BOARD_ARDUINO_PRIMO)
    #include "arduino_primo.h"
    #elif defined(BOARD_BLE400) // BLE400 board
    #include "ble400.h" // BLE400 board
    #elif defined(BOARD_CUSTOM)
    #include "custom_board.h"
    #else
    #error "Board is not defined"
    ...
    -------------------------------------------------------------------------------------------------
    -------------------------------------------------------------------------------------------------
    * New File: C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\components\boards\ble400.h

    See Board schematic: www.waveshare.com/.../BLE400-Schematic.pdf
    -------------------------------------------------------------------------------------------------
    #ifndef BLE400_H
    #define BLE400_H

    #ifdef __cplusplus
    extern "C" {
    #endif

    #include "nrf_gpio.h"

    // LEDs definitions for BLE400
    #define LEDS_NUMBER 5

    #define LED_START 18
    #define LED_0 18
    #define LED_1 19
    #define LED_2 20
    #define LED_3 21
    #define LED_4 22
    #define LED_STOP 19

    #define LEDS_ACTIVE_STATE 1

    #define LEDS_INV_MASK 0x00000000

    #define LEDS_LIST { LED_0, LED_1, LED_2, LED_3, LED_4 }

    #define BSP_LED_0 LED_0
    #define BSP_LED_1 LED_1
    #define BSP_LED_2 LED_2
    #define BSP_LED_3 LED_3
    #define BSP_LED_4 LED_4

    #define BUTTONS_NUMBER 2

    #define BUTTON_START 16
    #define BUTTON_0 16
    #define BUTTON_1 17
    #define BUTTON_STOP 17
    #define BUTTON_PULL NRF_GPIO_PIN_PULLUP

    #define BUTTONS_ACTIVE_STATE 0

    #define BUTTONS_LIST { BUTTON_0, BUTTON_1 }

    #define BSP_BUTTON_0 BUTTON_0
    #define BSP_BUTTON_1 BUTTON_1

    // USART Externa (Conector)
    #define RX_PIN_NUMBER 11
    #define TX_PIN_NUMBER 9
    #define CTS_PIN_NUMBER 10
    #define RTS_PIN_NUMBER 8
    #define HWFC true

    #define SPIS_MISO_PIN 23 // SPI MISO signal.
    #define SPIS_CSN_PIN 30 // SPI CSN signal.
    #define SPIS_MOSI_PIN 24 // SPI MOSI signal.
    #define SPIS_SCK_PIN 25 // SPI SCK signal.

    #define SPIM0_SCK_PIN 25u // SPI clock GPIO pin number.
    #define SPIM0_MOSI_PIN 24u // SPI Master Out Slave In GPIO pin number.
    #define SPIM0_MISO_PIN 23u // SPI Master In Slave Out GPIO pin number.
    #define SPIM0_SS_PIN 30u // SPI Slave Select GPIO pin number.

    // from here not used yet ...

    #define SPIM1_SCK_PIN 29u /**< SPI clock GPIO pin number. */
    #define SPIM1_MOSI_PIN 24u /**< SPI Master Out Slave In GPIO pin number. */
    #define SPIM1_MISO_PIN 28u /**< SPI Master In Slave Out GPIO pin number. */
    #define SPIM1_SS_PIN 25u /**< SPI Slave Select GPIO pin number. */

    // serialization APPLICATION board

    // UART
    // this configuration works with the SPI wires setup
    #define SER_APP_RX_PIN 23 // UART RX pin number.
    #define SER_APP_TX_PIN 24 // UART TX pin number.
    #define SER_APP_CTS_PIN 25 // UART Clear To Send pin number.
    #define SER_APP_RTS_PIN 30 // UART Request To Send pin number.

    // SPI
    #if 0
    #define SER_APP_SPIM0_SCK_PIN 20 // SPI clock GPIO pin number.
    #define SER_APP_SPIM0_MOSI_PIN 17 // SPI Master Out Slave In GPIO pin number
    #define SER_APP_SPIM0_MISO_PIN 16 // SPI Master In Slave Out GPIO pin number
    #define SER_APP_SPIM0_SS_PIN 21 // SPI Slave Select GPIO pin number
    #define SER_APP_SPIM0_RDY_PIN 19 // SPI READY GPIO pin number
    #define SER_APP_SPIM0_REQ_PIN 18 // SPI REQUEST GPIO pin number
    #else
    #define SER_APP_SPIM0_SCK_PIN 23 // SPI clock GPIO pin number.
    #define SER_APP_SPIM0_MOSI_PIN 20 // SPI Master Out Slave In GPIO pin number
    #define SER_APP_SPIM0_MISO_PIN 22 // SPI Master In Slave Out GPIO pin number
    #define SER_APP_SPIM0_SS_PIN 21 // SPI Slave Select GPIO pin number
    #define SER_APP_SPIM0_RDY_PIN 25 // SPI READY GPIO pin number
    #define SER_APP_SPIM0_REQ_PIN 24 // SPI REQUEST GPIO pin number
    #endif

    // serialization CONNECTIVITY board
    // UART
    #if 0
    #define SER_CON_RX_PIN 22 // UART RX pin number.
    #define SER_CON_TX_PIN 20 // UART TX pin number.
    #define SER_CON_CTS_PIN 21 // UART Clear To Send pin number. Not used if HWFC is set to false.
    #define SER_CON_RTS_PIN 23 // UART Request To Send pin number. Not used if HWFC is set to false.
    #else
    // this configuration works with the SPI wires setup
    #define SER_CON_RX_PIN 20 // UART RX pin number.
    #define SER_CON_TX_PIN 22 // UART TX pin number.
    #define SER_CON_CTS_PIN 21 // UART Clear To Send pin number. Not used if HWFC is set to false.
    #define SER_CON_RTS_PIN 23 // UART Request To Send pin number. Not used if HWFC is set to false.
    #endif

    //SPI
    #if 0
    #define SER_CON_SPIS_SCK_PIN 20 // SPI SCK signal.
    #define SER_CON_SPIS_MISO_PIN 16 // SPI MISO signal.
    #define SER_CON_SPIS_MOSI_PIN 17 // SPI MOSI signal.
    #define SER_CON_SPIS_CSN_PIN 21 // SPI CSN signal.
    #define SER_CON_SPIS_RDY_PIN 19 // SPI READY GPIO pin number.
    #define SER_CON_SPIS_REQ_PIN 18 // SPI REQUEST GPIO pin number.
    #else
    #define SER_CON_SPIS_SCK_PIN 23 // SPI SCK signal.
    #define SER_CON_SPIS_MOSI_PIN 22 // SPI MOSI signal.
    #define SER_CON_SPIS_MISO_PIN 20 // SPI MISO signal.
    #define SER_CON_SPIS_CSN_PIN 21 // SPI CSN signal.
    #define SER_CON_SPIS_RDY_PIN 25 // SPI READY GPIO pin number.
    #define SER_CON_SPIS_REQ_PIN 24 // SPI REQUEST GPIO pin number.
    #endif

    #define SER_CONN_ASSERT_LED_PIN LED_0

    // Low frequency clock source to be used by the SoftDevice
    #define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \
    .rc_ctiv = 0, \
    .rc_temp_ctiv = 0, \
    .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}

    #ifdef __cplusplus
    }
    #endif

    #endif // BLE400_H
    -------------------------------------------------------------------------------------------------

    -------------------------------------------------------------------------------------------------
    New files structure created
    -------------------------------------------------------------------------------------------------
    C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\examples\peripheral\blinky\ble400
    C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\examples\peripheral\blinky\ble400\blank
    C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\examples\peripheral\blinky\ble400\blank\armgcc
    C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\examples\peripheral\blinky\ble400\blank\armgcc\blinky_gcc_nrf51.ld (1KB 05/05/2017 13:23)
    C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\examples\peripheral\blinky\ble400\blank\armgcc\Makefile (see below)
    C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\examples\peripheral\blinky\ble400\blank\config
    C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\examples\peripheral\blinky\ble400\blank\config\sdk_config.h (82KB - 05/05/2017 13:23)
    -------------------------------------------------------------------------------------------------

    -------------------------------------------------------------------------------------------------
    File: C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\examples\peripheral\blinky\ble400\blank\armgcc\Makefile
    -------------------------------------------------------------------------------------------------
    PROJECT_NAME := blinky_ble400
    TARGETS := nrf51422_xxac
    OUTPUT_DIRECTORY := _build

    SDK_ROOT := C:/Nordic_semi/nRF5_SDK_12.3.0_d7731ad
    PROJ_DIR := C:/Nordic_semi/nRF5_SDK_12.3.0_d7731ad/examples/peripheral/blinky

    $(OUTPUT_DIRECTORY)/nrf51422_xxac.out: \
    LINKER_SCRIPT := blinky_gcc_nrf51.ld

    # Source files common to all targets
    SRC_FILES += \
    $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \
    $(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \
    $(SDK_ROOT)/components/libraries/util/app_error.c \
    $(SDK_ROOT)/components/libraries/util/app_error_weak.c \
    $(SDK_ROOT)/components/libraries/timer/app_timer.c \
    $(SDK_ROOT)/components/libraries/util/app_util_platform.c \
    $(SDK_ROOT)/components/libraries/hardfault/hardfault_implementation.c \
    $(SDK_ROOT)/components/libraries/util/nrf_assert.c \
    $(SDK_ROOT)/components/libraries/util/sdk_errors.c \
    $(SDK_ROOT)/components/boards/boards.c \
    $(SDK_ROOT)/components/drivers_nrf/clock/nrf_drv_clock.c \
    $(SDK_ROOT)/components/drivers_nrf/common/nrf_drv_common.c \
    $(SDK_ROOT)/components/drivers_nrf/uart/nrf_drv_uart.c \
    $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c \
    $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c \
    $(PROJ_DIR)/main.c \
    $(SDK_ROOT)/external/segger_rtt/RTT_Syscalls_GCC.c \
    $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
    $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
    $(SDK_ROOT)/components/toolchain/gcc/gcc_startup_nrf51.S \
    $(SDK_ROOT)/components/toolchain/system_nrf51.c \

    # Include folders common to all targets
    INC_FOLDERS += \
    $(SDK_ROOT)/components/drivers_nrf/comp \
    $(SDK_ROOT)/components/drivers_nrf/twi_master \
    $(SDK_ROOT)/components/ble/ble_services/ble_ancs_c \
    $(SDK_ROOT)/components/ble/ble_services/ble_ias_c \
    $(SDK_ROOT)/components/libraries/pwm \
    $(SDK_ROOT)/components/libraries/usbd/class/cdc/acm \
    $(SDK_ROOT)/components/libraries/usbd/class/hid/generic \
    $(SDK_ROOT)/components/libraries/usbd/class/msc \
    $(SDK_ROOT)/components/libraries/usbd/class/hid \
    $(SDK_ROOT)/components/libraries/log \
    $(SDK_ROOT)/components/ble/ble_services/ble_gls \
    $(SDK_ROOT)/components/libraries/fstorage \
    $(SDK_ROOT)/components/drivers_nrf/i2s \
    $(PROJ_DIR) \
    $(SDK_ROOT)/components/libraries/gpiote \
    $(SDK_ROOT)/components/drivers_nrf/gpiote \
    $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \
    $(SDK_ROOT)/components/boards \
    $(SDK_ROOT)/components/drivers_nrf/common \
    $(SDK_ROOT)/components/ble/ble_advertising \
    $(SDK_ROOT)/components/drivers_nrf/adc \
    $(SDK_ROOT)/components/ble/ble_services/ble_bas_c \
    $(SDK_ROOT)/components/ble/ble_services/ble_hrs_c \
    $(SDK_ROOT)/components/libraries/queue \
    $(SDK_ROOT)/components/ble/ble_dtm \
    $(SDK_ROOT)/components/toolchain/cmsis/include \
    $(SDK_ROOT)/components/ble/ble_services/ble_rscs_c \
    $(SDK_ROOT)/components/drivers_nrf/uart \
    $(SDK_ROOT)/components/libraries/usbd/class/hid/kbd \
    $(SDK_ROOT)/components/ble/ble_services/ble_lls \
    $(SDK_ROOT)/components/drivers_nrf/wdt \
    $(SDK_ROOT)/components/libraries/bsp \
    $(SDK_ROOT)/components/ble/ble_services/ble_bas \
    $(SDK_ROOT)/components/libraries/experimental_section_vars \
    $(SDK_ROOT)/components/ble/ble_services/ble_ans_c \
    $(SDK_ROOT)/components/libraries/slip \
    $(SDK_ROOT)/external/segger_rtt \
    $(SDK_ROOT)/components/libraries/csense_drv \
    $(SDK_ROOT)/components/drivers_nrf/hal \
    $(SDK_ROOT)/components/ble/ble_services/ble_nus_c \
    $(SDK_ROOT)/components/drivers_nrf/rtc \
    $(SDK_ROOT)/components/ble/ble_services/ble_ias \
    $(SDK_ROOT)/components/libraries/usbd/class/hid/mouse \
    $(SDK_ROOT)/components/drivers_nrf/ppi \
    $(SDK_ROOT)/components/ble/ble_services/ble_dfu \
    $(SDK_ROOT)/components/drivers_nrf/twis_slave \
    $(SDK_ROOT)/components \
    $(SDK_ROOT)/components/drivers_nrf/usbd \
    $(SDK_ROOT)/components/libraries/scheduler \
    $(SDK_ROOT)/components/ble/ble_services/ble_lbs \
    $(SDK_ROOT)/components/ble/ble_services/ble_hts \
    $(SDK_ROOT)/components/drivers_nrf/delay \
    $(SDK_ROOT)/components/libraries/crc16 \
    $(SDK_ROOT)/components/drivers_nrf/timer \
    $(SDK_ROOT)/components/libraries/util \
    $(SDK_ROOT)/components/drivers_nrf/pwm \
    ../config \
    $(SDK_ROOT)/components/libraries/usbd/class/cdc \
    $(SDK_ROOT)/components/libraries/csense \
    $(SDK_ROOT)/components/drivers_nrf/rng \
    $(SDK_ROOT)/components/libraries/low_power_pwm \
    $(SDK_ROOT)/components/libraries/hardfault \
    $(SDK_ROOT)/components/ble/ble_services/ble_cscs \
    $(SDK_ROOT)/components/libraries/uart \
    $(SDK_ROOT)/components/libraries/hci \
    $(SDK_ROOT)/components/drivers_nrf/spi_slave \
    $(SDK_ROOT)/components/drivers_nrf/lpcomp \
    $(SDK_ROOT)/components/libraries/timer \
    $(SDK_ROOT)/components/drivers_nrf/power \
    $(SDK_ROOT)/components/libraries/usbd/config \
    $(SDK_ROOT)/components/toolchain \
    $(SDK_ROOT)/components/libraries/led_softblink \
    $(SDK_ROOT)/components/drivers_nrf/qdec \
    $(SDK_ROOT)/components/ble/ble_services/ble_cts_c \
    $(SDK_ROOT)/components/drivers_nrf/spi_master \
    $(SDK_ROOT)/components/ble/ble_services/ble_nus \
    $(SDK_ROOT)/components/ble/ble_services/ble_hids \
    $(SDK_ROOT)/components/drivers_nrf/pdm \
    $(SDK_ROOT)/components/libraries/crc32 \
    $(SDK_ROOT)/components/libraries/usbd/class/audio \
    $(SDK_ROOT)/components/ble/peer_manager \
    $(SDK_ROOT)/components/libraries/mem_manager \
    $(SDK_ROOT)/components/ble/ble_services/ble_tps \
    $(SDK_ROOT)/components/ble/ble_services/ble_dis \
    $(SDK_ROOT)/components/device \
    $(SDK_ROOT)/components/ble/nrf_ble_qwr \
    $(SDK_ROOT)/components/libraries/button \
    $(SDK_ROOT)/components/libraries/usbd \
    $(SDK_ROOT)/components/drivers_nrf/saadc \
    $(SDK_ROOT)/components/ble/ble_services/ble_lbs_c \
    $(SDK_ROOT)/components/ble/ble_racp \
    $(SDK_ROOT)/components/toolchain/gcc \
    $(SDK_ROOT)/components/libraries/fds \
    $(SDK_ROOT)/components/libraries/twi \
    $(SDK_ROOT)/components/drivers_nrf/clock \
    $(SDK_ROOT)/components/ble/ble_services/ble_rscs \
    $(SDK_ROOT)/components/drivers_nrf/swi \
    $(SDK_ROOT)/components/ble/ble_services/ble_hrs \
    $(SDK_ROOT)/components/libraries/log/src \

    # Libraries common to all targets
    LIB_FILES += \

    # C flags common to all targets
    CFLAGS += -DNRF51
    CFLAGS += -DNRF51422
    CFLAGS += -DSWI_DISABLE0
    CFLAGS += -DBOARD_BLE400
    CFLAGS += -DBSP_DEFINES_ONLY
    CFLAGS += -mcpu=cortex-m0
    CFLAGS += -mthumb -mabi=aapcs
    CFLAGS += -Wall -Werror -O3 -g3
    CFLAGS += -mfloat-abi=soft
    # keep every function in separate section, this allows linker to discard unused ones
    CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
    CFLAGS += -fno-builtin --short-enums

    # C++ flags common to all targets
    CXXFLAGS += \

    # Assembler flags common to all targets
    ASMFLAGS += -x assembler-with-cpp
    ASMFLAGS += -DNRF51
    ASMFLAGS += -DNRF51422
    ASMFLAGS += -DSWI_DISABLE0
    ASMFLAGS += -DBOARD_BLE400
    ASMFLAGS += -DBSP_DEFINES_ONLY

    # Linker flags
    LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
    LDFLAGS += -mcpu=cortex-m0
    # let linker to dump unused sections
    LDFLAGS += -Wl,--gc-sections
    # use newlib in nano version
    LDFLAGS += --specs=nano.specs -lc -lnosys


    .PHONY: $(TARGETS) default all clean help flash

    # Default target - first one defined
    default: nrf51422_xxac

    # Print all targets that can be built
    help:
    @echo following targets are available:
    @echo nrf51422_xxac

    TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc

    include $(TEMPLATE_PATH)/Makefile.common

    $(foreach target, $(TARGETS), $(call define_target, $(target)))

    # Flash the program
    flash: $(OUTPUT_DIRECTORY)/nrf51422_xxac.hex
    @echo Flashing: $<
    nrfjprog --program $< -f nrf51 --sectorerase
    nrfjprog --reset -f nrf51

    erase:
    nrfjprog --eraseall -f nrf52
    -------------------------------------------------------------------------------------------------

    -------------------------------------------------------------------------------------------------
    Compilation result:
    -------------------------------------------------------------------------------------------------
    C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\examples\peripheral\blinky\ble400\blank\armgcc>make
    mkdir _build
    Compiling file: nrf_log_backend_serial.c
    Compiling file: nrf_log_frontend.c
    Compiling file: app_error.c
    Compiling file: app_error_weak.c
    Compiling file: app_timer.c
    Compiling file: app_util_platform.c
    Compiling file: hardfault_implementation.c
    Compiling file: nrf_assert.c
    Compiling file: sdk_errors.c
    Compiling file: boards.c
    Compiling file: nrf_drv_clock.c
    Compiling file: nrf_drv_common.c
    Compiling file: nrf_drv_uart.c
    Compiling file: nrf_nvic.c
    Compiling file: nrf_soc.c
    Compiling file: main.c
    Compiling file: RTT_Syscalls_GCC.c
    Compiling file: SEGGER_RTT.c
    Compiling file: SEGGER_RTT_printf.c
    Assembling file: gcc_startup_nrf51.S
    Compiling file: system_nrf51.c
    Linking target: _build/nrf51422_xxac.out

    text data bss dec hex filename
    3132 108 112 3352 d18 _build/nrf51422_xxac.out

    Preparing: _build/nrf51422_xxac.hex
    Preparing: _build/nrf51422_xxac.bin

    C:\Nordic_semi\nRF5_SDK_12.3.0_d7731ad\examples\peripheral\blinky\ble400\blank\armgcc>
    -------------------------------------------------------------------------------------------------

  • I new in Nordic products too

    That seems to be the only thing that your post has in common with the rest of this 5-month-old thread?

    Best to start your own thread rather than hijack an unrelated one.

    Any particular reason for starting with nRF51 ?

    Especially as nRF51 is not recommended for new BLE projects:

    https://devzone.nordicsemi.com/f/nordic-q-a/42960/status-of-nrf51-products/169728#169728

    You'd make your life easier using a Nordic Dev Kit - See:

    https://devzone.nordicsemi.com/f/nordic-q-a/49079/nrn51822-not-reconized/195385#195385

    How to properly post source code:

    (also for stuff like makefiles, logs, etc)

  • Thank you for your support, I need integrate installed beacon's network based on nRF51822, with new custom beacons based on nRF52832.

    I tested development on nRF52832 without issues (SDK v15.3 + GCC) it's perfect, but I need make some developments on nRF51822, I want to use most recent compatible SDK v12.3.

    This the reason because I need learn how to program over nRF51822, it's mandatory for me.

  • Which part of  "create a new question" did you not understand?

Related