aboutsummaryrefslogtreecommitdiff
path: root/circuitpython/tools/gen_nvm_devices.py
diff options
context:
space:
mode:
Diffstat (limited to 'circuitpython/tools/gen_nvm_devices.py')
-rw-r--r--circuitpython/tools/gen_nvm_devices.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/circuitpython/tools/gen_nvm_devices.py b/circuitpython/tools/gen_nvm_devices.py
new file mode 100644
index 0000000..3cda867
--- /dev/null
+++ b/circuitpython/tools/gen_nvm_devices.py
@@ -0,0 +1,23 @@
+import sys
+import cascadetoml
+import pathlib
+import typer
+from jinja2 import Template
+
+
+def main(input_template: pathlib.Path, output_path: pathlib.Path):
+ flashes = cascadetoml.filter_toml(pathlib.Path("../../data/nvm.toml"), [])
+
+ template = Template(input_template.read_text())
+
+ settings = {"nvms": []}
+ for flash in flashes["nvm"]:
+ if "sku" not in flash or flash["sku"] == flash["manufacturer"]:
+ continue
+ settings["nvms"].append(dict(flash))
+
+ output_path.write_text(template.render(settings))
+
+
+if __name__ == "__main__":
+ typer.run(main)