User Tools

Site Tools


s340_softdevice_adafruit_nrf52840_feather_express

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
s340_softdevice_adafruit_nrf52840_feather_express [2020/02/07 22:09]
orrmany [Modify the Adafruit bootloader]
s340_softdevice_adafruit_nrf52840_feather_express [2020/03/15 17:04] (current)
orrmany
Line 1: Line 1:
-====== ​S340 SoftDevice & Adafruit nRF52840 Express Feather ​====== +====== ​Page moved!======
-This lazy-guide is a short summary about how I made my [[https://​www.adafruit.com/​product/​4062|Adafruit Feather nRF52840 Express]] work with ANT+.+
  
-The Feather is an Arduino compatible board using the [[https://​www.nordicsemi.com/​Products/​Low-power-short-range-wireless/​nRF52840|nRF52840 SoC]] from Nordic Semiconductor (NordicSemi). +**NOTES:* 
- +  ​The content ​of this page used to be [[arduino:s340_softdevice_adafruit_nrf52840_feather_express|S340 SoftDevice ​& Adafruit nRF52840 Express ​Feather]]. ​Now this page has been moved down to the [[arduino:​]] ​namespace ​of this wiki 
-===== Introduction ===== +  - This page has been also republished ​as a [[https://blogarak.wordpress.com/2020/03/15/s340-softdevice-adafruit-nrf52840-express-feather/|as blog entry ]] 
-[[https://​en.wikipedia.org/​wiki/​ANT_(network)|ANT]] (Adaptive Network Topology) is a wireless communication network standard intended for sensor networks. Originally developed by DynaStream, it currently belongs to Garmin. It operates in the [[https://​en.wikipedia.org/​wiki/​ISM_band|ISM spectrum]] and most of its specs available publicly. Certain IPR-s remains controlled by Garmin, but for non-commerical use it can be used without a license fee.  + 
- +
-[[https://​en.wikipedia.org/​wiki/​ANT_(network)#​ANT+|ANT+]] is a interoperability standard on top of the ANT transport standard in order to create an "ultra low-power wireless"​ ecosystem for fitness and medical applications. Notably, Garmin runners'​ and bikers'​ watches and bike-computers uses this standard to communicate with various measurement sensors. +
- +
-The nRF52840 SoC is part of the nRF52 series of chips from NordicSemi. It is multi-protocol capable and a number of Arduino compatible boards sports this chipset. The most notable ones: +
-  ​The [[https://​en.wikipedia.org/​wiki/​ANT_(network)#​ANT+|nRF52849-DK]] Development Kit from NordicSemi +
-  ​[[https://​www.adafruit.com/​product/​4062|Adafruit Feather nRF52840 Express]] from AdaFruit Industries +
-  ​The [[https://​www.sparkfun.com/​products/​15025|nRF52840 Pro Mini]] fromSparkFun +
- +
-For legal (and probably other reasons) neither ​of these boards come with the ANT+ protocol stack pre-installed,​ albeit they are fully capable of running that stack. This guide is a summary of how I made my Adafruit nRF52840 Feather ANT+ capable while I kept its original functionality,​ i.e., being Arduino compatible and supporting Adafruit'​s Bluefruit Bluetooth library. +
- +
-The adaptation removes the Bluetooth only S140 SoftDevice from the firmware and replaces it with the S340 combined SoftDevice running BLE5 and ANT+ concurrently.  +
-   +
-**Note**: The CircuitPython capability will be lost, since the stock CircuitPython interpreter for this Feather is provided as a binary UF2 firmware update is bound to the S140 Bluetooth-only softdevice.  +
- +
-**BEWARE**: trying to install the CircuitPython UF2 package to a S340-adapted Feather will brick your Feather and you will need to use a SWD programmer device to make your Feather usable again! +
-==== Credits ==== +
-A number of internet resources helped me. The biggest help came as form of a personal mail from "​Ryan",​ whom I got acquainted with by [[https://​www.arduinolibraries.info/​authors/​cujomalainey|Curtis Malainey]]. It was "​Ryan",​ who first managed the S340 SoftDevice ​to work with his Feather ​and he kindly shared his steps with me. This guide is based primarily on his work.   +
-  *   ​[[https://​github.com/​charlesportwoodii/​Adafruit_nRF52_Bootloader]] -- some interesting learnings about the bootloader +
-  * [[https://​learn.sparkfun.com/​tutorials/​nrf52840-advanced-development-with-the-nrf5-sdk]] -- I learnt a lot about using the nRF5 SDK and the ARM-GCC workflow +
-  * [[https://​learn.sparkfun.com/​tutorials/​nrf52840-development-with-arduino-and-circuitpython]] tons of info about what does it take to add a new board-type to the Arduino IDE. This also helped a lot in understanding Ryan's comments about his PlatformIO adaptation. +
-  * The Adafruit nrf52 bootloader[[https://​github.com/​adafruit/​Adafruit_nRF52_Bootloader]] +
-  * A blog entry of a similar bootloader hack success. but with the SparkFun PRo Mini board: ​ . https://​judepereira.com/​blog/​nrf52840-flash-s340/​ +
- +
-===== Prequisites ===== +
-==== Must to have  ====  +
-  * You will need, obviously, an [[https://​www.adafruit.com/​product/​4062|Adafruit Feather nRF52840 Express]] +
-  * The original Adafruit bootloader from GitHub: [[https://​github.com/​adafruit/​Adafruit_nRF52_Bootloader]],​ and the corresponding toolchain:​ +
-    * The [[https://​developer.arm.com/​tools-and-software/​open-source-software/​developer-tools/​gnu-toolchain/​gnu-rm/​downloads|Gnu ARM Toolchain]] +
-    * The [[https://​www.nordicsemi.com/​Software-and-Tools/​Development-Tools/​nRF-Command-Line-Tools|nRF5x Command Line Tools]] +
-  * The [[https://​www.thisisant.com/​developer/​components/​nrf52832#​tab_protocol_stacks_tab|S340 SoftDevice]] realizing the BLE5 & ANT+ protocol stacks +
- +
-==== Most likely you will need to have  ====  +
-  * An SWD programmer (Segger J-link), just in case if you need to "​unbrick"​ your feather after a mistake.  +
-**Note**: the nRF52840-DK from NordicSemi contains an On-Board Segger programmer (Segger-OB),​ which is free to use for Nordic chipsets. The Segger OB on the NordicSemi DevKit ​also has an SWD connector for external boards, so it can be used with the Feather, ​as well.  Otherwise the Segger EDU can be not-so-expensive alternative +
- +
-==== Good to have  ==== +
-  * If you need the Arduino IDE support, then the Adafruit Arduino BSP: [[https://github.com/​adafruit/​Adafruit_nRF52_Arduino]] +
-  * This can be also used for the [[https://​platformio.org/​platformio-ide|PlatformIO IDE]] support +
-===== Adapting the bootloader ===== +
-Note: this tutorial  +
-==== A. Warm-up: Rebuild the Adafruit bootloader ==== +
-1. Clone the Adafruit bootloader from https://​github.com/adafruit/Adafruit_nRF52_Bootloader. It contains two submodules, hence you need to clone it recursively. I used to the [[https://desktop.github.com/​|GitHub Desktop]], which does recursive cloning automagically +
-   +
-<code bash> +
-git clone https://​github.com/​adafruit/​Adafruit_nRF52_Bootloader +
-cd Adafruit_nRF52_Bootloader +
-git submodule update ​--init --recursive +
-</​code>​ +
-Follow its readme: https://​github.com/​adafruit/​Adafruit_nRF52_Bootloader/​blob/​master/​README.md +
-    ​install the ARM-GCC toolchain, plus the GNU make, as needed. See above +
-    ​install nRF5x command line tools, as needed. See above +
-    - install adafruit-nrfutil,​ a modified version of Nordic nrfutil, which required to perform DFU. Install python3 if it is not installed already and run this command to install adafruit-nrfutil from PyPi: +
-<code bash>$ pip3 install --user adafruit-nrfutil<​/code> +
- +
-2. Make sure that you can succesfully build and flash it into your board.  +
- +
-Follow the instructions at https://​github.com/​adafruit/​Adafruit_nRF52_Bootloader/​blob/​master/​README.md. Change the serial to your actual serial device. For me, under Windows10 it was COM5. Under Linux it could be, for example, /​dev/​ttyACM0 ​  +
-<code bash> +
-$ make BOARD=feather_nrf52840_express all combinehex +
-$ make BOARD=feather_nrf52840_express SERIAL=COM5 dfu-flash +
-</​code>​  +
- +
-If you run into any trouble, then **DO NOT PROCEED until you can successfully rebuild the original bootloader and flash it into your device!!** (If you can't build and flash the original version, then it makes no sense to try to hack it. +
- +
-==== B. Get the ANT SoftDevice ==== +
-Download [[https://​www.thisisant.com/​developer/​components/​nrf52832#​tab_protocol_stacks_tab|S340 SoftDevice]] from thisisant.com. +
-Unpack  +
- +
-==== Modify the Adafruit bootloader ==== +
-=== 1. Adapt the Makefile === +
-Insert the following after setting flags according to MCU_SUB_VARIANTS after line #106: +
-<code Makefile>​ +
-ifdef USE_S340  +
-#if S340 then adjust SD_NAME and MCU +
-  SD_NAME = s340 +
-  MCU_FLAGS = -DNRF52840_XXAA -DS340 +
-endif +
-</​code>​  +
-See the differences here. Left is original, right is the modified new +
-{{ :​make-diff.png?​direct |Makefile diff}} +
- +
-=== 2. Insert the S340 SoftDevice headers and binary into the source tree === +
-Go to ...\lib\softdevice\. Create ​dir called s340_nrf52_6.1.1:​ +
-<code bash> +
-...\lib\softdevice $ mkdir s340_nrf52_6.1.1 +
-</​code>​ +
- +
-This directory needs to store the v6.1.1 version of the BLE+ANT combinded S340 softdevice headers + the .hex binary. +
-The way you can get that is described here: [[https://​www.nordicsemi.com/​Software-and-tools/​Software/​S340-ANT]] +
- +
-**IMPORTANT:​**  +
-  - you should rename the .hex file to: s340_nrf52_6.1.1_softdevice.hex +
-  - You should put the S340 library headers under: s340_nrf52_6.1.1_API +
- +
-That is, your resulted library tree should look exactly like this: +
-<​code>​ +
-s340_nrf52_6.1.1/​ +
-├── s340_nrf52_6.1.1_API +
-│   └── include +
-│   ​    ​├── ant_error.h +
-│   ​    ​├── ant_interface.h +
-│   ​    ​├── ant_parameters.h +
-│   ​    ​├── ble.h +
-│   ​    ​├── ble_err.h +
-│   ​    ​├── ble_gap.h +
-│   ​    ​├── ble_gatt.h +
-│   ​    ​├── ble_gattc.h +
-│   ​    ​├── ble_gatts.h +
-│   ​    ​├── ble_hci.h +
-│   ​    ​├── ble_l2cap.h +
-│   ​    ​├── ble_ranges.h +
-│   ​    ​├── ble_types.h +
-│   ​    ​├── nrf52 +
-│   ​    ​│   └── nrf_mbr.h +
-│   ​    ​├── nrf_error.h +
-│   ​    ​├── nrf_error_sdm.h +
-│   ​    ​├── nrf_error_soc.h +
-│   ​    ​├── nrf_nvic.h +
-│   ​    ​├── nrf_sd_def.h +
-│   ​    ​├── nrf_sdm.h +
-│   ​    ​├── nrf_soc.h +
-│   ​    ​└── nrf_svc.h +
-└── s340_nrf52_6.1.1_softdevice.hex +
-</​code>​ +
-=== 3. Create a new board definition called ''​feather_nrf52840_express_s340''​=== +
-  * Go to ... /​src/​boards/​.  +
-  * Copy the '​feather_nrf52840_express'​ dir to '​feather_nrf52840_express_s340'​ +
-  * Go into the '​feather_nrf52840_express_s340'​ subdir, which was just freshly created by copying'​feather_nrf52840_express_s340'​ +
-== Modify src/​boards/​feather_nrf52840_express_s340/​board.h == +
-  - Change the #include guards from "​_FEATHER_NRF52840_H"​ to something else, say _FEATHER_NRF52840_S340_H +
-  - Change the "​BLEDIS_MODEL"​ to something else, say "​Feather nRF52840 Express w.ANT"​ +
-  - Change the "​UF2_PRODUCT_NAME"​ to something else, say ""​Adafruit Feather nRF52840 Express w.ANT"​ +
- +
-The diffs looks like this (left is orginal, right is modified) +
-{{ ::​boardh-diff.png?​direct |}}+
s340_softdevice_adafruit_nrf52840_feather_express.1581109767.txt.gz · Last modified: 2020/02/07 22:09 by orrmany