-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathEFM2RIOT.py
93 lines (70 loc) · 2.38 KB
/
EFM2RIOT.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from efm2riot import configuration, tasks, parsers
import argparse
import sys
import os
def parse_arguments():
"""
Parse commandline arguments.
"""
parser = argparse.ArgumentParser()
# Add options
parser.add_argument(
"--sdk", action="store", help="path to EFM32 SDK")
parser.add_argument(
"--svds", action="store", help="path to EFM32 SVDs folder")
parser.add_argument(
"--dist", action="store", default="dist/", help="output folder")
parser.add_argument(
"--development", action="store_true", default=False,
help="copy features under development")
# Parse command line
return parser.parse_args(), parser
def main(argv):
"""
Prepare a the EFM32 port for RIOT-OS, given the EFM32 SDK.
"""
# Parse command line arguments.
arguments, parser = parse_arguments()
root_directory = os.path.join(os.path.dirname(__file__), "efm2riot")
dist_directory = arguments.dist
sdk_directory = arguments.sdk
svds_directory = arguments.svds
# Start with a clean output directory.
tasks.clean_dist(dist_directory)
# Index all families.
families = parsers.parse_families(sdk_directory)
# Index all CPUs.
cpus = []
for family in families:
cpus.extend(
parsers.parse_cpus(
sdk_directory,
svds_directory,
family))
sys.stdout.write(
"Found %d CPUs in %d families.\n" % (
len(cpus), len(families)))
# Extend boards with families and CPUs.
boards = []
for board in configuration.BOARDS:
for cpu in cpus:
if cpu["cpu"] == board["cpu"]:
board.update(cpu)
boards.append(board)
break
else:
raise Exception(
"Unable to match CPU with board %s" % board["board"])
# Copy static files.
tasks.copy_static(
root_directory, dist_directory, sdk_directory, arguments.development)
# Process templates.
tasks.copy_templates(
root_directory, dist_directory, sdk_directory, cpus, families, boards,
arguments.development)
# Process patches.
tasks.copy_patches(
root_directory, dist_directory, sdk_directory, cpus, families, boards)
# E.g. `python3 EFM2RIOT.py --sdk /path/to/sdk --dist dist/'.
if __name__ == "__main__":
sys.exit(main(sys.argv))