Skip to content

Commit 16cb2bc

Browse files
committed
scripts: west_commands: genboard: support current NCS only
Maintaining multiversion compatibility is a nightmare, so lets make the tool support the current NCS version, ie, the one in the same tree. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 9e58cb8 commit 16cb2bc

22 files changed

+59
-478
lines changed

scripts/west_commands/genboard/config.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ products:
3737
- name: qdaa
3838
ram: 128
3939
flash: 512
40-
since: 2.5.0
4140
- name: qiaa
4241
ram: 128
4342
flash: 512
@@ -46,7 +45,6 @@ products:
4645
- name: qfaa
4746
ram: 256
4847
flash: 1024
49-
since: 2.5.0
5048
- name: qiaa
5149
ram: 256
5250
flash: 1024
@@ -68,7 +66,6 @@ products:
6866
- name: nrf54l15
6967
variants:
7068
- name: qfaa
71-
since: 2.7.0
7269
cores:
7370
- name: cpuapp
7471
arch: arm
@@ -82,14 +79,12 @@ products:
8279
ram: 256
8380
flash: 1024
8481
ns: true
85-
since: 2.5.0
8682
- name: nrf9151
8783
variants:
8884
- name: laca
8985
ram: 256
9086
flash: 1024
9187
ns: true
92-
since: 2.6.0
9388
- name: nrf9160
9489
variants:
9590
- name: sica
@@ -99,7 +94,6 @@ products:
9994
- name: nrf9161
10095
variants:
10196
- name: laca
102-
since: 2.5.0
10397
ram: 256
10498
flash: 1024
10599
ns: true

scripts/west_commands/genboard/ncs_genboard.py

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
TEMPLATE_DIR = SCRIPT_DIR / "templates"
2121
CONFIG = SCRIPT_DIR / "config.yml"
2222

23-
NCS_VERSION_MIN = (2, 0, 0)
24-
HWMV2_SINCE = (2, 7, 0)
25-
TFM_SINCE = (2, 6, 0)
26-
27-
NCS_VERSION_RE = re.compile(r"^(\d+)\.(\d+)\.(\d+)$")
2823
VENDOR_RE = re.compile(r"^[a-zA-Z0-9_-]+$")
2924
BOARD_RE = re.compile(r"^[a-zA-Z0-9_-]+$")
3025

@@ -51,9 +46,6 @@ def do_add_parser(self, parser_adder):
5146
)
5247
parser.add_argument("-s", "--soc", required=True, help="SoC")
5348
parser.add_argument("-v", "--variant", required=True, help="Variant")
54-
parser.add_argument(
55-
"-n", "--ncs-version", required=True, help="NCS target version"
56-
)
5749

5850
return parser
5951

@@ -62,17 +54,6 @@ def do_run(self, args, unknown_args):
6254
config = load(f, Loader=Loader)
6355

6456
# validate input
65-
m = NCS_VERSION_RE.match(args.ncs_version)
66-
if not m:
67-
log.err(f"Invalid NCS version: {args.ncs_version}")
68-
return
69-
70-
ncs_version = tuple(int(n) for n in m.groups())
71-
72-
if ncs_version < NCS_VERSION_MIN:
73-
log.err(f"Unsupported NCS version: {args.ncs_version}")
74-
return
75-
7657
if not VENDOR_RE.match(args.vendor):
7758
log.err(f"Invalid vendor name: {args.vendor}")
7859
return
@@ -100,26 +81,13 @@ def do_run(self, args, unknown_args):
10081
targets = []
10182
for variant in soc["variants"]:
10283
if args.variant == variant["name"]:
103-
since = variant.get("since", ".".join(str(i) for i in NCS_VERSION_MIN))
104-
m = NCS_VERSION_RE.match(since)
105-
if not m:
106-
log.err(f"Malformed NCS version: {since}")
107-
return
108-
109-
since_version = tuple(int(n) for n in m.groups())
110-
if ncs_version < since_version:
111-
log.err(
112-
f"SoC {args.soc}-{args.variant} not supported in NCS version {args.ncs_version}"
113-
)
114-
return
115-
11684
if "cores" in variant:
11785
for core in variant["cores"]:
11886
target = {
11987
"core": core["name"],
12088
"ram": core["ram"],
12189
"flash": core["flash"],
122-
"ns": core.get("ns", False) if ncs_version >= TFM_SINCE else False,
90+
"ns": core.get("ns", False),
12391
"xip": core.get("xip", False),
12492
"arch": core.get("arch", "arm"),
12593
}
@@ -137,7 +105,7 @@ def do_run(self, args, unknown_args):
137105
target = {
138106
"ram": variant["ram"],
139107
"flash": variant["flash"],
140-
"ns": variant.get("ns", False) if ncs_version >= TFM_SINCE else False,
108+
"ns": variant.get("ns", False),
141109
"xip": variant.get("xip", False),
142110
"arch": variant.get("arch", "arm"),
143111
}
@@ -161,8 +129,6 @@ def do_run(self, args, unknown_args):
161129
loader=FileSystemLoader(TEMPLATE_DIR / series),
162130
)
163131

