From a5014429324bdc7c885dd03d32493329c1360501 Mon Sep 17 00:00:00 2001
From: Arul Kumaran <arulkumaran.devarajan@huawei.com>
Date: Tue, 1 Jun 2021 15:21:38 +0530
Subject: [PATCH] docs/nRF52840-DK.rst: Documentation for nRF52840 DK Board

* Introduce new nRF52840-DK topic in supported boards, fixes issue
  https://git.ostc-eu.org/OSTC/planning/hw-enablement/-/issues/27.

Signed-off-by: Arul Kumaran <arulkumaran.devarajan@huawei.com>
---
 docs/build-flavours/zephyr-flavour.rst       |   1 +
 docs/hardware-support/boards/index.rst       |   1 +
 docs/hardware-support/boards/nRF52840-DK.rst | 101 +++++++++++++++++++
 3 files changed, 103 insertions(+)
 create mode 100644 docs/hardware-support/boards/nRF52840-DK.rst

diff --git a/docs/build-flavours/zephyr-flavour.rst b/docs/build-flavours/zephyr-flavour.rst
index ecec828f..7fa21496 100644
--- a/docs/build-flavours/zephyr-flavour.rst
+++ b/docs/build-flavours/zephyr-flavour.rst
@@ -23,6 +23,7 @@ Supported machines (default in **bold**):
 * 96b-nitrogen (96Boards Nitrogen)
 * 96b-avenger96 (96Boards Avenger96)
 * arduino-nano-33-ble (Arduino Nano 33 BLE and Arduino Nano 33 BLE Sense)
+* nrf52840dk-nrf52840 (Nordic Semiconductor nRF 52840 Development Kit)
 
 Build steps example:
 
diff --git a/docs/hardware-support/boards/index.rst b/docs/hardware-support/boards/index.rst
index 9cd7d88b..d6b6c1a0 100644
--- a/docs/hardware-support/boards/index.rst
+++ b/docs/hardware-support/boards/index.rst
@@ -16,3 +16,4 @@ This section details the boards supported as part of All Scenario OS.
    seco-imx8mm-c61
    raspberrypi4
    arduino-nano-33-ble
+   nRF52840-DK
diff --git a/docs/hardware-support/boards/nRF52840-DK.rst b/docs/hardware-support/boards/nRF52840-DK.rst
new file mode 100644
index 00000000..90238d0b
--- /dev/null
+++ b/docs/hardware-support/boards/nRF52840-DK.rst
@@ -0,0 +1,101 @@
+.. SPDX-FileCopyrightText: Huawei Inc.
+..
+.. SPDX-License-Identifier: CC-BY-4.0
+
+.. _SupportedBoardnRF52840DK:
+
+nRF52840 DK
+############
+
+.. contents::
+   :depth: 3
+
+Overview
+********
+
+The nRF52840 DK is a low-cost single-board development kit that uses the nRF52840
+multi-protocol SoC to develop Bluetooth® 5, Bluetooth mesh, Thread, Zigbee, ANT, IEEE 802.15.4, and 2.4 GHz
+proprietary applications. It also supports development on the nRF52811 SoC.
+
+Hardware
+********
+
+* For detailed specifications, see nRF52840 DK product page on the `nRF52840 DK website <https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK>`_.
+* For hardware schematics, see `nRF52840 Development Kit <https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52840-DK/Download#infotabs>`_.
+
+Working with the board
+**********************
+
+Building an application
+=======================
+
+All Scenarios OS Zephyr flavour is based on Zephyr kernel.
+
+1. Source the environment with proper template settings, flavour being ``zephyr``
+   and target machine being ``nrf52840dk-nrf52840``:
+
+ .. code-block:: console
+
+   $ TEMPLATECONF=../sources/meta-ohos/flavours/zephyr . ./sources/poky/oe-init-build-env build-ohos-zephyr
+
+2. You will find yourself in the newly created build directory. Call ``bitbake``
+   to build the image. Example below shows how to build ``zephyr-philosophers``.
+
+ .. code-block:: console
+
+   $ MACHINE=nrf52840dk-nrf52840 bitbake zephyr-philosophers
+
+ You can set up ``MACHINE`` variable can be set up in ``conf/local.conf`` file under the build directory, or via the command line.
+
+3. After the build completes, the image file can be found in
+   ``build-ohos-zephyr/tmp-newlib/deploy/images/nrf52840dk-nrf52840/``.
+
+Flashing an application
+=======================
+
+Installing pyOCD
+----------------
+
+pyOCD is an open source Python package for programming and debugging
+Arm Cortex-M microcontrollers using multiple supported types of USB debug probes. 
+It is fully cross-platform, with support for Linux.
+
+* To install the latest stable version of pyOCD via `pip <https://pip.pypa.io/en/stable/>`_ as follows:
+
+ .. code-block:: console
+
+   $ pip install --pre -U pyOCD
+
+* To install the latest pre-release version from the HEAD of the master branch, execute the following command:
+
+ .. code-block:: console
+
+   $ pip install --pre -U git+https://github.com/mbedmicro/pyOCD.git
+
+* To install directly from the source by cloning the git repository, do the following:
+
+ .. code-block:: console
+
+   $ python setup.py install
+
+* Verify that the board is detected by pyOCD by executing the command:
+
+ .. code-block:: console
+
+   $ pyocd-flashtool -l
+
+ .. note::
+
+   When ``ValueError: The device has no langid`` error is displayed due to lack of 
+   permission, perform the `instructions to resolve <https://github.com/pyocd/pyOCD/tree/master/udev>`__.
+
+How to flash
+------------
+
+To flash the image, execute the command used to build the image with ``-c flash_usb`` appended.
+For example, to flash the already built zephyr-philosophers image, execute:
+
+.. code-block:: console
+
+   $ MACHINE=nrf52840dk-nrf52840 bitbake zephyr-philosophers -c flash_usb
+
-- 
GitLab