Skip to content

Commit ff823c6

Browse files
nordicjmfabiobaltieri
authored andcommitted
doc: build: flashing: Add documentation
Adds documentation on the new flashing configuration system Signed-off-by: Jamie McCrae <[email protected]>
1 parent 4b2d19f commit ff823c6

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
.. _flashing-soc-board-config:
2+
3+
Flashing configuration
4+
######################
5+
6+
Zephyr supports setting up configuration for flash runners (invoked from
7+
:ref:`west flash<west-flashing>`) which allows for customising how commands are used when
8+
programming boards. This configuration is used for :ref:`sysbuild` projects and allows for
9+
configuring when commands are ran for groups of board targets. As an example: a multi-core SoC
10+
might want to only allow the ``--erase`` argument to be used once for all of the cores in the SoC
11+
which would prevent multiple erase tasks running in a single ``west flash`` invocation, which
12+
could wrongly clear the memory which is used by the other images being programmed.
13+
14+
Priority
15+
********
16+
17+
Flashing configuration is singular, it will only be read from a single location, this
18+
configuration can reside in the following files starting with the highest priority:
19+
20+
* ``soc.yml`` (in soc folder)
21+
* ``board.yml`` (in board folder)
22+
23+
Configuration
24+
*************
25+
26+
Configuration is applied in the yml file by using a ``runners`` map with a single ``run_once``
27+
child, this then contains a map of commands as they would be provided to the flash runner e.g.
28+
``--reset`` followed by a list which specifies the settings for each of these commands (these
29+
are grouped by flash runner, and by qualifiers/boards). Commands have associated runners that
30+
they apply to using a ``runners`` list value, this can contain ``all`` if it applies to all
31+
runners, otherwise must contain each runner that it applies to using the runner-specific name.
32+
Groups of board targets can be specified using the ``groups`` key which has a list of board
33+
target sets. Board targets are regular expression matches, for ``soc.yml`` files each set of
34+
board targets must be in a ``qualifiers`` key (only regular expression matches for board
35+
qualifiers are allowed, board names must be omitted from these entries). For ``board.yml``
36+
files each set of board targets must be in a ``boards`` key, these are lists containing the
37+
matches which form a singular group. A final parameter ``run`` can be set to ``first`` which
38+
means that the command will be ran once with the first image flashing process per set of board
39+
targets, or to ``last`` which will be ran once for the final image flash per set of board targets.
40+
41+
An example flashing configuration for a ``soc.yml`` is shown below in which the ``--recover``
42+
command will only be used once for any board targets which used the nRF5340 SoC application or
43+
network CPU cores, and will only reset the network or application core after all images for the
44+
respective core have been flashed.
45+
46+
.. code-block:: yaml
47+
48+
runners:
49+
run_once:
50+
'--recover':
51+
- run: first
52+
runners:
53+
- nrfjprog
54+
groups:
55+
- qualifiers:
56+
- nrf5340/cpunet
57+
- nrf5340/cpuapp
58+
- nrf5340/cpuapp/ns
59+
'--reset':
60+
- run: last
61+
runners:
62+
- nrfjprog
63+
- jlink
64+
groups:
65+
- qualifiers:
66+
- nrf5340/cpunet
67+
- qualifiers:
68+
- nrf5340/cpuapp
69+
- nrf5340/cpuapp/ns
70+
# Made up non-real world example to show how to specify different options for different
71+
# flash runners
72+
- run: first
73+
runners:
74+
- some_other_runner
75+
groups:
76+
- qualifiers:
77+
- nrf5340/cpunet
78+
- qualifiers:
79+
- nrf5340/cpuapp
80+
- nrf5340/cpuapp/ns
81+
82+
Usage
83+
*****
84+
85+
Commands that are supported by flash runners can be used as normal when flashing non-sysbuild
86+
applications, the run once configuration will not be used. When flashing a sysbuild project with
87+
multiple images, the flash runner run once configuration will be applied.
88+
89+
For example, building the :zephyr:code-sample:`smp-svr` sample for the nrf5340dk which will
90+
include MCUboot as a secondary image:
91+
92+
.. code-block:: console
93+
94+
cmake -GNinja -Sshare/sysbuild/ -Bbuild -DBOARD=nrf5340dk/nrf5340/cpuapp -DAPP_DIR=samples/subsys/mgmt/mcumgr/smp_svr
95+
cmake --build build
96+
97+
Once built with an nrf5340dk connected, the following command can be used to flash the board with
98+
both applications and will only perform a single device recovery operation when programming the
99+
first image:
100+
101+
.. code-block:: console
102+
103+
west flash --recover
104+
105+
If the above was ran without the flashing configuration, the recovery process would be ran twice
106+
and the device would be unbootable.

doc/build/flashing/index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. _flashing:
2+
3+
Flashing
4+
########
5+
6+
.. toctree::
7+
:maxdepth: 1
8+
9+
configuration.rst

doc/build/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ Build and Configuration Systems
1515
zephyr_cmake_package.rst
1616
sysbuild/index.rst
1717
version/index.rst
18+
flashing/index.rst

0 commit comments

Comments
 (0)