upsilon/gateware/csr2mp.py

30 lines
807 B
Python
Raw Normal View History

2023-06-21 18:47:52 -04:00
#!/usr/bin/python3
# Copyright 2023 (C) Peter McGoron
#
# This file is a part of Upsilon, a free and open source software project.
# For license terms, refer to the files in `doc/copying` in the Upsilon
# source distribution.
#######################################################################
#
# This file generates memory locations
2023-06-21 18:47:52 -04:00
#
# TODO: Devicetree?
2023-06-26 15:49:20 -04:00
import collections
2023-06-23 18:15:53 -04:00
import argparse
2023-06-21 18:47:52 -04:00
import json
import sys
2023-06-28 18:49:26 -04:00
import mmio_descr
2023-06-23 18:15:53 -04:00
with open(sys.argv[1], 'rt') as f:
j = json.load(f)
2023-06-23 18:15:53 -04:00
print("from micropython import const")
2023-06-21 18:47:52 -04:00
for key in j["csr_registers"]:
2024-02-21 23:58:59 -05:00
if key.startswith("pico0"):
print(f'{key} = const({j["csr_registers"][key]["addr"]})')
2023-06-21 18:47:52 -04:00
2024-02-21 23:58:59 -05:00
print(f'pico0_ram = const({j["memories"]["pico0_ram"]["base"]})')
print(f'pico0_dbg_reg = const({j["memories"]["pico0_dbg_reg"]["base"]})')