aboutsummaryrefslogtreecommitdiff
path: root/circuitpython/tools/gen_nvm_devices.py
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2022-06-19 19:47:51 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2022-06-19 19:47:51 +0530
commit4fd287655a72b9aea14cdac715ad5b90ed082ed2 (patch)
tree65d393bc0e699dd12d05b29ba568e04cea666207 /circuitpython/tools/gen_nvm_devices.py
parent0150f70ce9c39e9e6dd878766c0620c85e47bed0 (diff)
add circuitpython code
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)