Skip to content

Commit 8e8ada4

Browse files
Refactor examples for handling many boards
The current way examples are done in the repository and shipped in the SDK does not make sense when you have many boards in my opinion so this restructure moves examples that are not specific to any particular platform (e.g hello world) to be generic to every platform supported by Microkit. Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
1 parent 9bc4568 commit 8e8ada4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+150
-805
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ LICENSE.md
189189
LICENSES/$licence.txt
190190
doc/
191191
doc/microkit_user_manual.pdf
192+
example/
193+
example/$example/
192194
bin/
193195
bin/microkit
194196
board/

build_sdk.py

Lines changed: 23 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class BoardInfo:
7373
gcc_cpu: Optional[str]
7474
loader_link_address: int
7575
kernel_options: KERNEL_OPTIONS
76-
examples: Dict[str, Path]
7776

7877

7978
@dataclass
@@ -96,9 +95,6 @@ class ConfigInfo:
9695
"KernelArmHypervisorSupport": True,
9796
"KernelArmVtimerUpdateVOffset": False,
9897
},
99-
examples={
100-
"ethernet": Path("example/tqma8xqp1gb/ethernet")
101-
}
10298
),
10399
BoardInfo(
104100
name="zcu102",
@@ -113,9 +109,6 @@ class ConfigInfo:
113109
"KernelArmHypervisorSupport": True,
114110
"KernelArmVtimerUpdateVOffset": False,
115111
},
116-
examples={
117-
"hello": Path("example/zcu102/hello")
118-
}
119112
),
120113
BoardInfo(
121114
name="maaxboard",
@@ -129,9 +122,6 @@ class ConfigInfo:
129122
"KernelArmHypervisorSupport": True,
130123
"KernelArmVtimerUpdateVOffset": False,
131124
},
132-
examples={
133-
"hello": Path("example/maaxboard/hello")
134-
}
135125
),
136126
BoardInfo(
137127
name="imx8mm_evk",
@@ -145,9 +135,6 @@ class ConfigInfo:
145135
"KernelArmHypervisorSupport": True,
146136
"KernelArmVtimerUpdateVOffset": False,
147137
},
148-
examples={
149-
"passive_server": Path("example/imx8mm_evk/passive_server")
150-
}
151138
),
152139
BoardInfo(
153140
name="imx8mp_evk",
@@ -161,9 +148,6 @@ class ConfigInfo:
161148
"KernelArmHypervisorSupport": True,
162149
"KernelArmVtimerUpdateVOffset": False,
163150
},
164-
examples={
165-
"hello": Path("example/imx8mp_evk/hello")
166-
}
167151
),
168152
BoardInfo(
169153
name="imx8mq_evk",
@@ -177,9 +161,6 @@ class ConfigInfo:
177161
"KernelArmHypervisorSupport": True,
178162
"KernelArmVtimerUpdateVOffset": False,
179163
},
180-
examples={
181-
"hello": Path("example/imx8mq_evk/hello")
182-
}
183164
),
184165
BoardInfo(
185166
name="odroidc2",
@@ -193,9 +174,6 @@ class ConfigInfo:
193174
"KernelArmHypervisorSupport": True,
194175
"KernelArmVtimerUpdateVOffset": False,
195176
},
196-
examples={
197-
"hello": Path("example/odroidc2/hello")
198-
}
199177
),
200178
BoardInfo(
201179
name="odroidc4",
@@ -209,9 +187,6 @@ class ConfigInfo:
209187
"KernelArmHypervisorSupport": True,
210188
"KernelArmVtimerUpdateVOffset": False,
211189
},
212-
examples={
213-
"timer": Path("example/odroidc4/timer")
214-
}
215190
),
216191
BoardInfo(
217192
name="qemu_virt_aarch64",
@@ -228,10 +203,6 @@ class ConfigInfo:
228203
"KernelArmExportPTMRUser": True,
229204
"KernelArmVtimerUpdateVOffset": False,
230205
},
231-
examples={
232-
"hello": Path("example/qemu_virt_aarch64/hello"),
233-
"hierarchy": Path("example/qemu_virt_aarch64/hierarchy")
234-
}
235206
),
236207
BoardInfo(
237208
name="qemu_virt_riscv64",
@@ -245,9 +216,6 @@ class ConfigInfo:
245216
"KernelRiscvExtD": True,
246217
"KernelRiscvExtF": True,
247218
},
248-
examples={
249-
"hello": Path("example/qemu_virt_riscv64/hello"),
250-
}
251219
),
252220
BoardInfo(
253221
name="rockpro64",
@@ -261,9 +229,6 @@ class ConfigInfo:
261229
"KernelArmHypervisorSupport": True,
262230
"KernelArmVtimerUpdateVOffset": False,
263231
},
264-
examples={
265-
"hello": Path("example/rockpro64/hello")
266-
}
267232
),
268233
BoardInfo(
269234
name="star64",
@@ -276,9 +241,6 @@ class ConfigInfo:
276241
"KernelRiscvExtD": True,
277242
"KernelRiscvExtF": True,
278243
},
279-
examples={
280-
"hello": Path("example/star64/hello")
281-
}
282244
),
283245
)
284246

