This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
s340_softdevice_adafruit_nrf52840_feather_express [2020/02/07 22:55] orrmany [Modify the Adafruit bootloader] |
s340_softdevice_adafruit_nrf52840_feather_express [2020/02/09 17:50] orrmany [Credits] |
||
---|---|---|---|
Line 22: | Line 22: | ||
**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! | **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 ==== | ==== 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. | + | A number of internet resources helped me. The biggest help came as form of a personal mail from [[https://github.com/rtgree01|rtgree01]], whom I got acquainted with by [[https://www.arduinolibraries.info/authors/cujomalainey|Curtis Malainey]]. It was him, 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://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-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. | + | * [[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 rtgree01's comments about his PlatformIO adaptation. |
* The Adafruit nrf52 bootloader: [[https://github.com/adafruit/Adafruit_nRF52_Bootloader]] | * 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/ | * A blog entry of a similar bootloader hack success. but with the SparkFun PRo Mini board: . https://judepereira.com/blog/nrf52840-flash-s340/ | ||
- | ===== Prequisites ===== | + | ===== Prerequisites ===== |
==== Must to have ==== | ==== Must to have ==== | ||
* You will need, obviously, an [[https://www.adafruit.com/product/4062|Adafruit Feather nRF52840 Express]] | * You will need, obviously, an [[https://www.adafruit.com/product/4062|Adafruit Feather nRF52840 Express]] | ||
Line 45: | Line 45: | ||
* This can be also used for the [[https://platformio.org/platformio-ide|PlatformIO IDE]] support | * This can be also used for the [[https://platformio.org/platformio-ide|PlatformIO IDE]] support | ||
===== Adapting the bootloader ===== | ===== Adapting the bootloader ===== | ||
- | Note: this tutorial | + | Note: this tutorial is based on the v.6.1.1 versions of the NordicSemi softdevices and the 0.3.0 version of the Adafruit bootloader |
==== A. Warm-up: Rebuild the Adafruit bootloader ==== | ==== 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 | 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 | ||
Line 68: | Line 68: | ||
</code> | </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. | + | If you run into any trouble, then **DO NOT PROCEED further down within this lazy-guide 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 ==== | ==== B. Get the ANT SoftDevice ==== | ||
Download [[https://www.thisisant.com/developer/components/nrf52832#tab_protocol_stacks_tab|S340 SoftDevice]] from thisisant.com. | Download [[https://www.thisisant.com/developer/components/nrf52832#tab_protocol_stacks_tab|S340 SoftDevice]] from thisisant.com. | ||
- | Unpack | + | Unpack it somewhere. You will need to rename and copy it later. |
==== C. Modify the Adafruit bootloader ==== | ==== C. Modify the Adafruit bootloader ==== | ||
Line 138: | Line 138: | ||
* Go to ... /src/boards/. | * Go to ... /src/boards/. | ||
* Copy the 'feather_nrf52840_express' dir to 'feather_nrf52840_express_s340' | * 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' | + | * Go into the 'feather_nrf52840_express_s340' subdir, which was just freshly created by copying 'feather_nrf52840_express' over. |
== Modify src/boards/feather_nrf52840_express_s340/board.h == | == 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 #include guards from "_FEATHER_NRF52840_H" to something else, say _FEATHER_NRF52840_S340_H | ||
Line 186: | Line 186: | ||
{{ ::mainc-diff.png?direct |}} | {{ ::mainc-diff.png?direct |}} | ||
==== D. Build and flash the modified Adafruit bootloader ==== | ==== D. Build and flash the modified Adafruit bootloader ==== | ||
+ | Go to the root of the bootloader directory tree. Build and flash as follows. | ||
+ | **NOTE**: adapt the GNU_INSTALL_ROOT and SERIAL definitions according to your local setup! | ||
+ | <code bash> | ||
+ | make GNU_INSTALL_ROOT="C:/Program Files (x86)/GNU Tools Arm Embedded/9 2019-q4-major/bin/" BOARD=feather_nrf52840_express_s340 all combinehex | ||
+ | make GNU_INSTALL_ROOT="C:/Program Files (x86)/GNU Tools Arm Embedded/9 2019-q4-major/bin/" BOARD=feather_nrf52840_express_s340 SERIAL=COM5 dfu-flash | ||
+ | </code> | ||
+ | |||
+ | Enjoy :) | ||
+ | |||
+ | If you got confused you can check my forked repo at: https://github.com/orrmany/Adafruit_nRF52_Bootloader/tree/s340-for-nrf52840-Feather | ||
+ | ==== E. Appendix: a transcript of my build ==== | ||
+ | |||
+ | <code bash> | ||
+ | C:\Users\egbozie\Google Drive\Arduino\libraries\Adafruit_nRF52_Bootloader>make BOARD=feather_nrf52840_express all combinehex | ||
+ | CC main.c | ||
+ | CC boards.c | ||
+ | CC flash_nrf5x.c | ||
+ | CC dfu_ble_svc.c | ||
+ | CC dfu_init.c | ||
+ | CC nrfx_power.c | ||
+ | CC nrfx_nvmc.c | ||
+ | CC system_nrf52840.c | ||
+ | CC bootloader.c | ||
+ | CC bootloader_settings.c | ||
+ | CC bootloader_util.c | ||
+ | CC dfu_transport_serial.c | ||
+ | CC dfu_transport_ble.c | ||
+ | CC dfu_single_bank.c | ||
+ | CC pstorage_raw.c | ||
+ | CC ble_dfu.c | ||
+ | CC ble_dis.c | ||
+ | CC app_timer.c | ||
+ | CC app_scheduler.c | ||
+ | CC app_error.c | ||
+ | CC app_util_platform.c | ||
+ | CC crc16.c | ||
+ | CC hci_mem_pool.c | ||
+ | CC hci_slip.c | ||
+ | CC hci_transport.c | ||
+ | CC nrf_assert.c | ||
+ | CC usb_desc.c | ||
+ | CC usb.c | ||
+ | CC msc_uf2.c | ||
+ | CC ghostfat.c | ||
+ | CC dcd_nrf5x.c | ||
+ | CC tusb_fifo.c | ||
+ | CC usbd.c | ||
+ | CC usbd_control.c | ||
+ | CC cdc_device.c | ||
+ | CC msc_device.c | ||
+ | CC tusb.c | ||
+ | AS gcc_startup_nrf52840.S | ||
+ | LD feather_nrf52840_express_bootloader-0.2.13-21-g454b281-dirty-nosd.out | ||
+ | '' | ||
+ | text data bss dec hex filename | ||
+ | 30376 212 22426 53014 cf16 _build-feather_nrf52840_express/feather_nrf52840_express_bootloader-0.2.13-21-g454b281-dirty-nosd.out | ||
+ | '' | ||
+ | CR feather_nrf52840_express_bootloader-0.2.13-21-g454b281-dirty-nosd.hex | ||
+ | CR feather_nrf52840_express_bootloader-0.2.13-21-g454b281-dirty_s340_6.1.1.hex | ||
+ | |||
+ | C:\Users\egbozie\Google Drive\Arduino\libraries\Adafruit_nRF52_Bootloader>make BOARD=feather_nrf52840_express SERIAL=COM5 dfu-flash | ||
+ | LD feather_nrf52840_express_bootloader-0.2.13-21-g454b281-dirty-nosd.out | ||
+ | CR feather_nrf52840_express_bootloader-0.2.13-21-g454b281-dirty-nosd.hex | ||
+ | Zip created at _build-feather_nrf52840_express/feather_nrf52840_express_bootloader-0.2.13-21-g454b281-dirty_s340_6.1.1.zip | ||
+ | adafruit-nrfutil --verbose dfu serial --package _build-feather_nrf52840_express/feather_nrf52840_express_bootloader-0.2.13-21-g454b281-dirty_s340_6.1.1.zip -p COM5 -b 115200 --singlebank --touch 1200 | ||
+ | Upgrading target on COM5 with DFU package C:\Users\egbozie\Google Drive\Arduino\libraries\Adafruit_nRF52_Bootloader\_build-feather_nrf52840_express\feather_nrf52840_express_bootloader-0.2.13-21-g454b281-dirty_s340_6.1.1.zip. Flow control is disabled, Single bank, Touch 1200 | ||
+ | Touched serial port COM5 | ||
+ | Opened serial port COM5 | ||
+ | Starting DFU upgrade of type 3, SoftDevice size: 190272, bootloader size: 30580, application size: 0 | ||
+ | Sending DFU start packet | ||
+ | Sending DFU init packet | ||
+ | Sending firmware file | ||
+ | ######################################## | ||
+ | ######################################## | ||
+ | ######################################## | ||
+ | ######################################## | ||
+ | ######################################## | ||
+ | ######################################## | ||
+ | ######################################## | ||
+ | ######################################## | ||
+ | ######################################## | ||
+ | ######################################## | ||
+ | ################################ | ||
+ | Activating new firmware | ||
+ | |||
+ | DFU upgrade took 24.582117557525635s | ||
+ | Device programmed. | ||
+ | |||
+ | C:\Users\egbozie\Google Drive\Arduino\libraries\Adafruit_nRF52_Bootloader> | ||
+ | |||
+ | </code> |