I’m quite excited that Bluetooth Low Energy (nRF51822) is comming to mbed. So I’m exploring what we can do with BLE (nRF51822). Preparing tools to get started with new things is always the beginning.

Here we use CMSIS-DAP and pyOCD. CMSIS-DAP is the software running on mbed interface to provide drag-n-drop, USB2UART communication and SWD debug. pyOCD is an Open Source python library or programming and debugging ARM Cortex-M microcontrollers using CMSIS-DAP.

First, use Arch as an mbed interface to run CMSIS-DAP.

  1. Download mbed interface firmware for Arch.
  2. Connect Arch with PC, long press Arch’s button and replace firmware.bin with the new firmware in “CRP DISABLD” drive on windows. use dd if=lpc11u24_nrf51822_if_mbed.bin of={path-to}/firmware.bin conv=notrunc on Linux/Mac
  3. Quick press the button. “MBED” drive will pop up.
  4. Install the mbed interface driver for windows to enable USB2UART function

CMSIS-DAP debug adapter

Second, setup pyOCD for nRF51822. We need pyOCD, pyUSB(Linux) or pyWinUSB(Windows) and flash_nrf51822.py

On Ubuntu

sudo apt-get install python-setuptools
sudo easy_install pyusb
sudo easy_install pyocd
sudo easy_install intelhex
wget https://github.com/xiongyihui/pyOCD/raw/master/util/flash_nrf51822.py

On windows, install pyWinUSB instread of pyUSB.

Third, flash a hex file generated by mbed online compiler or an application binary file to nRF51822.

The hex file includes threee parts — Code Region 0 (CR0), Code Region 1 (CR1) and User Information Configuration Registers (UICR). To flash the hex file, run

sudo python flash_nrf51822.py -i {ble.hex}

To flash an application binary with an offset 0x14000

sudo python flash_nrf51822.py -b {app.bin}


blog comments powered by Disqus

Published

31 March 2014

Tags