@@ -310,6 +272,15 @@ class ConfigInfo:
310272
)
311273

312274

275+
EXAMPLES={
276+
"hello": Path("example/hello"),
277+
"ethernet": Path("example/ethernet"),
278+
"passive_server": Path("example/passive_server"),
279+
"hierarchy": Path("example/hierarchy"),
280+
"timer": Path("example/timer"),
281+
}
282+
283+
313284
def tar_filter(tarinfo: TarInfo) -> TarInfo:
314285
"""This is used to change the tarinfo when created the .tar.gz archive.
315286
@@ -681,19 +652,20 @@ def main() -> None:
681652
build_elf_component("loader", root_dir, build_dir, board, config, loader_defines)
682653
build_elf_component("monitor", root_dir, build_dir, board, config, [])
683654
build_lib_component("libmicrokit", root_dir, build_dir, board, config)
684-
# Setup the examples
685-
for example, example_path in board.examples.items():
686-
include_dir = root_dir / "board" / board.name / "example" / example
687-
source_dir = example_path
688-
for p in source_dir.rglob("*"):
689-
if not p.is_file():
690-
continue
691-
rel = p.relative_to(source_dir)
692-
dest = include_dir / rel
693-
dest.parent.mkdir(exist_ok=True, parents=True)
694-
dest.unlink(missing_ok=True)
695-
copy(p, dest)
696-
dest.chmod(0o744)
655+
656+
# Setup the examples
657+
for example, example_path in EXAMPLES.items():
658+
include_dir = root_dir / "example" / example
659+
source_dir = example_path
660+
for p in source_dir.rglob("*"):
661+
if not p.is_file():
662+
continue
663+
rel = p.relative_to(source_dir)
664+
dest = include_dir / rel
665+
dest.parent.mkdir(exist_ok=True, parents=True)
666+
dest.unlink(missing_ok=True)
667+
copy(p, dest)
668+
dest.chmod(0o744)
697669

698670
if not args.skip_tar:
699671
# At this point we create a tar.gz file

dev_build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ def main():
9090

9191
# Choose the makefile based on the `--example-from-sdk` command line flag
9292
makefile_directory = (
93-
f"{release}/board/{args.board}/example/{args.example}"
93+
f"{release}/example/{args.example}"
9494
if args.example_from_sdk
95-
else f"{CWD.absolute()}/example/{args.board}/{args.example}"
95+
else f"{CWD.absolute()}/example/{args.example}"
9696
)
9797

9898
cmd = ["make", "-C", makefile_directory]

docs/manual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ Additionally, for each supported board configuration the following are provided:
331331
* `kernel.elf`
332332
* `monitor.elf`
333333

334-
For some boards there are also examples provided in the `examples` directory.
334+
There are also examples provided in the `example` directory.
335335

336336
The Microkit SDK does **not** provide, nor require, any specific build system.
337337
The user is free to build their system using whatever build system is deemed most appropriate for their specific use case.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ ifeq ($(strip $(MICROKIT_CONFIG)),)
1919
$(error MICROKIT_CONFIG must be specified)
2020
endif
2121

22+
ifneq ($(MICROKIT_BOARD),tqma8xqp1gb)
23+
$(error Unsupported MICROKIT_BOARD given, only tqma8xqp1gb supported)
24+
endif
25+
2226
TOOLCHAIN := aarch64-none-elf
2327

2428
CPU := cortex-a35

example/ethernet/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Example - Ethernet
2+
3+
This example shows an ethernet system for the TQMa8XQP platform.
4+
It also includes a driver for the general purpose timer on the platform.
5+
6+
## Building
7+
8+
```sh
9+
mkdir build
10+
make BUILD_DIR=build MICROKIT_BOARD=tqma8xqp1gb MICROKIT_CONFIG=<debug/release/benchmark> MICROKIT_SDK=/path/to/sdk
11+
```
12+
13+
## Running
14+
15+
See instructions for your board in the manual.
File renamed without changes.

0 commit comments

Comments
 (0)