Keil in-line program through DFU BLE

I am investigating Master Emulator API and found something interesting that can help you program your device through BLE DFU in Keil. This method calls the python script used in MCP. If you can use MCP DFU to program your device, it will also works for your Keil. BTW, this method emulates the exact BLE DFU procedure and the application is available just after a successful upload. No modification on bootloader or application code is required.


A device (like PCA10000) running Master Emulator.


  1. Download and install the newest IronPython (Python with .Net support) from

  2. Configure Windows Environment Variables to include IronPython's execution path. image description

  3. Locate the directory where you installed Master Control Panel. We need "". image description

  4. Create a dfu_upload.bat script in your project directory. (C: is the hard drive you installed MCP, and command cd is followed by the path got from step 3.) image description image description

  5. Now test it with "--help" argument, you should get output as shown below. image description

  6. Plug-in Master Emulator dongle, and DISCONNECT any other device from your PC. You can power your device with a battery or USB charger. (I think this is another BUG for the Master Emulator API. I found if you connect both devices to PC, the Python script in MCP may fail to find the true Master Emulator device.)

  7. Run MCP, and get the DFU-ready device's address. image description

  8. Run Keil uVision, open your application project. Click Project>Options for Target xxx..., and open Utilities tab. Check "Use External Tool for Flash Programming". In the "Command" box, locate the bat script. In the "Arguments" box, fill in "--file "#H" --mode APPLICATION --address [Your Device Address]". image description

  9. A command line window will pop up. After a while, it will gone if the upload is successful, and the Build Output sub-window will show all log messages. If it is stuck for a long time, Ctrl-C and check c:\ProgramData\Nordic Semiconductor\MasterEmulator\log.txt.