nRF51822 with pyOCD and Arch
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.
1. use Arch as an mbed interface to run CMSIS-DAP.
- Download mbed interface firmware for Arch.
- 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
- Quick press the button. "MBED" drive will pop up.
- Install the mbed interface driver for windows to enable USB2UART function
2. 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.
3. flash a hex file generated by mbed online compiler or application binary file to nRF51822.
The hex file include three parts - Code Region 0(CR0), Code Region 1 and User Information Configuration Registers(UICR). We can flash the hex file byt running
sudo python flash_nrf51822.py -i {ble_app.hex}
To flash an application binary without ble stack
sudo python flash_nrf51822.py -b {application.bin}
10 comments on nRF51822 with pyOCD and Arch:
Great, so nRF51822 can be downloaded by a CMSIS-DAP interface. Can I program nRF via CMSIS-DAP debugger on FRDM board? And does it (nRF) have any ISP options like regular MCU does?
The nRESET & SWDIO are the same pin#23 on the nrf51822! but above you should that nRESET and SWDIO need to be connected individually! ,so How I'm supposed to connect in such a case?
Hi Nishant,
You can just connect SWDIO to nRF51822's nRSET & SWDIO. The script can reset nRF51822 through SWCLK and SWDIO.
Can I program nRF via CMSIS-DAP debugger on FRDM board? And does it (nRF) have any ISP options like regular MCU does?
Any CMSIS-DAP debugger supported by pyOCD can be used to program nRF51822. As I know, nRF51822 don't have a ISP options.
Cool note, so I'd like to try to compile by myself of your CMSIS-DAP proect from your Github site (https://github.com/xiongyihui/CMSIS-DAP/tree/lpc11u24)
First, I download and oended project file "\CMSIS-DAP-xiong\interface\mdk\lpc11u24\lpc11u24_interface.uvproj"
and I selected sub-project of "lpc11u24_lpc11u24_if", because I bought 2 Seeed Arch Board.
finally I compiled But, I met the error like:
"gpio.c: Error: #5: cannot open source input file "..\..\interface\hal\TARGET_NXP\TARGET_LPC11U24\gpio.c": No such file or directory"
so I try to find that directory, but I can't. just there is "TARGET_LPC11U35" directory only.
Something wrong? Please help me~ Thanks.
Hi Nishant, You can just connect SWDIO to nRF51822's nRSET & SWDIO. The script can reset nRF51822 through SWCLK and SWDIO.
Thanks yihui , can you describe what you mean by making a schmatics or Fritzing drawing?
Yihui,
can I do it with mBed LPC11u24? instead of the Arch.
Yihui,
can I do it with mBed LPC11u24? instead of the Arch.
To use mbed LPC11U24, you need to add USB connector as the on-board USB connector is for mbed interface.
insanity_wolf
#
19 Aug 2015
Hi Yihui,
I get the following error under Windows:
C:\Users\Kauz\Desktop\NRF51>python flash_nrf51822.py -i {beacon.hex}
Traceback (most recent call last):
File "flash_nrf51822.py", line 192, in <module>
adapter = MbedBoard("target_lpc1768", "flash_lpc1768", first_interface)
File "C:\Python27\lib\site-packages\pyOCD\board\mbed_board.py", line 86, in
init
raise Exception("Unknown board target")
Exception: Unknown board target
Has pyOCD changed over time and an adaptation in flash_nrf51822 is necessary? Is this the problem? Because everything installs fine and the Arch seems to be recognized on the USB port...your help would be appreciated.
Thanks in advance,
Arthur
Please log in to post comments.
Great, so nRF51822 can be downloaded by a CMSIS-DAP interface. Can I program nRF via CMSIS-DAP debugger on FRDM board? And does it (nRF) have any ISP options like regular MCU does?