Skip to content

Commit c461a68

Browse files
divipillairlubos
authored andcommitted
doc: Add sdk nrf toolchain docker image
Added nRF connect SDK docker image. Signed-off-by: divya pillai <[email protected]> (cherry picked from commit b863230)
1 parent cc75976 commit c461a68

File tree

5 files changed

+106
-103
lines changed

5 files changed

+106
-103
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@
604604
/scripts/print_toolchain_checksum.sh @nrfconnect/ncs-ci
605605
/scripts/sdp/ @nrfconnect/ncs-ll-ursus
606606

607+
/scripts/docker/*.rst @nrfconnect/ncs-doc-leads
607608
/scripts/hid_configurator/*.rst @nrfconnect/ncs-si-bluebagel-doc
608609
/scripts/memfault/*.rst @nrfconnect/ncs-cia-doc
609610
/scripts/nrf_provision/fast_pair/*.rst @nrfconnect/ncs-si-bluebagel-doc

doc/nrf/links.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
.. _`Zephyr pull request #50305`: https://github.com/zephyrproject-rtos/zephyr/pull/50305
4646
.. _`Zephyr issue #69546`: https://github.com/zephyrproject-rtos/zephyr/issues/69546
4747

48+
.. _`print_toolchain_checksum.sh`: https://github.com/nrfconnect/sdk-nrf/blob/main/scripts/print_toolchain_checksum.sh
49+
.. _`JLink License Agreement`: https://github.com/nrfconnect/sdk-nrf/blob/main/scripts/docker/jlink/license.txt
50+
4851
.. _`sdk-mcuboot`: https://github.com/nrfconnect/sdk-mcuboot
4952
.. _`MCUboot design`: https://github.com/mcu-tools/mcuboot/blob/main/docs/design.md
5053
.. _`MCUboot repository`: https://github.com/mcu-tools/mcuboot

doc/nrf/scripts.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Here you can find documentation for these scripts.
1515
../../scripts/shell/*/*
1616
../../scripts/nrf_provision/*/*
1717
../../scripts/hid_configurator/*
18+
../../scripts/docker/*
1819
../../scripts/partition_manager/*
1920
../../scripts/west_commands/sbom/*
2021
../../scripts/memfault/*

scripts/docker/README.md

Lines changed: 0 additions & 103 deletions
This file was deleted.

scripts/docker/README.rst

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
.. _nrf_toolchain_docker_image:
2+
3+
|NCS| toolchain Docker image
4+
############################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
The image is based on Linux - Ubuntu 22.04 Docker image with the following additional tools:
11+
12+
* Git
13+
* `nRF Util`_ with following commands:
14+
15+
* ``toolchain-manager``
16+
* ``device``
17+
18+
* |NCS| toolchain bundle
19+
* JLink |jlink_ver| (installation requires accepting SEGGER License)
20+
21+
Building image
22+
**************
23+
24+
To build a Docker image, you have to provide a ``VERSION`` argument containing the ID of the Linux toolchain bundle you want to install.
25+
You can use `print_toolchain_checksum.sh`_ to get ID proper for your |NCS| revision.
26+
27+
.. code-block:: shell
28+
29+
TOOLCHAIN_ID=$(../print_toolchain_checksum.sh)
30+
docker build --build-arg VERSION=$TOOLCHAIN_ID
31+
32+
Accepting JLink license
33+
***********************
34+
35+
To install and use JLink software you have to accept `JLink License Agreement`_.
36+
37+
If the container is run in an interactive mode, you will be asked to accept the license at the start of the container.
38+
39+
You can also start the container with the ``ACCEPT_JLINK_LICENSE=1`` environment variable, and JLink will be installed without prompting.
40+
41+
During post installation steps, JLink configures ``udev`` roles.
42+
This operation requires running a container with the ``--privileged`` flag to grant permissions needed for the container.
43+
44+
Running container
45+
*****************
46+
47+
Toolchain environment variables are set only in Bash sessions.
48+
Outside the Bash session, these variables are not set, and tools delivered in the toolchain bundle cannot be found on the path.
49+
|NCS| toolchain image uses ``bash`` command as entry point.
50+
If the entry point is not overwritten, you can start your Docker container in both interactive and non-interactive mode.
51+
52+
Locally
53+
=======
54+
55+
To run the |NCS| toolchain container to build and flash HEX files, run the following command.
56+
57+
.. code-block:: none
58+
59+
docker run -ti ghcr.io/nrfconnect/sdk-nrf-toolchain:<TAG> -v /dev:/dev --privileged -e ACCEPT_JLINK_LICENSE=1 bash
60+
61+
.. tip::
62+
63+
You can also add the ``-v <PATH-TO-NCS-PROJECT-ON-DOCKER-HOST>:/ncs`` argument to the ``docker run`` command to mount the |NCS| project to the container.
64+
In such cases, you might encounter issues with repositories, ownership, and west project configuration.
65+
To resolve them, perform the following:
66+
67+
* Run the ``git config --global --add safe.directory '*'`` command to mark mounted git repositories as trusted.
68+
* Run the ``west update`` command to import west commands delivered in the |NCS| project (for example, ``west build``)
69+
* Add ``--pristine`` argument to ``west build`` command to avoid path mismatch issues.
70+
71+
In CI
72+
=====
73+
74+
CI systems usually run the Docker container in detached mode and can override the default entry point and command.
75+
However, it is still possible to use the |NCS| toolchain images in pipelines.
76+
77+
GitHub Actions
78+
--------------
79+
80+
GitHub action starts container with overwritten default entry point. That means you have to set ``bash`` as a default shell to load all required environment variables.
81+
82+
If the container is started with the ``ACCEPT_JLINK_LICENSE`` env variable set to ``1``, JLink will be installed just before the first bash command is executed.
83+
84+
Example job configuration:
85+
86+
.. code-block:: yaml
87+
88+
jobs:
89+
build-in-docker:
90+
runs-on: ubuntu-22.04
91+
container:
92+
image: ghcr.io/nrfconnect/sdk-nrf-toolchain:<TAG> # steps in this job are executed inside sdk-nrf-toolchain container
93+
env:
94+
ACCEPT_JLINK_LICENSE: 1 # set if you want to install JLink
95+
defaults:
96+
run:
97+
shell: bash # It is required to set `bash` as default shell
98+
steps:
99+
- name: Run command in NCS toolchain environment
100+
run: "west --version" # This command is executed in bash shell `docker exec <container> bash -c west --version`
101+
# It will also install JLink if ACCEPT_JLINK_LICENSE is set to 1

0 commit comments

Comments
 (0)