Flashing a Minew D15 iBeacon using nRF51 Development Kit

I've been looking a various replacements for the Bluegiga BLE112 and BLE113 modules I've been using so far for all projects involving BLE. Not that there is anything wrong with them, but they are a bit expensive.

So right now, I'm looking at the Nordic Semiconductor nRF51822 chip. It's got a couple of things going for it:

  • It is pretty cheap
  • It only requires relatively few support components
  • The free version of the Keil IDE can be used for most projects. And this is important since the Keil µVision IDE costs about $4000
  • The free, online IDE can be used
  • There's lots of documentation and many people are using it

I bought the nRF51 Development Kit (which has an onboard programmer) then I remembered I had a bunch of Minew D15 iBeacons lying around (From Alibaba). And since they are populated with nRF51822's, I figured I'd try to see if I could them flashed with my own firmware. (Spoiler alert: I could.)
Here's a short writeup of what I did.


  1. nRF51 Development Kit. I got mine at Farnell.
  2. Keil MDK-ARM Lite. The Lite version is a free version but is limited to 32 KB compiled code.
  3. nRFgo Studio and associated tools. Free download from Nordic Semi.
  4. nRF51 SDK. You can either download the SDK's from Nordic Semi's website or you can download them as packs from Keil's "Pack Installer" which is part of the IDE. I did both, which is certainly not necessary and only served to confuse me. I recommend using the Pack Installer – it's easier. So in the IDE go to Project -> Manage and choose Pack Installer…
  5. A Windows computer (sigh) or a Mac with Bootcamp or VMware Fusion running Windows (I use a MacBook Pro and VMware Fusion).

The code

I used the simplest possible example: good ol' blinky. Go to Project -> Manage -> Pack Installer… -> Nordic Semiconductor -> nRF51 Series, then click Examples in the right-hand pane, select blinky_blank_pca20006 (nRF51 PCA20006) and click "Copy". The "pcaXXXX" are the different board versions. The pca20006 is the small beacon puck which I thought came the closest to the Minew D15 puck. I was almost right.

Clicking "Rebuild project" in Keil will build the project. But, unfortunately, for a wrong chip and the wrong board, so let's fix that.

Choosing the correct chip

The Minew D15 uses a "QFABC00" version of nRF51822. That translates to "rev. 3, 128 KB flash, 16 KB RAM". Click "Target Options" and choose "Device". Then select nRF51 Series -> nRF51822_xxAB. This will set the correct chip.

You also need to specify that the crystal is a 16 MHz one. So select the "Target" tab and enter "16.0" in the field named "Xtal (MHz)".

Custom board

Since the Minew D15 does not have the same layout as the pca20006 we'll make a custom board definition:

  1. Add a new file named custom_board.h to the project. Place it in the same location as the main.c file. Paste in the code from the bottom of this post. This code defines a board with one LED and no buttons.
  2. Go to Target Options -> C/C++ and delete BOARD_PCA20006 and instead insert BOARD_CUSTOM.
  3. On the same tab, in the "Include Paths" field, enter ..\..\..

And we're done! Click "Rebuild" and it should suceed without any errors or warnings.


The nRF51 DK has an onboard Segger programmer. To use it we need four connections to the target D15 beacon:

  1. GND_DETECT: for ground reference
  2. VTG: target voltage reference to check if the device is powered up and to identify voltage levels
  3. SWDIO: serial-wire protocol IO signal
  4. SWDCLK: serial-wire protocol clock signal

Use the "P20 Debug Out" connector on the DK. Pinout is as follows (which they didn't bother putting in the manual) - from left (pin nearest the USB connector) to right:

  1. NC
  2. NC
  3. VTG
  4. SWDIO
  6. NC
  7. NC


If the device is self-powered – that is, has its own battery or power supply – simply connect VTG to the device's VCC and GND_DETECT to the device's GND.

You can also choose to power the device from the Devkit board. If so use the P1 connector's VDD and GND connections (there are multiple VDD and GND connections on P1) as follows:

  1. P20 VTG -> P1 VDD
  2. P20 GND_DETECT -> P1 GND
  3. P1 VDD -> device VCC
  4. P1 GND -> device GND

Nordic did document the P1 header and the connections are from left (nearest the USB connector) to right:

  1. VDD
  2. VDD
  3. RESET
  4. VDD
  5. 5V – Don't use this one. 5 V is too much and will fry the nRF51822!
  6. GND
  7. GND
  8. VIN

Connections on the Minew D15

The connections on the Minew D15 is as follows (seen from above):

Minew D15 pinout

So add headers or simply solder wires to the board and connect as described above.

Compile and install

Build the project (click "Rebuild" or "Build").

With both Devkit and device connected, open nRFgo Studio. Choose the Segger programmer under "nRF51 development boards" in "Device Manager" on the left. Now you should see the information for the Minew device showing the chip type (nRF51822, QFABC00) and the currently installed SoftDevice (S110_nRF51_8.0.0) in Region 0 and the application in Region 1.

Click "Erase all". Then select the "Program Application" tab, click "Browse…" and choose the .hex file that was generated (in the _build folder) and click "Program".

If everything goes well, the LED on the Minew board should now start blinking.

Yea, and verily...


// Defines the number of LEDs. In this example, there is a single LED.
#define LEDS_NUMBER 1

// Defines which PIOs control the LED.
#define LED_START 15
#define LED_1 15
#define LED_STOP 15

#define LEDS_LIST { LED_1 }

// A  single LED.
#define BSP_LED_0 LED_1
#define BSP_LED_0_MASK (1<<BSP_LED_0)

// Defines which LEDs are lit when the signal is low. In this example, no LEDs are lit.
#define LEDS_INV_MASK 0

// Defines the user buttons. In this example, there are no user buttons.
#define BUTTONS_MASK 0x00000000

Leave a Reply