11# Setup
22
3- ## Installing CircuitPython submodules
4-
5- Before you can build, you will need to run the following commands once, which
6- will install the submodules that are part of the CircuitPython ecosystem, and
7- build the ` mpy-cross ` tool:
3+ Before you can build, you will need to run the following commands once:
84
95```
106$ cd circuitpython
117$ git submodule update --init
128$ make -C mpy-cross
139```
1410
15- You then need to download the SD and Nordic SDK files via :
11+ You then need to download the SD and Nordic SDK files:
1612
1713> This script relies on ` wget ` , which must be available from the command line.
1814
@@ -21,50 +17,47 @@ $ cd ports/nrf
2117$ ./drivers/bluetooth/download_ble_stack.sh
2218```
2319
24- ## Installing ` nrfutil `
25-
26- The Adafruit Bluefruit nRF52 Feather ships with a serial and OTA BLE bootloader
27- that can be used to flash firmware images over a simple serial connection,
28- using the on-board USB serial converter.
29-
30- If you haven't installed this command-line tool yet, go to the ` /libs/nrfutil `
31- folder (where nrfutil 0.5.2 is installed as a sub-module) and run the following
32- commands:
33-
34- > If you get a 'sudo: pip: command not found' error running 'sudo pip install',
35- you can install pip via 'sudo easy_install pip'
36-
37- ```
38- $ cd libs/nrfutil
39- $ sudo pip install -r requirements.txt
40- $ sudo python setup.py install
41- ```
42-
4320# Building and flashing firmware images
4421
45- ## Building CircuitPython binaries
22+ ## Building CircuitPython
4623
4724#### REPL over UART (default settings)
4825
4926To build a CircuitPython binary with default settings for the
5027` feather52 ` target enter:
5128
52- > ** NOTE:** ` BOARD=feather52 ` is the default option and isn't stricly required.
53-
5429```
5530$ make BOARD=feather52 V=1
5631```
5732
58- #### REPL over BLE support
33+ #### REPL over BLE UART (AKA ` NUS ` )
5934
60- To build a CircuitPython binary with BLE support (S132) include ` SD=s132 `
61- as part of the build process:
35+ To build a CircuitPython binary with REPL over BLE UART, edit
36+ ` bluetooth_conf.h ` with the following values (under
37+ ` #elif (BLUETOOTH_SD == 132) ` ):
38+
39+ ```
40+ #define MICROPY_PY_BLE (1)
41+ #define MICROPY_PY_BLE_NUS (1)
42+ #define BLUETOOTH_WEBBLUETOOTH_REPL (1)
43+ ```
44+
45+ Then build the CircuitPython binary, including ` SD=s132 `
46+ to enable BLE support in the build process:
6247
6348```
6449$ make BOARD=feather52 V=1 SD=s132
6550```
6651
67- ## Flashing binaries with ` nrfutil `
52+ ## Flashing with ` nrfutil `
53+
54+ The Adafruit Bluefruit nRF52 Feather ships with a serial and OTA BLE bootloader
55+ that can be used to flash firmware images over a simple serial connection,
56+ using the on-board USB serial converter.
57+
58+ These commands assume that you have already installed ` nrfutil ` , as described
59+ in the [ learning guide] ( https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide/arduino-bsp-setup )
60+ for the Arduino variant of the board.
6861
6962### 1. ** Update bootloader** to single-bank version
7063
@@ -95,7 +88,7 @@ To enable BLE5 support and the latest S132 release, flash the v5.0.0 bootloader
9588$ make BOARD=feather52 SERIAL=/dev/tty.SLAB_USBtoUART SOFTDEV_VERSION=5.0.0 boot-flash
9689```
9790
98- ### 2. Generate and flash a CircuitPython DFU .zip package over serial
91+ ### 2. Generate a CircuitPython DFU .zip package and flash it over serial
9992
10093The following command will package and flash the CircuitPython binary using the
10194appropriate bootloader mentionned above.
@@ -109,49 +102,9 @@ image, as described earlier in this readme.
109102$ make BOARD=feather52 SERIAL=/dev/tty.SLAB_USBtoUART dfu-gen dfu-flash
110103```
111104
112- If you built your CircuitPython binary with ** BLE** support you will need to
113- add the ` SD=s132 ` flag as shown below:
105+ If you built your CircuitPython binary with ** BLE UART ** support you will
106+ need to add the ` SD=s132 ` flag as shown below:
114107
115108```
116109$ make BOARD=feather52 SERIAL=/dev/tty.SLAB_USBtoUART SD=s132 dfu-gen dfu-flash
117110```
118-
119- ## Working with CircuitPython
120-
121- ### Running local files with ` ampy `
122-
123- [ ampy] ( https://learn.adafruit.com/micropython-basics-load-files-and-run-code/install-ampy )
124- is a command-line tool that can be used with the nRF52 Feather to transfer
125- local python files to the nRF52 for execution, rather than having to enter
126- the REPL manually, enter paste mode, and paste the code yourself.
127-
128- > ** IMPORTANT** : You must have ` ampy ` version ** 1.0.3** or higher to use ` ampy `
129- with the nRF52. The bootloader on the nRF52 requires a delay between the
130- HW reset, and the moment when the command sequance is sent to enter raw
131- mode. This required ` -d/--delay ` flag was added in release 1.0.3.
132-
133-
134- Save the following file as ` test.py ` :
135-
136- ```
137- import board
138- import digitalio
139- import time
140-
141- led = digitalio.DigitalInOut(board.LED2)
142- led.direction = digitalio.Direction.OUTPUT
143-
144- while True:
145- led.value = True
146- time.sleep(0.5)
147- led.value = False
148- time.sleep(0.5)
149- ```
150-
151- Then run the saved file via ampy, updating the serial port as required:
152-
153- ```
154- $ ampy -p /dev/tty.SLAB_USBtoUART -d 1.5 run test.py
155- ```
156-
157- This should give you blinky at 1 Hz on LED2 (the blue LED on the nRF52 Feather).
0 commit comments