前言
在開發nRF51822前,當然要佈置他的開發環境
沒有錢買Keil C的我,只能用open source的東西自己架
安裝環境:Ubuntu 16.04
首先
要先檢查相關工具的版本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | You'll also need: - make - libtool - pkg-config >= 0.23 (or compatible) Additionally, for building from git: - autoconf >= 2.64 - automake >= 1.14 - texinfo USB-based adapters depend on libusb-1.0 and some older drivers require libusb-0.1 or libusb-compat-0.1. A compatible implementation, such as FreeBSD's, additionally needs the corresponding .pc files. USB-Blaster, ASIX Presto and OpenJTAG interface adapter drivers need: - libftdi: http://www.intra2net.com/en/developer/libftdi/index.php CMSIS-DAP support needs HIDAPI library. |
為了要可以支援CMSIS-DAP這個Open Source的燒錄器,需要安裝HID library和相關Library。
1 2 | sudo apt-get install libudev-dev libusb-1.0-0-dev libfox-1.6-dev sudo apt-get install libhidapi-dev |
之後去clone OpenOCD&開始編譯
1 2 3 4 5 | git clone https://github.com/riscv/riscv-openocd openocd ./bootstrap#(when building from the git repository) ./configure#[options] make sudo make install |
安裝好之後 就可以透過openOCD上傳第一支LED閃爍的程式測試了
1 | sudo openocd -f interface/cmsis-dap.cfg -f/target/nrf51.cfg |
成功的話,會跑出以下字串
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | Open On-Chip Debugger 0.10.0+dev-00132-g3ddbbd5 (2018-03-19-16:28) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'. cortex_m reset_config sysresetreq adapter speed: 1000 kHz Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : CMSIS-DAP: SWD Supported Info : CMSIS-DAP: JTAG Supported Info : CMSIS-DAP: Interface Initialised (SWD) Info : CMSIS-DAP: FW Version = 1.0 Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 1 nTRST = 0 nRESET = 1 Info : CMSIS-DAP: Interface ready Info : clock speed 1000 kHz Info : SWD DPIDR 0x0bb11477 Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints Info : Listening on port 3333 for gdb connections |
這時候就可以透過mbed先編譯一個 LED Blinky,下載Hex測試。
1 2 3 | telnet localhost 4444#連接openOCD Debug port >program /home/notbeloser/Downloads/mbed_blinky_NRF51822.hex verify >reset |
LED若是開始閃爍,代表成功!