diff --git a/ports/nrf/README.md b/ports/nrf/README.md index 5fceb6705f..22bb4af514 100644 --- a/ports/nrf/README.md +++ b/ports/nrf/README.md @@ -58,12 +58,12 @@ By default, the PCA10040 (nrf52832) is used as compile target. To build and flas make submodules make - make flash + make deploy Alternatively the target board could be defined: make BOARD=pca10040 - make BOARD=pca10040 flash + make BOARD=pca10040 deploy ## Compile without LTO enabled @@ -118,26 +118,27 @@ For example: ## Target Boards and Make Flags -Target Board (BOARD) | Bluetooth Stack (SD) | Bluetooth Support | Flash Util ----------------------|-------------------------|------------------------|------------------------------- -microbit | s110 | Peripheral | [PyOCD](#pyocdopenocd-targets) -pca10000 | s110 | Peripheral | [Segger](#segger-targets) -pca10001 | s110 | Peripheral | [Segger](#segger-targets) -pca10028 | s110 | Peripheral | [Segger](#segger-targets) -pca10031 | s110 | Peripheral | [Segger](#segger-targets) -wt51822_s4at | s110 | Peripheral | Manual, see [datasheet](https://4tronix.co.uk/picobot2/WT51822-S4AT.pdf) for pinout -pca10040 | s132 | Peripheral and Central | [Segger](#segger-targets) -feather52 | s132 | Peripheral and Central | Manual, SWDIO and SWCLK solder points on the bottom side of the board -arduino_primo | s132 | Peripheral and Central | [PyOCD](#pyocdopenocd-targets) -ibk_blyst_nano | s132 | Peripheral and Central | [IDAP](#idap-midap-link-targets) -idk_blyst_nano | s132 | Peripheral and Central | [IDAP](#idap-midap-link-targets) -blueio_tag_evim | s132 | Peripheral and Central | [IDAP](#idap-midap-link-targets) -evk_nina_b1 | s132 | Peripheral and Central | [Segger](#segger-targets) -pca10056 | s140 | Peripheral and Central | [Segger](#segger-targets) -pca10059 | s140 | Peripheral and Central | Manual, SWDIO and SWCLK solder points on the sides. -particle_xenon | s140 | Peripheral and Central | [Black Magic Probe](#black-magic-probe-targets) -pca10090 | None (bsdlib.a) | None (LTE/GNSS) | [Segger](#segger-targets) -actinius_icarus | None (bsdlib.a) | None (LTE/GNSS) | [Segger](#segger-targets) +Target Board (BOARD) | Bluetooth Stack (SD) | Bluetooth Support | Bootloader | Default Flash Util +---------------------|-------------------------|------------------------|----------------|------------------- +microbit | s110 | Peripheral | | [PyOCD](#pyocdopenocd-targets) +pca10000 | s110 | Peripheral | | [Segger](#segger-targets) +pca10001 | s110 | Peripheral | | [Segger](#segger-targets) +pca10028 | s110 | Peripheral | | [Segger](#segger-targets) +pca10031 | s110 | Peripheral | | [Segger](#segger-targets) +wt51822_s4at | s110 | Peripheral | | Manual, see [datasheet](https://4tronix.co.uk/picobot2/WT51822-S4AT.pdf) for pinout +pca10040 | s132 | Peripheral and Central | | [Segger](#segger-targets) +feather52 | s132 | Peripheral and Central | | Manual, SWDIO and SWCLK solder points on the bottom side of the board +arduino_primo | s132 | Peripheral and Central | | [PyOCD](#pyocdopenocd-targets) +ibk_blyst_nano | s132 | Peripheral and Central | | [IDAP](#idap-midap-link-targets) +idk_blyst_nano | s132 | Peripheral and Central | | [IDAP](#idap-midap-link-targets) +blueio_tag_evim | s132 | Peripheral and Central | | [IDAP](#idap-midap-link-targets) +evk_nina_b1 | s132 | Peripheral and Central | | [Segger](#segger-targets) +pca10056 | s140 | Peripheral and Central | | [Segger](#segger-targets) +pca10059 | s140 | Peripheral and Central | OpenBootloader | [nrfutil](#nrfutil-targets) +particle_xenon | s140 | Peripheral and Central | | [Black Magic Probe](#black-magic-probe-targets) +nrf52840-mdk-usb-dongle | s140 | Peripheral and Central | OpenBootloader | [nrfutil](#nrfutil-targets) +pca10090 | None (bsdlib.a) | None (LTE/GNSS) | | [Segger](#segger-targets) +actinius_icarus | None (bsdlib.a) | None (LTE/GNSS) | | [Segger](#segger-targets) ## IDAP-M/IDAP-Link Targets @@ -173,6 +174,31 @@ This requires no further dependencies other than `arm-none-eabi-gdb`. [this guide](https://github.com/blacksphere/blackmagic/wiki/Useful-GDB-commands) for more tips about using the BMP with GDB. +## nRFUtil Targets + +Install the necessary Python packages that will be used for flashing using the bootloader: + + sudo pip install nrfutil + sudo pip install intelhex + +The `intelhex` provides the `hexmerge.py` utility which is used by the Makefile +to trim of the MBR in case SoftDevice flashing is requested. + +`nrfutil` as flashing backend also requires a serial port paramter to be defined +in addition to the `deploy` target of make. For example: + + make BOARD=nrf52840-mdk-usb-dongle NRFUTIL_PORT=/dev/ttyACM0 deploy + +If the target device is connected to `/dev/ttyACM0` serial port, the +`NRFUTIL_PORT` parameter to make can be elided as it is the default serial +port set by the Makefile. + +When enabling Bluetooth LE, as with the other flash utils, the SoftDevice +needs to be flashed in the first firmware update. This can be done by issuing +the `sd` target instead of `deploy`. For example: + + make BOARD=nrf52840-mdk-usb-dongle SD=s140 NRFUTIL_PORT=/dev/ttyACM0 sd + ## Bluetooth LE REPL The port also implements a BLE REPL driver. This feature is disabled by default, as it will deactivate the UART REPL when activated. As some of the nRF devices only have one UART, using the BLE REPL free's the UART instance such that it can be used as a general UART peripheral not bound to REPL. diff --git a/ports/nrf/boards/nrf52840-mdk-usb-dongle/README.md b/ports/nrf/boards/nrf52840-mdk-usb-dongle/README.md index c39a800d77..f993c7dc53 100644 --- a/ports/nrf/boards/nrf52840-mdk-usb-dongle/README.md +++ b/ports/nrf/boards/nrf52840-mdk-usb-dongle/README.md @@ -39,11 +39,10 @@ Follow the standard [nRF Port build instructions](../../README.md); but use make BOARD=nrf52840-mdk-usb-dongle The build artifacts will be created in `build-nrf52840-mdk-usb-dongle`. Once -built, the easiest way to deploy to the device is to open `firmware.hex` using +built, the target can be deployed to the device as described in +[nRFUtil targets](../../README.md#nrfutil-targets). + +An alternative way to deploy to the device, is to open `firmware.hex` using *nRF Connect* and select *Write*. Detailed instructions can be found on the [developer wiki](https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/programming/). - -**Note** that the regular method of deployment for the MicroPython nRF port -(using `make deploy`) will *not* operate correctly and will overwrite the -bootloader. diff --git a/ports/nrf/boards/nrf52840-mdk-usb-dongle/mpconfigboard.mk b/ports/nrf/boards/nrf52840-mdk-usb-dongle/mpconfigboard.mk index f98d5c88a9..ca437418d5 100644 --- a/ports/nrf/boards/nrf52840-mdk-usb-dongle/mpconfigboard.mk +++ b/ports/nrf/boards/nrf52840-mdk-usb-dongle/mpconfigboard.mk @@ -2,6 +2,18 @@ MCU_SERIES = m4 MCU_VARIANT = nrf52 MCU_SUB_VARIANT = nrf52840 SOFTDEV_VERSION = 6.1.1 -LD_FILES += boards/nrf52840-mdk-usb-dongle/nrf52840_open_bootloader.ld boards/nrf52840_1M_256k.ld + +DFU ?= 1 + +ifeq ($(DFU),1) +BOOTLOADER=open_bootloader +BOOTLOADER_VERSION_MAJOR=1 +BOOTLOADER_VERSION_MINOR=2 +FLASHER=nrfutil +else +FLASHER=segger +endif + +LD_FILES += boards/nrf52840_1M_256k.ld NRF_DEFINES += -DNRF52840_XXAA diff --git a/ports/nrf/boards/nrf52840-mdk-usb-dongle/nrf52840_open_bootloader.ld b/ports/nrf/boards/nrf52840-mdk-usb-dongle/nrf52840_open_bootloader.ld deleted file mode 100644 index d6c6e743a4..0000000000 --- a/ports/nrf/boards/nrf52840-mdk-usb-dongle/nrf52840_open_bootloader.ld +++ /dev/null @@ -1,2 +0,0 @@ -_ram_start = 0x20000008; -_flash_start = 0x1000; diff --git a/ports/nrf/boards/pca10059/mpconfigboard.mk b/ports/nrf/boards/pca10059/mpconfigboard.mk index ca555d3932..ca437418d5 100644 --- a/ports/nrf/boards/pca10059/mpconfigboard.mk +++ b/ports/nrf/boards/pca10059/mpconfigboard.mk @@ -2,6 +2,18 @@ MCU_SERIES = m4 MCU_VARIANT = nrf52 MCU_SUB_VARIANT = nrf52840 SOFTDEV_VERSION = 6.1.1 + +DFU ?= 1 + +ifeq ($(DFU),1) +BOOTLOADER=open_bootloader +BOOTLOADER_VERSION_MAJOR=1 +BOOTLOADER_VERSION_MINOR=2 +FLASHER=nrfutil +else +FLASHER=segger +endif + LD_FILES += boards/nrf52840_1M_256k.ld NRF_DEFINES += -DNRF52840_XXAA