164-
env.globals["ncs_version"] = ncs_version
165-
env.globals["hwmv2_since"] = HWMV2_SINCE
166132
env.globals["vendor"] = args.vendor
167133
env.globals["board"] = args.board
168134
env.globals["board_desc"] = args.board_desc
@@ -172,11 +138,7 @@ def do_run(self, args, unknown_args):
172138
env.globals["targets"] = targets
173139

174140
# render templates/copy files
175-
if ncs_version < HWMV2_SINCE:
176-
out_dir = args.output / "arm" / args.board
177-
else:
178-
out_dir = args.output / args.vendor / args.board
179-
141+
out_dir = args.output / args.vendor / args.board
180142
if not out_dir.exists():
181143
out_dir.mkdir(parents=True)
182144

@@ -192,16 +154,12 @@ def do_run(self, args, unknown_args):
192154
f.write(tmpl.render())
193155

194156
tmpl = env.get_template("Kconfig.board.jinja2")
195-
fname = (
196-
"Kconfig.board" if ncs_version < HWMV2_SINCE else f"Kconfig.{args.board}"
197-
)
198-
with open(out_dir / fname, "w") as f:
157+
with open(out_dir / f"Kconfig.{args.board}", "w") as f:
199158
f.write(tmpl.render())
200159

201-
if ncs_version >= HWMV2_SINCE:
202-
tmpl = env.get_template("board.yml.jinja2")
203-
with open(out_dir / f"board.yml", "w") as f:
204-
f.write(tmpl.render())
160+
tmpl = env.get_template("board.yml.jinja2")
161+
with open(out_dir / f"board.yml", "w") as f:
162+
f.write(tmpl.render())
205163

206164
tmpl = env.get_template("Kconfig.defconfig.jinja2")
207165
with open(out_dir / f"Kconfig.defconfig", "w") as f:
@@ -226,12 +184,10 @@ def do_run(self, args, unknown_args):
226184
for target in targets:
227185
name = args.board
228186
if target.get("core"):
229-
if ncs_version >= HWMV2_SINCE:
230-
name += f"_{args.soc}"
231-
name += f"_{target['core']}"
187+
name += f"_{args.soc}_{target['core']}"
232188
if target["ns"]:
233189
name += "_ns"
234-
elif target["xip"]:
190+
if target["xip"]:
235191
name += "_xip"
236192

237193
tmpl = env.get_template("board_defconfig.jinja2")
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
config BOARD_{{ board | upper }}
2-
{% if ncs_version < hwmv2_since %}
3-
bool "{{ board_desc }}"
4-
depends on SOC_{{ soc | upper }}_{{ variant | upper}}
5-
{% else %}
62
select SOC_{{ soc | upper }}_{{ variant | upper}}
7-
{% endif %}

scripts/west_commands/genboard/templates/nrf52/Kconfig.defconfig.jinja2

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
if BOARD_{{ board | upper }}
22

3-
{% if ncs_version < hwmv2_since %}
4-
config BOARD
5-
default "{{ board }}"
6-
7-
{% endif %}
83
config BT_CTLR
94
default BT
105

scripts/west_commands/genboard/templates/nrf52/board.cmake.jinja2

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ board_runner_args(jlink "--device={{ soc | replace("nrf", "nRF") }}_xx{{ variant
22
board_runner_args(pyocd "--target={{ soc }}" "--frequency=4000000")
33

44
include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
5-
{% if ncs_version >= (2, 4, 0) %}
65
include(${ZEPHYR_BASE}/boards/common/nrfutil.board.cmake)
7-
{% endif %}
86
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
97
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
108
include(${ZEPHYR_BASE}/boards/common/openocd-nrf5.board.cmake)

scripts/west_commands/genboard/templates/nrf52/board.dts.jinja2

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,6 @@
2525
};
2626

