|
| 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 | +$ ./drivers/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 (`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 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 | +Once `nrfjprog` is installed and available in `PATH` you can flash your |
| 83 | +board with the serial bootloader via the following command: |
| 84 | + |
| 85 | +``` |
| 86 | +make SD=s140 BOARD=feather52840 boot-flash |
| 87 | +``` |
| 88 | + |
| 89 | +This should give you the following (or very similar) output, and you will see |
| 90 | +a DFU blinky pattern on one of the board LEDs: |
| 91 | + |
| 92 | +``` |
| 93 | +$ make SD=s140 BOARD=feather52840 boot-flash |
| 94 | +Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity. |
| 95 | +nrfjprog --program boards/feather52840/bootloader/feather52840_bootloader_6.0.0_s140_single.hex -f nrf52 --chiperase --reset |
| 96 | +Parsing hex file. |
| 97 | +Erasing user available code and UICR flash areas. |
| 98 | +Applying system reset. |
| 99 | +Checking that the area to write is not protected. |
| 100 | +Programing device. |
| 101 | +Applying system reset. |
| 102 | +Run. |
| 103 | +``` |
| 104 | + |
| 105 | +From this point onward, you can now use a simple serial port for firmware |
| 106 | +updates. |
| 107 | + |
| 108 | +### IMPORTANT: Disable Mass Storage on PCA10056 J-Link |
| 109 | + |
| 110 | +The J-Link firmware on the PCA10056 implement USB Mass Storage, but this |
| 111 | +causes a known conflict with reliable USB CDC serial port communication. In |
| 112 | +order to use the serial bootloader, **you must disable MSD support on the |
| 113 | +Segger J-Link**! |
| 114 | + |
| 115 | +To disable mass storage support, run the `JLinkExe` (or equivalent) command, |
| 116 | +and send `MSDDisable`. (You can re-enable MSD support via `MSDEnable`): |
| 117 | + |
| 118 | +``` |
| 119 | +$ JLinkExe |
| 120 | +SEGGER J-Link Commander V6.20f (Compiled Oct 13 2017 17:20:01) |
| 121 | +DLL version V6.20f, compiled Oct 13 2017 17:19:52 |
| 122 | +
|
| 123 | +Connecting to J-Link via USB...O.K. |
| 124 | +Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 24 2017 17:30:12 |
| 125 | +Hardware version: V1.00 |
| 126 | +S/N: 683947110 |
| 127 | +VTref = 3.300V |
| 128 | +
|
| 129 | +
|
| 130 | +Type "connect" to establish a target connection, '?' for help |
| 131 | +J-Link>MSDDisable |
| 132 | +Probe configured successfully. |
| 133 | +J-Link>exit |
| 134 | +``` |
| 135 | + |
| 136 | +## Building and Flashing CircuitPython |
| 137 | + |
| 138 | +### Installing `nrfutil` |
| 139 | + |
| 140 | +If you haven't installed the required command-line tool yet, go to the |
| 141 | +`/libs/nrfutil` folder (where nrfutil 0.5.2b is installed as a sub-module) |
| 142 | +and run the following commands: |
| 143 | + |
| 144 | +> If you get a 'sudo: pip: command not found' error running 'sudo pip install', |
| 145 | +you can install pip via 'sudo easy_install pip' |
| 146 | + |
| 147 | +``` |
| 148 | +$ cd ../../lib/nrfutil |
| 149 | +$ sudo pip install -r requirements.txt |
| 150 | +$ sudo python setup.py install |
| 151 | +``` |
| 152 | + |
| 153 | +#### Changes to `nrfutil` in 0.5.2b |
| 154 | + |
| 155 | +**IMPORTANT**: Make sure that you have version **0.5.2b**, since a small |
| 156 | +change was required to `dfu_transport_serial.py` to account for the |
| 157 | +increased minimum flash erase time on the nRF52840 compared to the earlier |
| 158 | +nRF52832! |
| 159 | + |
| 160 | +You can also manually change the file with the following new values (lines |
| 161 | +67-68), and reinstall the utility via `sudo python setup.py install`: |
| 162 | + |
| 163 | +``` |
| 164 | +FLASH_PAGE_ERASE_MAX_TIME = 0.1 # Worst time to erase a page 100 ms |
| 165 | +FLASH_PAGE_ERASE_MIN_TIME = 0.09 # Best time to erase a page 90 ms |
| 166 | +``` |
| 167 | + |
| 168 | +### Flashing CircuitPython |
| 169 | + |
| 170 | +With the serial bootloader present on your board, you first need to force your |
| 171 | +board into DFU mode by holding down BUTTON1 and RESETTING the board (with |
| 172 | +BUTTON1 still pressed as you come out of reset). |
| 173 | + |
| 174 | +This will give you a **fast blinky DFU pattern** to indicate you are in DFU |
| 175 | +mode. |
| 176 | + |
| 177 | +At this point, you can build and flash a CircuitPython binary via the following |
| 178 | +command: |
| 179 | + |
| 180 | +``` |
| 181 | +$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 dfu-gen dfu-flash |
| 182 | +``` |
| 183 | + |
| 184 | +This should give you the following results: |
| 185 | + |
| 186 | +``` |
| 187 | +$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 dfu-gen dfu-flash |
| 188 | +nrfutil dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application build-feather52840-s140/firmware.hex build-feather52840-s140/dfu-package.zip |
| 189 | +Zip created at build-feather52840-s140/dfu-package.zip |
| 190 | +nrfutil --verbose dfu serial --package build-feather52840-s140/dfu-package.zip -p /dev/tty.usbmodem1411 -b 115200 |
| 191 | +Upgrading target on /dev/tty.usbmodem1411 with DFU package /Users/kevintownsend/Dropbox/microBuilder/Code/CircuitPython/circuitpython-mb/ports/nrf/build-feather52840-s140/dfu-package.zip. Flow control is disabled. |
| 192 | +Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, application size: 195252 |
| 193 | +Sending DFU start packet |
| 194 | +Sending DFU init packet |
| 195 | +Sending firmware file |
| 196 | +################################################################################################################################################################################################################################################################################################################################################################################################ |
| 197 | +Activating new firmware |
| 198 | +
|
| 199 | +DFU upgrade took 41.6610329151s |
| 200 | +Device programmed. |
| 201 | +``` |
0 commit comments