diff --git a/README.md b/README.md index c0db5361..470bcab3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -# Arduino Core for Adafruit nRF52 Feather Boards +# Arduino Core for Adafruit Bluefruit nRF52 Boards + +This repository contains the Arduino BSP for Adafruit nRF52 series: + +- [Bluefruit Feather nRF52832](https://www.adafruit.com/product/3406) ## BSP Installation @@ -21,33 +25,29 @@ There are two methods that you can use to install this BSP. We highly recommend * OS X : `~/Library/Arduino15/packages/adafruit/hardware/nrf52` * Linux : `~/.arduino15/packages/adafruit/hardware/nrf52` * Windows: `%APPDATA%\Local\Arduino15\packages\adafruit\hardware\nrf52` - 3. ```cd ```, where `````` is your Arduino Sketch folder: - * OS X : ```~/Documents/Arduino``` - * Linux : ```~/Arduino``` - * Windows: ```~/Documents/Arduino``` - 4. Create a folder named ```hardware/Adafruit```, if it does not exist, and change directories to it - 5. Clone this repo: `git clone git@github.com:adafruit/Adafruit_nRF52_Arduino.git` + 3. `cd `, where `` is your Arduino Sketch folder: + * OS X : `~/Documents/Arduino` + * Linux : `~/Arduino` + * Windows: `~/Documents/Arduino` + 4. Create a folder named `hardware/Adafruit`, if it does not exist, and change directories to it + 5. Clone this repo: `git clone https://github.com/adafruit/Adafruit_nRF52_Arduino.git` 6. Restart the Arduino IDE 7. Once the BSP is installed, select 'Adafruit Bluefruit nRF52 Feather' from the Tools -> Board menu, which will update your system config to use the right compiler and settings for the nRF52. -### Third Party Tools +### Adafruit's nrfutil tools -#### nrfutil +[adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) (derived from Nordic pc-nrfutil) is needed to upload sketch via serial port. -The Adafruit nRF52 BSP includes a [python wrapper](https://github.com/NordicSemiconductor/pc-nrfutil) -for Nordic's `nrfutil`, which is used to flash boards. Go into the BSP folder -(`hardware/Adafruit/Adafruit_nRF52_Arduino/tools/nrfutil-0.5.2`), and run the following to make -this available to the Arduino IDE: +- For Windows and macOS, pre-built executable binaries are included in the BSP at `tools/adafruit-nrfutil/`. It should work out of the box. +- Linux user need to run follow command to install it from PyPi -``` -$ cd tools/nrfutil-0.5.2 -$ sudo pip install -r requirements.txt -$ sudo python setup.py install -``` + ``` + $ pip3 install adafruit-nrfutil --user + ``` -**Notes** : Don't install nrfutil from the pip package (ex. `sudo pip install nrfutil`). The -latest nrfutil does not support DFU via Serial, and you should install the local copy of 0.5.2 -included with the BSP via the `python setup.py install` command above. +### Drivers + +- [SiLabs CP2104 driver](http://www.silabs.com/products/mcu/pages/usbtouartbridgevcpdrivers.aspx) is required for USB to Serial when using with Feather nRF52832 ## Arduino BLE Application Support @@ -63,17 +63,33 @@ examples sketched for the selected board. ## Bootloader Support -### Third Party Tools +### Upgrade existiting Bootloader + +Bluefruit's Bootloader is self-upgradable, you could upgrade to the latest Bootloader + Softdevice using the serial port within Arduino IDE. + +- Select `Tools > Board > Adafruit Bluefruit Feather52` +- Select `Tools > Programmer > Bootloader DFU for Bluefruit nRF52` +- Select `Tools > Burn Bootloader` +- **WAIT** until the process complete ~30 seconds + +Note: close the Serial Monitor before you click "Burn Bootloader". Afterwards, you shouldn't close the Arduino IDE, unplug the Feather, launch Serial Monitor etc ... to abort the process. There is a high chance it will brick your device! Do this with care and caution. + +### Burnning new Bootloader To burn the bootloader from within the Arduino IDE, you will need the following tools installed on your system and available in the system path: -#### Jlink Driver and Tools +- Segger [JLink Software and Documentation Pack](https://www.segger.com/downloads/jlink) +- Nordic [nRF5x Command Line Tools](http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.tools%2Fdita%2Ftools%2Fnrf5x_command_line_tools%2Fnrf5x_installation.html) -Download and install the [JLink Software and Documentation Pack](https://www.segger.com/downloads/jlink) -from Segger, which will also install a set of command line tools. +Check to make sure you can run `nrfjprog` from your terminal/command prompt -### Burning the Bootloader +**OS X Note** At present, you will need to create a symlink in `/usr/local/bin` to the +`nrfjprog` tool wherever you have added it. You can run the following command, for example: + +``` +$ ln -s $HOME/prog/nordic/nrfjprog/nrfjprog /usr/local/bin/nrfjprog +``` Once the tools above have been installed and added to your system path, from the Arduino IDE: @@ -83,24 +99,11 @@ Once the tools above have been installed and added to your system path, from the #### Manually Burning the Bootloader via nrfjprog -You can also manually burn the bootloader from the command line, you will need `nrfjprog` from Nordic: - -- Download [nRF5x-Command-Line-Tools](https://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF52832#Downloads) for OSX/Linux/Win32 -- Extract the downloaded file and add the extracted path to your environment `PATH` variable -- Check to make sure you can run `nrfjprog` from your terminal/command prompt - -**OS X Note** At present, you will need to create a symlink in `/usr/local/bin` to the -`nrfjprog` tool wherever you have added it. You can run the following command, for example: - -``` -$ ln -s $HOME/prog/nordic/nrfjprog/nrfjprog /usr/local/bin/nrfjprog -``` - -Then run the command as follows: +The bootloader hex file can be found at `bin/bootloader` run the command as follows: ``` $ nrfjprog -e -f nrf52 -$ nrfjprog --program bootloader_with_s132.hex -f nrf52 +$ nrfjprog --program feather_nrf52832_bootloader.hex -f nrf52 $ nrfjprog --reset -f nrf52 ``` @@ -142,3 +145,4 @@ which in turn is based on the [Arduino SAMD Core](https://github.com/arduino/Ard The following tools are used: * [GCC ARM Embedded](https://launchpad.net/gcc-arm-embedded) as the compiler + * adafruit-nrfutil is based on Nordic Semiconductor ASA's [pc-nrfutil](https://github.com/NordicSemiconductor/pc-nrfutil) diff --git a/changelog.md b/changelog.md index 357543cc..9c8c8bdd 100644 --- a/changelog.md +++ b/changelog.md @@ -2,8 +2,10 @@ ## 0.8.5 +- Migrate nrfutil to adafruit-nrfutil, executable binaries for windows and macOS are included. - Implement #166 BLE HID Keyboard LED receive from Central, update hid_keyscan & hid_keyboard example. - Add hardware's systick sketch example +- Add software timer's sketch example ## 0.8.4 diff --git a/libraries/Bluefruit52Lib/examples/Hardware/hw_systick/hw_systick.ino b/libraries/Bluefruit52Lib/examples/Hardware/hw_systick/hw_systick.ino index 91812309..2cf39236 100644 --- a/libraries/Bluefruit52Lib/examples/Hardware/hw_systick/hw_systick.ino +++ b/libraries/Bluefruit52Lib/examples/Hardware/hw_systick/hw_systick.ino @@ -13,6 +13,9 @@ *********************************************************************/ #include +// Interval between systick event +#define TICK_INTERVAL_MS 50 + // Note: Extern "C" is required since all the IRQ hardware handler is // declared as "C function" within the startup (assembly) file. // Without it, our SysTick_Handler will be declared as "C++ function" @@ -37,8 +40,15 @@ void SysTick_Handler(void) void setup() { - // Set up systick to fire 10 times per second - SysTick_Config(F_CPU/10); + /* Input parameter is number of ticks between interrupts handler i.e SysTick_Handler + * 1000 ms --> F_CPU ticks + * T ms --> (F_CPU/1000)*T ticks + * + * Note: Since systick is 24-bit timer, the max tick value is 0xFFFFFF, F_CPU = 64 Mhz + * --> our Tmax = 0xFFFFFF/64000 ~ 262 ms + */ + + SysTick_Config( (F_CPU/1000)*TICK_INTERVAL_MS ); } void loop() diff --git a/platform.txt b/platform.txt index 075c697b..13b9c895 100644 --- a/platform.txt +++ b/platform.txt @@ -122,34 +122,31 @@ recipe.size.regex.data=(\.data|\.bss|\.stack)\s+([0-9]+).* recipe.output.tmp_file={build.project_name}.hex recipe.output.save_file={build.project_name}.{build.variant}.hex -#********************************************** +#*************************************************** # adafruit-nrfutil for uploading # https://github.com/adafruit/Adafruit_nRF52_nrfutil -# Note : For MacOS, make a symlink to /usr/local/bin/adafruit-nrfutil -# if installed to other location -#********************************************** +# pre-built binaries are provided for macos and windows +#*************************************************** tools.nrfutil.cmd=adafruit-nrfutil -#tools.nrfutil.cmd.windows={runtime.platform.path}/tools/nrfutil-0.5.2/binaries/win32/nrfutil.exe -tools.nrfutil.cmd.macosx=/usr/local/bin/adafruit-nrfutil +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil tools.nrfutil.upload.params.verbose=--verbose tools.nrfutil.upload.params.quiet= tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank -#********************************************** +#*************************************************** # Jlink for programming -#********************************************** +#*************************************************** #tools.nrfutil.upload.pattern=nrfjprog --reset --program "{build.path}/{build.project_name}.hex" --sectorerase -f nrf52 # && nrfjprog --erasepage {upload.BOOT_SETTING_ADDR} -f nrf52 && nrfjprog --memwr {upload.BOOT_SETTING_ADDR} --val 0x00000001 -f nrf52 && nrfjprog --reset -f nrf52 # tools.nrfutil.upload.BOOT_SETTING_ADDR=0xFF000 - -#********************************************** +#*************************************************** # Burning bootloader with either jlink or nrfutil -#********************************************** - +#*************************************************** tools.bootburn.bootloader.params.verbose= tools.bootburn.bootloader.params.quiet= tools.bootburn.bootloader.pattern={program.pattern} diff --git a/programmers.txt b/programmers.txt index 4473f04c..3f17919c 100644 --- a/programmers.txt +++ b/programmers.txt @@ -1,7 +1,6 @@ #********************************************** # Jlink with nrfjprog to burn bootloader #********************************************** - nrfjprog.name=J-Link for Bluefruit nRF52 nrfjprog.program.tool=bootburn #nrfjprog.program.path={runtime.tools.nrfjprog.path}/ @@ -12,13 +11,12 @@ nrfjprog.program.cmd.windows=nrfjprog.exe nrfjprog.program.pattern="{program.path}{program.cmd}" --program "{runtime.platform.path}/bootloader/{build.variant}/beta/{build.variant}_bootloader_{build.sd_name}_{build.sd_version}r0.hex" -f nrf52 --chiperase --reset #********************************************** -# nrfutil to upgrade bootloader -# # Note : For MacOS, make a symlink to /usr/local/bin/nrfutil if installed to other location +# adafruit-nrfutil to upgrade bootloader #********************************************** nrfutil_boot.name=Bootloader DFU for Bluefruit nRF52 nrfutil_boot.program.tool=bootburn nrfutil_boot.program.cmd=adafruit-nrfutil -#nrfutil_boot.program.cmd.windows={runtime.platform.path}/tools/nrfutil-0.5.2/binaries/win32/nrfutil.exe -nrfutil_boot.program.cmd.macosx=/usr/local/bin/adafruit-nrfutil +nrfutil_boot.program.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe +nrfutil_boot.program.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil nrfutil_boot.program.pattern={program.cmd} --verbose dfu serial -pkg "{runtime.platform.path}/bootloader/{build.variant}/beta/{build.variant}_bootloader_{build.sd_name}_{build.sd_version}r0.zip" -p {serial.port} -b 115200 diff --git a/tools/adafruit-nrfutil/macos/adafruit-nrfutil b/tools/adafruit-nrfutil/macos/adafruit-nrfutil new file mode 100755 index 00000000..18e874e8 Binary files /dev/null and b/tools/adafruit-nrfutil/macos/adafruit-nrfutil differ diff --git a/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe b/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe new file mode 100644 index 00000000..1d32d6b6 Binary files /dev/null and b/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe differ