Skip to content

Commit

Permalink
Merge pull request #9407 from aabadie/pr/board/nrf52dk_openocd
Browse files Browse the repository at this point in the history
boards/nrf52: add openocd as programmer option
  • Loading branch information
maribu committed Feb 26, 2019
2 parents a5385c1 + 7a5d2ad commit ef70d2a
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 26 deletions.
5 changes: 5 additions & 0 deletions boards/acd52832/doc.txt
Expand Up @@ -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.

*/
28 changes: 20 additions & 8 deletions boards/common/nrf52/Makefile.include
Expand Up @@ -9,24 +9,36 @@ 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))
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.
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
@@ -1,2 +1,3 @@
transport select swd

source [find target/nrf52.cfg]
28 changes: 28 additions & 0 deletions boards/common/nrf52/doc.txt
@@ -0,0 +1,28 @@
/**
@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=<nrf52 board>` with the `make` command.<br/>
Example with `hello-world` application:
```
make BOARD=<nrf52 board> -C examples/hello-world flash
```

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:
```
PROGRAMMER=openocd make BOARD=<nrf52 board> -C examples/hello-world flash
```

*/
3 changes: 1 addition & 2 deletions boards/common/nrf52/include/board_common.h
Expand Up @@ -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.
* @{
*
Expand Down
3 changes: 0 additions & 3 deletions boards/nrf52840-mdk/Makefile.include
Expand Up @@ -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
14 changes: 1 addition & 13 deletions boards/nrf52840-mdk/doc.txt
Expand Up @@ -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.<br/>
Example with `hello-world` application:
```
make BOARD=nrf52840-mdk -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.
See the `Flashing` section in @ref boards_common_nrf52.

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

Expand Down
14 changes: 14 additions & 0 deletions boards/nrf52840dk/doc.txt
Expand Up @@ -13,4 +13,18 @@ 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

See the `Flashing` section in @ref boards_common_nrf52.

## 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<br/>
```
make BOARD=nrf52840dk -C examples/hello-world term
```

*/
14 changes: 14 additions & 0 deletions boards/nrf52dk/doc.txt
Expand Up @@ -104,4 +104,18 @@ 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

See the `Flashing` section in @ref boards_common_nrf52.

## 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<br/>
```
make BOARD=nrf52dk -C examples/hello-world term
```
*/
5 changes: 5 additions & 0 deletions boards/ruuvitag/doc.txt
Expand Up @@ -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.

*/
5 changes: 5 additions & 0 deletions boards/thingy52/doc.txt
Expand Up @@ -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.

*/

0 comments on commit ef70d2a

Please sign in to comment.