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.
Requirement
A device (like PCA10000) running Master Emulator.
Setup
-
Download and install the newest IronPython (Python with .Net support) from http://ironpython.codeplex.com/releases/view/90087
-
Configure Windows Environment Variables to include IronPython's execution path.
-
Locate the directory where you installed Master Control Panel. We need "main.py".
-
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.)
-
Now test it with "--help" argument, you should get output as shown below.
-
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.)
-
Run MCP, and get the DFU-ready device's address.
-
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]".
-
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.