2727
{% if soc == "nrf52840" %}
28-
{% if ncs_version <= (2, 4, 0) %}
29-
slot0_partition: partition@c000 {
30-
label = "image-0";
31-
reg = <0x0000c000 DT_SIZE_K(412)>;
32-
};
33-
34-
slot1_partition: partition@73000 {
35-
label = "image-1";
36-
reg = <0x00073000 DT_SIZE_K(412)>;
37-
};
38-
39-
scratch_partition: partition@da000 {
40-
label = "image-scratch";
41-
reg = <0xda000 DT_SIZE_K(120)>;
42-
};
43-
44-
storage_partition: partition@f8000 {
45-
label = "storage";
46-
reg = <0x000f8000 DT_SIZE_K(32)>;
47-
};
48-
{% else %}
4928
slot0_partition: partition@c000 {
5029
label = "image-0";
5130
reg = <0x0000c000 DT_SIZE_K(472)>;
@@ -60,29 +39,7 @@
6039
label = "storage";
6140
reg = <0x000f8000 DT_SIZE_K(32)>;
6241
};
63-
{% endif %}
6442
{% elif soc == "nrf52833" or soc == "nrf52832" %}
65-
{% if ncs_version <= (2, 4, 0) %}
66-
slot0_partition: partition@c000 {
67-
label = "image-0";
68-
reg = <0x0000c000 DT_SIZE_K(200)>;
69-
};
70-
71-
slot1_partition: partition@3e000 {
72-
label = "image-1";
73-
reg = <0x0003e000 DT_SIZE_K(200)>;
74-
};
75-
76-
scratch_partition: partition@70000 {
77-
label = "image-scratch";
78-
reg = <0x70000 DT_SIZE_K(40)>;
79-
};
80-
81-
storage_partition: partition@7a000 {
82-
label = "storage";
83-
reg = <0x0007a000 DT_SIZE_K(24)>;
84-
};
85-
{% else %}
8643
slot0_partition: partition@c000 {
8744
label = "image-0";
8845
reg = <0x0000c000 DT_SIZE_K(220)>;
@@ -97,7 +54,6 @@
9754
label = "storage";
9855
reg = <0x0007a000 DT_SIZE_K(24)>;
9956
};
100-
{% endif %}
10157
{% elif soc == "nrf52820" %}
10258
slot0_partition: partition@c000 {
10359
label = "image-0";
@@ -114,27 +70,6 @@
11470
reg = <0x0003a000 DT_SIZE_K(24)>;
11571
};
11672
{% elif soc == "nrf52811" or soc == "nrf52810" or soc == "nrf52805" %}
117-
{% if ncs_version <= (2, 4, 0) %}
118-
slot0_partition: partition@c000 {
119-
label = "image-0";
120-
reg = <0x0000c000 DT_SIZE_K(52)>;
121-
};
122-
123-
slot1_partition: partition@19000 {
124-
label = "image-1";
125-
reg = <0x0001a000 DT_SIZE_K(52)>;
126-
};
127-
128-
scratch_partition: partition@26000 {
129-
label = "image-scratch";
130-
reg = <0x26000 DT_SIZE_K(12)>;
131-
};
132-
133-
storage_partition: partition@29000 {
134-
label = "storage";
135-
reg = <0x00029000 DT_SIZE_K(28)>;
136-
};
137-
{% else %}
13873
slot0_partition: partition@c000 {
13974
label = "image-0";
14075
reg = <0x0000c000 DT_SIZE_K(56)>;
@@ -149,8 +84,6 @@
14984
label = "storage";
15085
reg = <0x00028000 DT_SIZE_K(32)>;
15186
};
152-
{% endif %}
153-
15487
{% endif %}
15588
};
15689
};
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
{% if ncs_version < hwmv2_since %}
2-
CONFIG_SOC_SERIES_{{ series | upper }}X=y
3-
CONFIG_SOC_{{ soc | upper }}_{{ variant | upper }}=y
4-
CONFIG_BOARD_{{ board | upper }}=y
5-
6-
{% endif %}
71
CONFIG_ARM_MPU=y
82
CONFIG_HW_STACK_PROTECTION=y
9-
10-
{% if ncs_version <= (2, 6, 0) %}
11-
CONFIG_PINCTRL=y
12-
{% endif %}
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
{% if ncs_version < hwmv2_since %}
2-
identifier: {{ board }}
3-
{% else %}
41
identifier: {{ board }}/{{ soc }}
5-
{% endif %}
62
name: {{ board_desc }}
73
vendor: {{ vendor }}
84
type: mcu
@@ -11,5 +7,4 @@ ram: {{ target["ram"] }}
117
flash: {{ target["flash"] }}
128
toolchain:
139
- zephyr
14-
supported:
15-
- gpio
10+
supported: []
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
{% if ncs_version < hwmv2_since %}
2-
if SOC_NRF5340_CPUAPP_QKAA
3-
4-
config BOARD_{{ board | upper }}_CPUAPP
5-
bool "{{ board_desc }} (CPUAPP)"
6-
7-
config BOARD_{{ board | upper }}_CPUAPP_NS
8-
bool "{{ board_desc }} (CPUAPP Non-Secure)"
9-
10-
endif # SOC_NRF5340_CPUAPP_QKAA
11-
12-
config BOARD_{{ board | upper }}_CPUNET
13-
bool "{{ board_desc }} (CPUNET)"
14-
depends on SOC_NRF5340_CPUNET_QKAA
15-
{% else %}
161
config BOARD_{{ board | upper }}
172
select SOC_NRF5340_CPUAPP_QKAA if BOARD_{{ board | upper }}_NRF5340_CPUAPP
183
select SOC_NRF5340_CPUAPP_QKAA if BOARD_{{ board | upper }}_NRF5340_CPUAPP_NS
194
select SOC_NRF5340_CPUNET_QKAA if BOARD_{{ board | upper }}_NRF5340_CPUNET
20-
{% endif %}

0 commit comments

Comments
 (0)