1# SPDX-License-Identifier: Apache-2.0
2#
3# Copyright (c) 2023, Nordic Semiconductor ASA
4
5## A pykwalify schema for basic validation of the structure of a
6## board metadata YAML file.
7##
8# The board.yml file is a simple list of key value pairs containing board
9# information like: name, vendor, socs, variants.
10schema;variant-schema:
11  required: false
12  type: seq
13  sequence:
14    - type: map
15      mapping:
16        name:
17          required: true
18          type: str
19        cpucluster:
20          required: false
21          type: str
22        variants:
23          required: false
24          include: variant-schema
25
26schema;extend-variant-schema:
27  required: false
28  type: seq
29  sequence:
30    - type: map
31      mapping:
32        name:
33          required: true
34          type: str
35        qualifier:
36          required: true
37          type: str
38
39schema;board-schema:
40  type: map
41  mapping:
42    name:
43      required: false # Note: either name or extend is required, but that is handled in python
44      type: str
45      desc: Name of the board
46    full_name:
47      required: false
48      type: str
49      desc: Full name of the board. Typically set to the commercial name of the board.
50    extend:
51      required: false # Note: either name or extend is required, but that is handled in python
52      type: str
53    vendor:
54      required: false
55      type: str
56      desc: SoC family of the SoC on the board.
57    revision:
58      required: false
59      type: map
60      mapping:
61        format:
62          required: true
63          type: str
64          enum:
65            ["major.minor.patch", "letter", "number", "custom"]
66        default:
67          required: false # This field is required when 'format' != 'custom'
68          type: str
69        exact:
70          required: false
71          type: bool
72        revisions:
73          required: false # This field is required when 'format' != 'custom'
74          type: seq
75          sequence:
76            - type: map
77              mapping:
78                name:
79                  required: true
80                  type: str
81    socs:
82      required: false # Required for name:, but not for extend.
83      type: seq
84      sequence:
85        - type: map
86          mapping:
87            name:
88              required: true
89              type: str
90            variants:
91              include: variant-schema
92    variants:
93      include: extend-variant-schema
94
95type: map
96mapping:
97  board:
98    include: board-schema
99  boards:
100    type: seq
101    sequence:
102      - include: board-schema
103  runners:
104    type: map
105    mapping:
106      priority:
107        type: int
108        desc: |
109              Priority of this flash run once configuration. The highest value data will be used
110              instead of any with lower priorities. If omitted, will default to 10.
111      run_once:
112        type: map
113        desc: |
114              Allows for restricting west flash commands when using sysbuild to run once per given
115              grouping of board targets. This is to allow for future image program cycles to not
116              erase the flash of a device which has just been programmed by another image.
117        mapping:
118          regex;(.*):
119            type: seq
120            desc: |
121                  A dictionary of commands which should be limited to running once per invocation
122                  of west flash for a given set of flash runners and board targets.
123            sequence:
124              - type: map
125                mapping:
126                  run:
127                    required: true
128                    type: str
129                    enum: ['first', 'last']
130                    desc: |
131                          If first, will run this command once when the first image is flashed, if
132                          last, will run this command once when the final image is flashed.
133                  runners:
134                    required: true
135                    type: seq
136                    sequence:
137                      - type: str
138                        desc: |
139                              A list of flash runners that this applies to, can use `all` to apply
140                              to all runners.
141                  groups:
142                    required: true
143                    type: seq
144                    sequence:
145                      - type: map
146                        desc: |
147                              A grouping of board targets which the command should apply to. Can
148                              be used multiple times to have multiple groups.
149                        mapping:
150                          boards:
151                            required: true
152                            type: seq
153                            sequence:
154                              - type: str
155                                desc: |
156                                      A board target to match against in regex. Must be one entry
157                                      per board target, a single regex entry will not match two
158                                      board targets even if they both match.
159