|
| 1 | +# Setup |
| 2 | + |
| 3 | +The `feather52840` board is currently based on the `PCA10056` development |
| 4 | +board from Nordic Semiconductors, since commercial modules are not yet |
| 5 | +available for the nRF52840. |
| 6 | + |
| 7 | +The difference between the `pca10056` and `feather52840` board support |
| 8 | +packages is that no bootloader is present on the `pca10056` (a HW debugger |
| 9 | +like a Segger J-Link is required to flash firmware images), whereas the |
| 10 | +`feather52840` package uses a serial bootloader, with a slightly different |
| 11 | +flash layout to account for the bootloader's presence. |
| 12 | + |
| 13 | +Both targets run on the same hardware and assume the same pinouts. |
| 14 | + |
| 15 | +The `feather52840` board support package will be updated at a later date |
| 16 | +to reflect any pin changes in the final Feather form-factor HW. |
| 17 | + |
| 18 | +## Installing CircuitPython submodules |
| 19 | + |
| 20 | +Before you can build, you will need to run the following commands once, which |
| 21 | +will install the submodules that are part of the CircuitPython ecosystem, and |
| 22 | +build the `mpy-cross` tool: |
| 23 | + |
| 24 | +``` |
| 25 | +$ cd circuitpython |
| 26 | +$ git submodule update --init |
| 27 | +$ make -C mpy-cross |
| 28 | +``` |
| 29 | + |
| 30 | +You then need to download the SD and Nordic SDK files via: |
| 31 | + |
| 32 | +> This script relies on `wget`, which must be available from the command line. |
| 33 | +
|
| 34 | +``` |
| 35 | +$ cd ports/nrf |
| 36 | +$ ./bluetooth/download_ble_stack.sh |
| 37 | +``` |
| 38 | + |
| 39 | +## Installing the Serial Bootloader |
| 40 | + |
| 41 | +The Adafruit nRF52840 Feather uses a serial bootloader that allows you to |
| 42 | +update the core CircuitPython firmware and internal file system contents |
| 43 | +using only a serial connection. |
| 44 | + |
| 45 | +On empty devices, the serial bootloader will need to be flashed once using a |
| 46 | +HW debugger such as a Segger J-Link before the serial updater (`adafruit-nrfutil`) can |
| 47 | +be used. |
| 48 | + |
| 49 | +### Install `nrfjprog` |
| 50 | + |
| 51 | +Before you can install the bootloader, you will first need to install the |
| 52 | +`nrfjprog` tool from Nordic Semiconductors for your operating system. The |
| 53 | +binary files can be downloaded via the following links: |
| 54 | + |
| 55 | +- [nRF5x toolset tar for Linux 32-bit v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-Linux32/52619) |
| 56 | +- [nRF5x toolset tar for Linux 64-bit v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-Linux64/51388) |
| 57 | +- [nRF5x toolset tar for OSX v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-OSX/53406) |
| 58 | +- [nRF5x toolset installer for Windows v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-Win32/48768) |
| 59 | + |
| 60 | +You will then need to add the `nrfjprog` folder to your system `PATH` variable |
| 61 | +so that it is available from the command line. The exact process for this is |
| 62 | +OS specific, but on a POSIX type system like OS X or Linux, you can |
| 63 | +temporarily add the location to your `PATH` environment variables as follows: |
| 64 | + |
| 65 | +``` |
| 66 | +$ export PATH=$PATH:YOURPATHHERE/nRF5x-Command-Line-Tools_9_7_2_OSX/nrfjprog/ |
| 67 | +``` |
| 68 | + |
| 69 | +You can test this by running the following command: |
| 70 | + |
| 71 | +``` |
| 72 | +$ nrfjprog --version |
| 73 | +nrfjprog version: 9.7.2 |
| 74 | +JLinkARM.dll version: 6.20f |
| 75 | +``` |
| 76 | + |
| 77 | +### Flash the USB CDC Bootloader with 'nrfjprog' |
| 78 | + |
| 79 | +> This operation only needs to be done once, and only on boards that don't |
| 80 | + already have the serial bootloader installed. |
| 81 | + |
| 82 | +Firstly clone the [Adafruit_nRF52_Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader.git) and enter its directory |
| 83 | + |
| 84 | +``` |
| 85 | +$ git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader.git |
| 86 | +$ cd Adafruit_nRF52_Bootloader |
| 87 | +``` |
| 88 | + |
| 89 | +Once `nrfjprog` is installed and available in `PATH` you can flash your |
| 90 | +board with the serial bootloader via the following command: |
| 91 | + |
| 92 | +``` |
| 93 | +make BOARD=feather_nrf52840_express VERSION=latest flash |
| 94 | +``` |
| 95 | + |
| 96 | +This should give you the following (or very similar) output, and you will see |
| 97 | +a DFU blinky pattern on one of the board LEDs: |
| 98 | + |
| 99 | +``` |
| 100 | +$ make BOARD=pca10056 VERSION=latest flash |
| 101 | +Flashing: bin/pca10056/6.0.0r0/pca10056_bootloader_s140_6.0.0r0.hex |
| 102 | +nrfjprog --program bin/pca10056/6.0.0r0/pca10056_bootloader_s140_6.0.0r0.hex --chiperase -f nrf52 --reset |
| 103 | +Parsing hex file. |
| 104 | +Erasing user available code and UICR flash areas. |
| 105 | +Applying system reset. |
| 106 | +Checking that the area to write is not protected. |
| 107 | +Programing device. |
| 108 | +Applying system reset. |
| 109 | +Run. |
| 110 | +``` |
| 111 | + |
| 112 | +From this point onward, you can now use a simple serial port for firmware |
| 113 | +updates. |
| 114 | + |
| 115 | +Note: You can specify other version that are available in the directory `Adafruit_nRF52_Bootloader/bin/feather_nrf52840_express/` . The `VERSION=latest` will use the latest bootloader available. |
| 116 | + |
| 117 | +### IMPORTANT: Disable Mass Storage on PCA10056 J-Link |
| 118 | + |
| 119 | +The J-Link firmware on the PCA10056 implement USB Mass Storage, but this |
| 120 | +causes a known conflict with reliable USB CDC serial port communication. In |
| 121 | +order to use the serial bootloader, **you must disable MSD support on the |
| 122 | +Segger J-Link**! |
| 123 | + |
| 124 | +To disable mass storage support, run the `JLinkExe` (or equivalent) command, |
| 125 | +and send `MSDDisable`. (You can re-enable MSD support via `MSDEnable`): |
| 126 | + |
| 127 | +``` |
| 128 | +$ JLinkExe |
| 129 | +SEGGER J-Link Commander V6.20f (Compiled Oct 13 2017 17:20:01) |
| 130 | +DLL version V6.20f, compiled Oct 13 2017 17:19:52 |
| 131 | +
|
| 132 | +Connecting to J-Link via USB...O.K. |
| 133 | +Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 24 2017 17:30:12 |
| 134 | +Hardware version: V1.00 |
| 135 | +S/N: 683947110 |
| 136 | +VTref = 3.300V |
| 137 | +
|
| 138 | +
|
| 139 | +Type "connect" to establish a target connection, '?' for help |
| 140 | +J-Link>MSDDisable |
| 141 | +Probe configured successfully. |
| 142 | +J-Link>exit |
| 143 | +``` |
| 144 | + |
| 145 | +## Building and Flashing CircuitPython |
| 146 | + |
| 147 | +### Installing `adafruit-nrfutil` |
| 148 | + |
| 149 | +run follow command to install [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) from PyPi |
| 150 | + |
| 151 | +``` |
| 152 | +$ pip3 install adafruit-nrfutil --user |
| 153 | +``` |
| 154 | + |
| 155 | +### Flashing CircuitPython with USB CDC |
| 156 | + |
| 157 | +With the serial bootloader present on your board, you first need to force your |
| 158 | +board into DFU mode by holding down BUTTON1 and RESETTING the board (with |
| 159 | +BUTTON1 still pressed as you come out of reset). |
| 160 | + |
| 161 | +This will give you a **fast blinky DFU pattern** to indicate you are in DFU |
| 162 | +mode. |
| 163 | + |
| 164 | +You can **build and flash** a CircuitPython binary via the following command: |
| 165 | + |
| 166 | +``` |
| 167 | +$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 all dfu-gen dfu-flash |
| 168 | +``` |
| 169 | + |
| 170 | +This should give you the following results: |
| 171 | + |
| 172 | +``` |
| 173 | +$make V=1 BOARD=feather52840 SD=s140 SERIAL=/dev/tty.usbmodem1411 dfu-gen dfu-flash |
| 174 | +nrfutil dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application build-feather52840-s140/firmware.hex build-feather52840-s140/dfu-package.zip |
| 175 | +Zip created at build-feather52840-s140/dfu-package.zip |
| 176 | +nrfutil --verbose dfu serial --package build-feather52840-s140/dfu-package.zip -p /dev/ttyACM1 -b 115200 --singlebank |
| 177 | +Upgrading target on /dev/ttyACM1 with DFU package /home/hathach/Dropbox/adafruit/circuitpython/ada_cp/ports/nrf/build-feather52840-s140/dfu-package.zip. Flow control is disabled, Single bank mode |
| 178 | +Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, application size: 199840 |
| 179 | +Sending DFU start packet |
| 180 | +Sending DFU init packet |
| 181 | +Sending firmware file |
| 182 | +######################################################################################################################################################################################################################################################################################################################################################################################################### |
| 183 | +Activating new firmware |
| 184 | +
|
| 185 | +DFU upgrade took 8.50606513023s |
| 186 | +Device programmed. |
| 187 | +``` |
| 188 | + |
| 189 | +### Flashing CircuitPython with MSC UF2 |
| 190 | + |
| 191 | +uf2 file is generated last by `all` target |
| 192 | + |
| 193 | +``` |
| 194 | +$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 all |
| 195 | +Create firmware.uf2 |
| 196 | +../../tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "build-feather52840-s140/firmware.uf2" "build-feather52840-s140/firmware.hex" |
| 197 | +Converting to uf2, output size: 392192, start address: 0x26000 |
| 198 | +Wrote 392192 bytes to build-feather52840-s140/firmware.uf2. |
| 199 | +``` |
| 200 | + |
| 201 | +Simply drag and drop firmware.uf2 to the MSC, the nrf52840 will blink fast and reset after done. |
0 commit comments