Skip to content

Commit 6897e8d

Browse files
committed
[stm32variant] Use Mcu description
This allows to harden the code as some mcu file name is not enough to define the family, ex: STM32GBK1CBTx is a STM32G4 Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 055c30f commit 6897e8d

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

CI/utils/stm32variant.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
gpiofile = ""
4848
tim_inst_list = [] # TIMx instance
4949
usb_inst = {"usb": "", "otg_fs": "", "otg_hs": ""}
50+
mcu_family = ""
5051

5152
# format
5253
# Peripheral
@@ -60,6 +61,7 @@
6061
# mcu file parsing
6162
def parse_IP_file():
6263
global gpiofile
64+
global mcu_family
6365
tim_regex = r"^(TIM\d+)$"
6466
usb_regex = r"^(USB(?!PD|_HOST|_DEVICE).*)$"
6567
gpiofile = ""
@@ -68,6 +70,9 @@ def parse_IP_file():
6870
usb_inst["otg_fs"] = ""
6971
usb_inst["otg_hs"] = ""
7072

73+
mcu_node = xml_mcu.getElementsByTagName("Mcu")[0]
74+
mcu_family = mcu_node.attributes["Family"].value
75+
7176
itemlist = xml_mcu.getElementsByTagName("IP")
7277
for s in itemlist:
7378
inst = re.match(tim_regex, s.attributes["InstanceName"].value)
@@ -1679,10 +1684,16 @@ def manage_repo():
16791684

16801685
for mcu_file in mcu_list:
16811686
print("Generating files for '{}'...".format(mcu_file.name))
1682-
if "MP1" in mcu_file.name:
1683-
mcu_dir = "STM32MP1xx"
1684-
else:
1685-
mcu_dir = mcu_file.name[:7] + "xx"
1687+
1688+
# Open input file
1689+
xml_mcu = parse(str(mcu_file))
1690+
parse_IP_file()
1691+
if not gpiofile:
1692+
print("Could not find GPIO file")
1693+
quit()
1694+
xml_gpio = parse(str(dirIP / ("GPIO-" + gpiofile + "_Modes.xml")))
1695+
1696+
mcu_dir = mcu_family + "xx"
16861697
out_path = root_dir / "variants" / mcu_dir / mcu_file.stem
16871698
periph_c_filepath = out_path / periph_c_filename
16881699
pinvar_h_filepath = out_path / pinvar_h_filename
@@ -1705,14 +1716,6 @@ def manage_repo():
17051716
variant_h_filepath.unlink()
17061717
variant_h_file = open(variant_h_filepath, "w", newline="\n")
17071718

1708-
# open input file
1709-
xml_mcu = parse(str(mcu_file))
1710-
parse_IP_file()
1711-
if not gpiofile:
1712-
print("Could not find GPIO file")
1713-
quit()
1714-
xml_gpio = parse(str(dirIP / ("GPIO-" + gpiofile + "_Modes.xml")))
1715-
17161719
parse_pins()
17171720
sort_my_lists()
17181721
manage_alternate()

0 commit comments

Comments
 (0)