remove bootloader binaries, update readme for using adafruit-nrufitl and flashing bootloader

This commit is contained in:
hathach 2018-08-22 15:22:17 +07:00
parent df4184e478
commit fc955b1591
11 changed files with 40 additions and 22119 deletions

View File

@ -79,6 +79,7 @@ Target Board (BOARD) | Bluetooth Stack (SD) | Bluetooth Support | Flash
pca10040 | s132 | Peripheral and Scanner | [Segger](#segger-targets) pca10040 | s132 | Peripheral and Scanner | [Segger](#segger-targets)
feather52832 | s132 | Peripheral and Scanner | [UART DFU](#dfu-targets) feather52832 | s132 | Peripheral and Scanner | [UART DFU](#dfu-targets)
pca10056 | s140 | Peripheral and Scanner | [Segger](#segger-targets) pca10056 | s140 | Peripheral and Scanner | [Segger](#segger-targets)
feather52840 | s140 | Peripheral and Scanner | [UART DFU](#dfu-targets)
## Segger Targets ## Segger Targets
@ -98,11 +99,9 @@ note: On Linux it might be required to link SEGGER's `libjlinkarm.so` inside nrf
## DFU Targets ## DFU Targets
sudo apt-get install build-essential libffi-dev pkg-config gcc-arm-none-eabi git python python-pip run follow command to install [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) from PyPi
git clone https://github.com/adafruit/Adafruit_nRF52_Arduino.git
cd Adafruit_nRF52_Arduino/tools/nrfutil-0.5.2/ $ pip3 install adafruit-nrfutil --user
sudo pip install -r requirements.txt
sudo python setup.py install
**make flash** and **make sd** will not work with DFU targets. Hence, **dfu-gen** and **dfu-flash** must be used instead. **make flash** and **make sd** will not work with DFU targets. Hence, **dfu-gen** and **dfu-flash** must be used instead.
* dfu-gen: Generates a Firmware zip to be used by the DFU flash application. * dfu-gen: Generates a Firmware zip to be used by the DFU flash application.
@ -111,8 +110,7 @@ note: On Linux it might be required to link SEGGER's `libjlinkarm.so` inside nrf
Example on how to generate and flash feather52832 target: Example on how to generate and flash feather52832 target:
make BOARD=feather52832 SD=s132 make BOARD=feather52832 SD=s132
make BOARD=feather52832 SD=s132 dfu-gen make BOARD=feather52832 SD=s132 dfu-gen dfu-flash
make BOARD=feather52832 SD=s132 dfu-flash
## Bluetooth LE REPL ## Bluetooth LE REPL

View File

@ -21,24 +21,15 @@ $ cd ports/nrf
$ ./drivers/bluetooth/download_ble_stack.sh $ ./drivers/bluetooth/download_ble_stack.sh
``` ```
## Installing `nrfutil` ## Installing `adafruit-nrfutil`
The Adafruit Bluefruit nRF52 Feather ships with a serial and OTA BLE bootloader The Adafruit Bluefruit nRF52 Feather ships with a serial and OTA BLE bootloader
that can be used to flash firmware images over a simple serial connection, that can be used to flash firmware images over a simple serial connection,
using the on-board USB serial converter. using the on-board USB serial converter.
If you haven't installed this command-line tool yet, go to the `/libs/nrfutil` run follow command to install [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) from PyPi
folder (where nrfutil 0.5.2 is installed as a sub-module) and run the following
commands:
> If you get a 'sudo: pip: command not found' error running 'sudo pip install', $ pip3 install adafruit-nrfutil --user
you can install pip via 'sudo easy_install pip'
```
$ cd ../../lib/nrfutil
$ sudo pip install -r requirements.txt
$ sudo python setup.py install
```
# Building and flashing firmware images # Building and flashing firmware images
@ -75,7 +66,7 @@ You can then connect over BLE UART using an application like Bluefruit LE
Connect, available for Android, iOS and OS X, or any other application that Connect, available for Android, iOS and OS X, or any other application that
supports the NUS service and allows you to send the corrent EOL sequence. supports the NUS service and allows you to send the corrent EOL sequence.
## Flashing binaries with `nrfutil` ## Flashing binaries with `adafruit-nrfutil`
### 1. **Update bootloader** to single-bank version ### 1. **Update bootloader** to single-bank version
@ -90,20 +81,25 @@ Due to the size of CircuitPython, we must migrate this bootloader to a
bootloader from the dual-bank version that ships on Arduino-based Adafruit bootloader from the dual-bank version that ships on Arduino-based Adafruit
Feather52 boards to a single-bank CircuitPython compatible version: Feather52 boards to a single-bank CircuitPython compatible version:
Firstly clone the [Adafruit_nRF52_Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader.git) and enter its directory
$ git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader.git
$ cd Adafruit_nRF52_Bootloader
#### S132 v2.0.1 single-bank (recommended): #### S132 v2.0.1 single-bank (recommended):
By default s132 v2.0.1 is used when no `SOFTDEV_VERSION` field is passed in: To flash bootloader with s132 v2.0.1
``` ```
$ make BOARD=feather52832 SERIAL=/dev/tty.SLAB_USBtoUART boot-flash $ make BOARD=feather_nrf52832 VERSION=2.0.1 SERIAL=/dev/tty.SLAB_USBtoUART dfu-flash
``` ```
#### S132 v5.0.0 (BLE5, experimental): #### S132 v5.0.0 (BLE5, experimental):
To enable BLE5 support and the latest S132 release, flash the v5.0.0 bootloader via: To flash bootloader with s132 v5.0.0
``` ```
$ make BOARD=feather52832 SERIAL=/dev/tty.SLAB_USBtoUART SOFTDEV_VERSION=5.0.0 boot-flash $ make BOARD=feather52832 VERSION=5.0.0 SERIAL=/dev/tty.SLAB_USBtoUART dfu-flash
``` ```
### 2. Generate and flash a CircuitPython DFU .zip package over serial ### 2. Generate and flash a CircuitPython DFU .zip package over serial

View File

@ -1,2 +0,0 @@
# Inform git that .zip files should be treated as binary
*.zip binary

View File

@ -1,9 +0,0 @@
# Adafruit nRF52 Feather Single-Bank Bootloader
These files contain an implementation of a single-bank bootloader,
which doubles the amount of flash memory available to applications
at the expense of safe over the air updates.
Two versions are present, based on release **2.0.1** and **5.0.0**
of the Nordic S132 SoftDevice. The SoftDevice is included as poart
of the bootloader binary.

View File

@ -43,7 +43,7 @@ update the core CircuitPython firmware and internal file system contents
using only a serial connection. using only a serial connection.
On empty devices, the serial bootloader will need to be flashed once using a On empty devices, the serial bootloader will need to be flashed once using a
HW debugger such as a Segger J-Link before the serial updater (`nrfutil`) can HW debugger such as a Segger J-Link before the serial updater (`adafruit-nrfutil`) can
be used. be used.
### Install `nrfjprog` ### Install `nrfjprog`
@ -79,20 +79,27 @@ JLinkARM.dll version: 6.20f
> This operation only needs to be done once, and only on boards that don't > This operation only needs to be done once, and only on boards that don't
already have the serial bootloader installed. already have the serial bootloader installed.
Firstly clone the [Adafruit_nRF52_Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader.git) and enter its directory
```
$ git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader.git
$ cd Adafruit_nRF52_Bootloader
```
Once `nrfjprog` is installed and available in `PATH` you can flash your Once `nrfjprog` is installed and available in `PATH` you can flash your
board with the serial bootloader via the following command: board with the serial bootloader via the following command:
``` ```
make SD=s140 BOARD=feather52840 bootloader make BOARD=feather_nrf52840_express VERSION=latest flash
``` ```
This should give you the following (or very similar) output, and you will see This should give you the following (or very similar) output, and you will see
a DFU blinky pattern on one of the board LEDs: a DFU blinky pattern on one of the board LEDs:
``` ```
$ make SD=s140 BOARD=feather52840 bootloader $ make BOARD=pca10056 VERSION=latest flash
Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity. Flashing: bin/pca10056/6.0.0r0/pca10056_bootloader_s140_6.0.0r0.hex
nrfjprog --program boards/feather52840/bootloader/feather52840_bootloader_6.0.0_s140_single.hex -f nrf52 --chiperase --reset nrfjprog --program bin/pca10056/6.0.0r0/pca10056_bootloader_s140_6.0.0r0.hex --chiperase -f nrf52 --reset
Parsing hex file. Parsing hex file.
Erasing user available code and UICR flash areas. Erasing user available code and UICR flash areas.
Applying system reset. Applying system reset.
@ -105,6 +112,8 @@ Run.
From this point onward, you can now use a simple serial port for firmware From this point onward, you can now use a simple serial port for firmware
updates. updates.
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.
### IMPORTANT: Disable Mass Storage on PCA10056 J-Link ### IMPORTANT: Disable Mass Storage on PCA10056 J-Link
The J-Link firmware on the PCA10056 implement USB Mass Storage, but this The J-Link firmware on the PCA10056 implement USB Mass Storage, but this
@ -135,31 +144,14 @@ J-Link>exit
## Building and Flashing CircuitPython ## Building and Flashing CircuitPython
### Installing `nrfutil` ### Installing `adafruit-nrfutil`
If you haven't installed the required command-line tool yet, go to the run follow command to install [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) from PyPi
`/libs/nrfutil` folder (where nrfutil 0.5.2b is installed as a sub-module)
and run the following commands:
> If you get a 'sudo: pip: command not found' error running 'sudo pip install',
you can install pip via 'sudo easy_install pip'
``` ```
$ cd ../../lib/nrfutil $ pip3 install adafruit-nrfutil --user
$ sudo pip install -r requirements.txt
$ sudo python setup.py install
``` ```
#### Changes to `nrfutil` in 0.5.2d
**IMPORTANT**: Make sure that you have version **0.5.2d**, since a small
change was required to `dfu_transport_serial.py` to account for the
increased minimum flash erase time on the nRF52840 compared to the earlier
nRF52832!
You can also manually change the file with the following new values (lines
67-68), and reinstall the utility via `sudo python setup.py install`:
### Flashing CircuitPython with USB CDC ### Flashing CircuitPython with USB CDC
With the serial bootloader present on your board, you first need to force your With the serial bootloader present on your board, you first need to force your
@ -169,8 +161,7 @@ BUTTON1 still pressed as you come out of reset).
This will give you a **fast blinky DFU pattern** to indicate you are in DFU This will give you a **fast blinky DFU pattern** to indicate you are in DFU
mode. mode.
At this point, you can **build and flash** a CircuitPython binary via the following you can **build and flash** a CircuitPython binary via the following command:
command:
``` ```
$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 all dfu-gen dfu-flash $ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 all dfu-gen dfu-flash
@ -197,19 +188,19 @@ Device programmed.
### Flashing CircuitPython with MSC UF2 ### Flashing CircuitPython with MSC UF2
Make `uf2` target to generate the uf2 uf2 file is generated at the end of `all` target
``` ```
$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 all uf2 $ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 all
Create firmware.uf2 Create firmware.uf2
../../tools/uf2/utils/uf2conv.py -c -o "build-feather52840-s140/firmware.uf2" "build-feather52840-s140/firmware.hex" ../../tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "build-feather52840-s140/firmware.uf2" "build-feather52840-s140/firmware.hex"
Converting to uf2, output size: 392192, start address: 0x26000 Converting to uf2, output size: 392192, start address: 0x26000
Wrote 392192 bytes to build-feather52840-s140/firmware.uf2. Wrote 392192 bytes to build-feather52840-s140/firmware.uf2.
``` ```
Simply drag and drop firmware.uf2 to the MSC, the nrf52840 will blink fast and reset after done. Simply drag and drop firmware.uf2 to the MSC, the nrf52840 will blink fast and reset after done.
**Note**: you need to update `tools/uf2` for uf2conv.py to support hex file input, current circuitpython's master use older verion of uf2conv.py which only support biin file input. To update, change directory to top folder of circuitpython and run. The size of uf2 should be ~400KB, if using the old uf2conv.py the output file would be 1 MB which is not correct. **Note**: you need to update `tools/uf2` for uf2conv.py to support hex file input, current circuitpython's master use older verion of uf2conv.py which only support bin file input. To update, change directory to top folder of circuitpython and run. The size of uf2 should be ~400KB, if using the old uf2conv.py the output file would be 1 MB which is not correct.
``` ```
git submodule update --init git submodule update --init