Reprogram the nRF51822 Beacon Kit to work with iOS 8

When I decided to attempt the reprogramming of my nRF51822 Beacon Kit I read several posts related to the task. The information I needed was there but I found it to be a bit scattered. It was difficult for me to put it all together; particularly so as I am a newbie. Now that I have been successful I decided to document the process. Hopefully it will help someone.

Note that several of the steps require Windows capability in order to run the tools (msi installer, crc.exe, hex2bin.exe, Keil uVision). I am a mac user and will be exploring OS X alternatives. For now I am using a Windows virtual machine.

I. First I verified that the DFU/OTA functionality worked properly. I wanted to do this without introducing any problems stemming from incorrect builds so I used the existing, unmodified Beacon firmware. Here are the steps:

  1. Install nRF51822_beacon_firmware_1.1.1.msi. Locate the file ...\nRF51822 Beacon v1.1.1\Precompiled hex\nrf51822_beacon_app.hex.
  2. Install the nRF Toolbox on the iPhone (or iPad). I have version 2.2
  3. Obtain hex2bin.exe, crc.exe, and application.dat
  4. Process nrf51822_beacon_app.hex with hex2bin.exe to generate nrf51822_beacon_app.bin
  5. Process nrf51822_beacon_app.bin with crc.exe to generate a CRC. Several CRCs are produced. Choose the one with the label CRC-CCITT (0xffff). The value that I got was 0x6563.
  6. Replace the original CRC in application.dat with the generated CRC. You must reorder the CRC so that the lsb comes first. Application.dat original: FF FF FF FF FF FF FF FF 02 00 4F 00 5A 00 9D B0. Application.dat modified: FF FF FF FF FF FF FF FF 02 00 4F 00 5A 00 63 65.
  7. Produce a zip archive that contains the init file (application.dat) and the application. You can use the .bin or the .hex variant of the application - either one will work. The iOS nRF Toolbox app complained if the application file name was other than application.hex or application.bin so I renamed the application file before I zipped it.
  8. Use iTunes to upload the zip file to the iPhone's nRFToolbox application. This will show you how.
  9. Put the Beacon into DFU mode by pressing SW1. The LED will blink blue.
  10. Go to the DFU "tab" of the nRFToolbox app.
  11. Press "Select Device" and choose "DFUTarg"
  12. Press "Select File" then press "User Files" and choose the zip file.
  13. Press "Select File Type" and choose "application".
  14. Press "Upload". The nRFToolbox app will show a progress dialog. The Beacon's LED will intermittently blink a rapid blue. When the upload is complete the nRfToolbox app will display a success dialog and the Beacon will reboot.
  15. Verify that the nRFToolbox app can interact with the beacon as before.

II. Next I verified that I could rebuild the exiting source code and then install it. Here are the steps:

  1. Install Keil MDK-ARM. The Keil Pack Installer installer will be launched. Use it to install the nRF51 soft packs and the nRF51 Blinky example. Open the Blinky project with uVision and verify the MDK installation by building it.
  2. Use uVision to open .../nRF51822 Beacon v1.1.1/Source Code/nrf51_beacon/ble_app_beacon/pca20006/s110/arm/ble_app_beacon_s110_pca20006.uvprojx and build it. I had to add .../components/toolchain/gcc to the include path (Project Menu -> Options for 'Target nrf51822_xxac_s110' then select the C/C++ tab to edit the include path).
  3. Find the hex file produced by step 2 (...\nRF51822 Beacon v1.1.1\Source Code\nrf51_beacon\ble_app_beacon\pca20006\s110\arm_build\nrf51822_beacon_app.hex) and use the DFU process above to load it into the beacon. When I ran crc.exe I got the same CRC as before, i.e 0x6563 - no changes, hence same CRC.
  4. Verify that the nRFToolbox app can interact with the beacon as before.

III. Finally, I modified the nRF51822 Beacon v1.1.1 source code so that the BLE Beacon App could successfully advertise itself to an app running on iOS 8. Here are the steps:

  1. Edit ...\nRF51822 Beacon v1.1.1\Source Code\nrf51_beacon\common\beacon\beacon.h. Change the value of the constant APP_DEFAULT_COMPANY_IDENTIFIER from 0x0059 to 0x004C (i.e. from Nordic's ID to Apple's ID). Make sure that the value of APP_DEFAULT_BEACON_UUID is the same as the UUID being scanned for by your iOS app (change it in beacon.h or in the iOS app).
  2. Repeat the Build and DFU procedures given above. This time the CRC was 0xC8F8.
  3. Run your iOS 8 app and verify that it detects the beacon. I am using this app. Nordic's iOS app doesn't work because it is scanning for arbitrary beacons and, as we know, this no longer works in iOS 8; i.e. iOS 8 apps must specify the UUID of the beacon being scanned for.

Cheers from Charlotte, NC USA.