From cd7baed14ddcad9ed2f345d770389ab63a2751d3 Mon Sep 17 00:00:00 2001 From: Kevin Townsend Date: Thu, 15 Feb 2018 16:00:34 +0100 Subject: [PATCH] Added note nrfutil and flashing --- ports/nrf/boards/feather52840/README.md | 49 +++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/ports/nrf/boards/feather52840/README.md b/ports/nrf/boards/feather52840/README.md index 8876945e8b..5861b43c57 100644 --- a/ports/nrf/boards/feather52840/README.md +++ b/ports/nrf/boards/feather52840/README.md @@ -138,7 +138,7 @@ J-Link>exit ### Installing `nrfutil` If you haven't installed the required command-line tool yet, go to the -`/libs/nrfutil` folder (where nrfutil 0.5.2 is installed as a sub-module) +`/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', @@ -150,11 +150,52 @@ $ sudo pip install -r requirements.txt $ sudo python setup.py install ``` +#### Changes to `nrfutil` in 0.5.2b + +**IMPORTANT**: Make sure that you have version **0.5.2b**, 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`: + +``` +FLASH_PAGE_ERASE_MAX_TIME = 0.1 # Worst time to erase a page 100 ms +FLASH_PAGE_ERASE_MIN_TIME = 0.09 # Best time to erase a page 90 ms +``` + ### Flashing CircuitPython -With the serial bootloader present on your board, you can build and flash -a CircuitPython binary via the following command: +With the serial bootloader present on your board, you first need to force your +board into DFU mode by holding down BUTTON1 and RESETTING the board (with +BUTTON1 still pressed as you come out of reset). + +This will give you a **fast blinky DFU pattern** to indicate you are in DFU +mode. + +At this point, you can build and flash a CircuitPython binary via the following +command: ``` -make SD=s140 SERIAL=/dev/ttyACM0 BOARD=feather52840 dfu-gen dfu-flash +$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 dfu-gen dfu-flash +``` + +This should give you the following results: + +``` +$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 dfu-gen dfu-flash +nrfutil dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application build-feather52840-s140/firmware.hex build-feather52840-s140/dfu-package.zip +Zip created at build-feather52840-s140/dfu-package.zip +nrfutil --verbose dfu serial --package build-feather52840-s140/dfu-package.zip -p /dev/tty.usbmodem1411 -b 115200 +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. +Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, application size: 195252 +Sending DFU start packet +Sending DFU init packet +Sending firmware file +################################################################################################################################################################################################################################################################################################################################################################################################ +Activating new firmware + +DFU upgrade took 41.6610329151s +Device programmed. ```