From 3eb17f56fa3350cd41d60280eeda2d32141a1a89 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 20 Jun 2018 10:42:38 +0200 Subject: [PATCH 1/6] boards/nrf52xxxdk: add openocd as programmer For the moment openocd doesn't work when softdevice blob module is loaded --- boards/common/nrf52/Makefile.include | 24 ++++++++++++++++-------- boards/common/nrf52/dist/openocd.cfg | 3 +++ 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 boards/common/nrf52/dist/openocd.cfg diff --git a/boards/common/nrf52/Makefile.include b/boards/common/nrf52/Makefile.include index 269a84f145..f8e47e1b57 100644 --- a/boards/common/nrf52/Makefile.include +++ b/boards/common/nrf52/Makefile.include @@ -9,24 +9,32 @@ PORT_LINUX ?= /dev/ttyACM0 PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) include $(RIOTMAKE)/tools/serial.inc.mk -# define jlink as default programmer, but overridable -PROGRAMMER ?= jlink +# The following configuration is dependencies specific +# but they are resolved later +# Hack to know now if 'nordic_softdevice_ble' is used +include $(RIOTBOARD)/$(BOARD)/Makefile.dep +PROGRAMMER ?= jlink ifeq (jlink,$(PROGRAMMER)) # setup JLink for flashing export JLINK_DEVICE := nrf52 - # The following configuration is dependencies specific - # but they are resolved later - # Hack to know now if 'nordic_softdevice_ble' is used - include $(RIOTBOARD)/$(BOARD)/Makefile.dep - # special options when using SoftDevice ifneq (,$(filter nordic_softdevice_ble,$(USEPKG))) export JLINK_PRE_FLASH := erase\nloadfile $(BINDIR)/softdevice.hex export FLASH_ADDR := 0x1f000 export LINKER_SCRIPT ?= $(RIOTCPU)/$(CPU)/ldscripts/$(CPU_MODEL)_sd.ld endif - include $(RIOTMAKE)/tools/jlink.inc.mk +else ifeq (openocd,$(PROGRAMMER)) + # setup OpenOCD for flashing. Version 0.10 of OpenOCD doesn't contain support + # for nrf52dk and nrf52840dk boards. To use OpenOCD with these a version + # build from source (master > 2018, August the 13rd) is required. + ifneq (,$(filter nordic_softdevice_ble,$(USEPKG))) + # openocd doesn't work (yet) with softdevice + $(error Cannot use OpenOCD with nordic_softdevice module) + endif + export DEBUG_ADAPTER ?= jlink + export OPENOCD_CONFIG := $(RIOTBOARD)/common/nrf52/dist/openocd.cfg + include $(RIOTMAKE)/tools/openocd.inc.mk endif diff --git a/boards/common/nrf52/dist/openocd.cfg b/boards/common/nrf52/dist/openocd.cfg new file mode 100644 index 0000000000..75659d4ab3 --- /dev/null +++ b/boards/common/nrf52/dist/openocd.cfg @@ -0,0 +1,3 @@ +transport select swd + +source [find target/nrf52.cfg] From 171e8589ff8e884e5f57dedc3d16ee3008423445 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 28 Jan 2019 18:05:18 +0100 Subject: [PATCH 2/6] boards/nrf52840-mdk: use common openocd configuration --- boards/nrf52840-mdk/Makefile.include | 3 --- boards/nrf52840-mdk/dist/openocd.cfg | 2 -- 2 files changed, 5 deletions(-) delete mode 100644 boards/nrf52840-mdk/dist/openocd.cfg diff --git a/boards/nrf52840-mdk/Makefile.include b/boards/nrf52840-mdk/Makefile.include index 8c03241645..34c3a015c3 100644 --- a/boards/nrf52840-mdk/Makefile.include +++ b/boards/nrf52840-mdk/Makefile.include @@ -10,9 +10,6 @@ ifeq (pyocd,$(PROGRAMMER)) # option is passed explicitly export FLASH_TARGET_TYPE ?= -t $(CPU) include $(RIOTMAKE)/tools/pyocd.inc.mk -else ifeq (openocd,$(PROGRAMMER)) - export DEBUG_ADAPTER ?= dap - include $(RIOTMAKE)/tools/openocd.inc.mk endif include $(RIOTBOARD)/common/nrf52/Makefile.include diff --git a/boards/nrf52840-mdk/dist/openocd.cfg b/boards/nrf52840-mdk/dist/openocd.cfg deleted file mode 100644 index 60f0681d52..0000000000 --- a/boards/nrf52840-mdk/dist/openocd.cfg +++ /dev/null @@ -1,2 +0,0 @@ -transport select swd -source [find target/nrf52.cfg] From 9373225a13fafc36052477121ab9877c7cc75da8 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 28 Jan 2019 18:10:29 +0100 Subject: [PATCH 3/6] boards/nrf52xx: add flashing and stdio sections in doc --- boards/nrf52840dk/doc.txt | 29 +++++++++++++++++++++++++++++ boards/nrf52dk/doc.txt | 30 ++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/boards/nrf52840dk/doc.txt b/boards/nrf52840dk/doc.txt index 3129f87482..29e51439bb 100644 --- a/boards/nrf52840dk/doc.txt +++ b/boards/nrf52840dk/doc.txt @@ -13,4 +13,33 @@ this, RIOT provides a little tool in `dist/tools/nrf52_resetpin_cfg`. Simply compile, flash, and run that tool on your board, and the reset pin should work for the time being. +## Flash the board + +By default, the board is flashed with via the on-board Segger JLink adapter. + +To flash the board, use `BOARD=nrf52840dk` with the `make` command.
+Example with `hello-world` application: +``` + make BOARD=nrf52840dk -C examples/hello-world flash +``` + +OpenOCD can also be used. For the moment, the latest stable version of OpenOCD +(0.10) doesn't contain any support for nrf52 but versions built against the +actual development version can be used. + +To flash the board with OpenOCD, use the `PROGRAMMER` variable: +``` + PROGRAMMER=openocd make BOARD=nrf52840dk -C examples/hello-world flash +``` + +## Accessing STDIO via UART + +The STDIO is directly accessible via the USB port. On a Linux host, it's +generally mapped to `/dev/ttyACM0`. + +Use the `term` target to connect to the board serial port
+``` + make BOARD=nrf52840dk -C examples/hello-world term +``` + */ diff --git a/boards/nrf52dk/doc.txt b/boards/nrf52dk/doc.txt index b32c08d7e5..4e42d21094 100644 --- a/boards/nrf52dk/doc.txt +++ b/boards/nrf52dk/doc.txt @@ -104,4 +104,34 @@ work for the time being. There are two pins for current measurement on board. Don't connect these pins to GND!. The left pin is at 3.3V level and the right pin is connected to V33. Divide the measured voltage between this pins by 22 to get the current. + + +## Flash the board + +By default, the board is flashed with via the on-board Segger JLink adapter. + +To flash the board, use `BOARD=nrf52dk` with the `make` command.
+Example with `hello-world` application: +``` + make BOARD=nrf52dk -C examples/hello-world flash +``` + +OpenOCD can also be used. For the moment, the latest stable version of OpenOCD +(0.10) doesn't contain any support for nrf52 but versions built against the +actual development version can be used. + +To flash the board with OpenOCD, use the `PROGRAMMER` variable: +``` + PROGRAMMER=openocd make BOARD=nrf52dk -C examples/hello-world flash +``` + +## Accessing STDIO via UART + +The STDIO is directly accessible via the USB port. On a Linux host, it's +generally mapped to `/dev/ttyACM0`. + +Use the `term` target to connect to the board serial port
+``` + make BOARD=nrf52dk -C examples/hello-world term +``` */ From 826df5648b42c6cfd3cb51f7e8c20330add9836d Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 4 Feb 2019 10:32:03 +0100 Subject: [PATCH 4/6] boards/nrf52: update nrf52 common documentation Add common flashing notes + move the doc in a separate doc.txt file --- boards/common/nrf52/doc.txt | 26 ++++++++++++++++++++++ boards/common/nrf52/include/board_common.h | 3 +-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 boards/common/nrf52/doc.txt diff --git a/boards/common/nrf52/doc.txt b/boards/common/nrf52/doc.txt new file mode 100644 index 0000000000..3c6f34e606 --- /dev/null +++ b/boards/common/nrf52/doc.txt @@ -0,0 +1,26 @@ +/** +@defgroup boards_common_nrf52 nRF52 common +@ingroup boards_common +@brief Common files and configuration for nRF52 boards. + +## Flashing nrf52 boards + +By default, nrf52 boards are flashed using Jlink. @ref boards_nrf52840-mdk +uses PyOCD by default. + +To flash the board, use `BOARD=` with the `make` command.
+Example with `hello-world` application: +``` + make BOARD= -C examples/hello-world flash +``` + +OpenOCD can also be used to flash nrf52 boards. For the moment, the latest +stable version of OpenOCD (0.10) doesn't contain any support for nrf52 but +versions built against the current development version can be used. + +To flash the board with OpenOCD, use the `PROGRAMMER` variable: +``` + PROGRAMMER=openocd make BOARD= -C examples/hello-world flash +``` + +*/ diff --git a/boards/common/nrf52/include/board_common.h b/boards/common/nrf52/include/board_common.h index c3be793e25..333b1af986 100644 --- a/boards/common/nrf52/include/board_common.h +++ b/boards/common/nrf52/include/board_common.h @@ -7,8 +7,7 @@ */ /** - * @defgroup boards_common_nrf52 NRF52 common - * @ingroup boards_common + * @ingroup boards_common_nrf52 * @brief Shared files and configuration for all nRF52 boards. * @{ * From a2cfa526022a585347a0ecca965a7403c1892f10 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 4 Feb 2019 10:38:19 +0100 Subject: [PATCH 5/6] boards/nrf52xx: use common flashing documentation --- boards/acd52832/doc.txt | 5 +++++ boards/nrf52840-mdk/doc.txt | 14 +------------- boards/nrf52840dk/doc.txt | 17 +---------------- boards/nrf52dk/doc.txt | 18 +----------------- boards/ruuvitag/doc.txt | 5 +++++ boards/thingy52/doc.txt | 5 +++++ 6 files changed, 18 insertions(+), 46 deletions(-) diff --git a/boards/acd52832/doc.txt b/boards/acd52832/doc.txt index 8ed60bf838..ee389426c1 100644 --- a/boards/acd52832/doc.txt +++ b/boards/acd52832/doc.txt @@ -2,4 +2,9 @@ @defgroup boards_acd52832 ACD52832 @ingroup boards @brief Support for the aconnoâ„¢ ACD52832 + +## Flash the board + +See the `Flashing` section in @ref boards_common_nrf52. + */ diff --git a/boards/nrf52840-mdk/doc.txt b/boards/nrf52840-mdk/doc.txt index b02b5c96f8..9e9024ebad 100644 --- a/boards/nrf52840-mdk/doc.txt +++ b/boards/nrf52840-mdk/doc.txt @@ -23,20 +23,8 @@ PyOCD can be installed using Python package manager: pip install pyocd --user -U ``` -To flash the board `BOARD=nrf52840-mdk` with the `make` command.
-Example with `hello-world` application: -``` - make BOARD=nrf52840-mdk -C examples/hello-world flash -``` +See the `Flashing` section in @ref boards_common_nrf52. -OpenOCD can also be used. For the moment, the latest stable version of OpenOCD -(0.10) doesn't contain any support for nrf52 but versions built against the -actual development version can be used. - -To flash the board with OpenOCD, use the `PROGRAMMER` variable: -``` - PROGRAMMER=openocd make BOARD=nrf52840-mdk -C examples/hello-world flash -``` ### Accessing STDIO via UART diff --git a/boards/nrf52840dk/doc.txt b/boards/nrf52840dk/doc.txt index 29e51439bb..73048077d2 100644 --- a/boards/nrf52840dk/doc.txt +++ b/boards/nrf52840dk/doc.txt @@ -15,22 +15,7 @@ work for the time being. ## Flash the board -By default, the board is flashed with via the on-board Segger JLink adapter. - -To flash the board, use `BOARD=nrf52840dk` with the `make` command.
-Example with `hello-world` application: -``` - make BOARD=nrf52840dk -C examples/hello-world flash -``` - -OpenOCD can also be used. For the moment, the latest stable version of OpenOCD -(0.10) doesn't contain any support for nrf52 but versions built against the -actual development version can be used. - -To flash the board with OpenOCD, use the `PROGRAMMER` variable: -``` - PROGRAMMER=openocd make BOARD=nrf52840dk -C examples/hello-world flash -``` +See the `Flashing` section in @ref boards_common_nrf52. ## Accessing STDIO via UART diff --git a/boards/nrf52dk/doc.txt b/boards/nrf52dk/doc.txt index 4e42d21094..da28180459 100644 --- a/boards/nrf52dk/doc.txt +++ b/boards/nrf52dk/doc.txt @@ -105,25 +105,9 @@ There are two pins for current measurement on board. Don't connect these pins to GND!. The left pin is at 3.3V level and the right pin is connected to V33. Divide the measured voltage between this pins by 22 to get the current. - ## Flash the board -By default, the board is flashed with via the on-board Segger JLink adapter. - -To flash the board, use `BOARD=nrf52dk` with the `make` command.
-Example with `hello-world` application: -``` - make BOARD=nrf52dk -C examples/hello-world flash -``` - -OpenOCD can also be used. For the moment, the latest stable version of OpenOCD -(0.10) doesn't contain any support for nrf52 but versions built against the -actual development version can be used. - -To flash the board with OpenOCD, use the `PROGRAMMER` variable: -``` - PROGRAMMER=openocd make BOARD=nrf52dk -C examples/hello-world flash -``` +See the `Flashing` section in @ref boards_common_nrf52. ## Accessing STDIO via UART diff --git a/boards/ruuvitag/doc.txt b/boards/ruuvitag/doc.txt index 4bf7036125..191d5c6cd8 100644 --- a/boards/ruuvitag/doc.txt +++ b/boards/ruuvitag/doc.txt @@ -2,4 +2,9 @@ @defgroup boards_ruuvitag RuuviTag @ingroup boards @brief Support for the RuuviTag board + +## Flash the board + +See the `Flashing` section in @ref boards_common_nrf52. + */ diff --git a/boards/thingy52/doc.txt b/boards/thingy52/doc.txt index 016cdf349f..8b9dbe870f 100644 --- a/boards/thingy52/doc.txt +++ b/boards/thingy52/doc.txt @@ -2,4 +2,9 @@ @defgroup boards_thingy52 Nordic Thingy:52 @ingroup boards @brief Support for the Nordic Thingy:52 board + +## Flash the board + +See the `Flashing` section in @ref boards_common_nrf52. + */ From 7a5d2ad2fb1853fbffa48008c461fcc76f875825 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 26 Feb 2019 11:15:36 +0100 Subject: [PATCH 6/6] boards/nrf52: thingy52 and ruuvitag don't work with openocd --- boards/common/nrf52/Makefile.include | 4 ++++ boards/common/nrf52/doc.txt | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/boards/common/nrf52/Makefile.include b/boards/common/nrf52/Makefile.include index f8e47e1b57..2df50ef0a3 100644 --- a/boards/common/nrf52/Makefile.include +++ b/boards/common/nrf52/Makefile.include @@ -27,6 +27,10 @@ ifeq (jlink,$(PROGRAMMER)) endif include $(RIOTMAKE)/tools/jlink.inc.mk else ifeq (openocd,$(PROGRAMMER)) + ifneq (,$(filter $(BOARD),ruuvitag thingy52)) + # openocd doesn't fully work with ruuvitag and thingy52 + $(error Cannot use OpenOCD with $(BOARD) board) + endif # setup OpenOCD for flashing. Version 0.10 of OpenOCD doesn't contain support # for nrf52dk and nrf52840dk boards. To use OpenOCD with these a version # build from source (master > 2018, August the 13rd) is required. diff --git a/boards/common/nrf52/doc.txt b/boards/common/nrf52/doc.txt index 3c6f34e606..332c538f4b 100644 --- a/boards/common/nrf52/doc.txt +++ b/boards/common/nrf52/doc.txt @@ -14,9 +14,11 @@ Example with `hello-world` application: make BOARD= -C examples/hello-world flash ``` -OpenOCD can also be used to flash nrf52 boards. For the moment, the latest -stable version of OpenOCD (0.10) doesn't contain any support for nrf52 but -versions built against the current development version can be used. +OpenOCD can also be used to flash nrf52 boards (except thingy52 and ruuvitag +because they are hardly coupled with JLink segger_rtt stdio). +For the moment, the latest stable version of OpenOCD (0.10) doesn't contain any +support for nrf52 but versions built against the current development version +can be used. To flash the board with OpenOCD, use the `PROGRAMMER` variable: ```