Skip to content

Commit 3910fbd

Browse files
authored
Merge pull request #3089 from fpistm/fix_variants
fix(variants): pin mapping issues
2 parents cf59c7d + ea98e3c commit 3910fbd

502 files changed

Lines changed: 32422 additions & 2922 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CI/update/stm32variant.py‎

Lines changed: 85 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@
5959
ospidata6_list = [] # ['PIN','name','OSPIDATA6', ['af']]
6060
ospidata7_list = [] # ['PIN','name','OSPIDATA7', ['af']]
6161
xspisclk_list = [] # ['PIN','name','XSPISCLK', ['af']]
62-
xspissel_list = [] # ['PIN','name','XSPISSEL', ['af']]
62+
xspincs1_list = [] # ['PIN','name','XSPINCS1', ['af']]
63+
xspincs2_list = [] # ['PIN','name','XSPINCS2', ['af']]
64+
xspinclk_list = [] # ['PIN','name','XSPINCLK', ['af']]
65+
xspidqs_list = [] # ['PIN','name','XSPIDQS', ['af']]
6366
syswkup_list = [] # ['PIN','name','SYSWKUP']
6467
usb_list = [] # ['PIN','name','USB', ['af']]
6568
usb_otgfs_list = [] # ['PIN','name','USB', ['af']]
@@ -222,12 +225,8 @@ def parse_mcu_file():
222225
ignored_stm32_list.append(mcu_family)
223226
xml_mcu.unlink()
224227
return False
228+
225229
mcu_refname = mcu_node.attributes["RefName"].value
226-
# Skip STM32H5E/F series
227-
if mcu_refname.startswith("STM32H5E") or mcu_refname.startswith("STM32H5F"):
228-
print(f"Warning: {mcu_refname} series is not supported yet. Skipping.")
229-
xml_mcu.unlink()
230-
return False
231230
core_node = mcu_node.getElementsByTagName("Core")
232231
for f in core_node:
233232
# Strip last non digit characters and extract the number
@@ -610,10 +609,16 @@ def store_xspi(pin, name, signal):
610609
ospidata6_list.append([pin, name, signal])
611610
elif "_IO7" in signal:
612611
ospidata7_list.append([pin, name, signal])
612+
elif "_NCLK" in signal:
613+
xspinclk_list.append([pin, name, signal])
614+
elif "_DQS" in signal:
615+
xspidqs_list.append([pin, name, signal])
616+
elif signal.endswith(("_NCS1", "_NCS", "_BK1_NCS")):
617+
xspincs1_list.append([pin, name, signal])
618+
elif signal.endswith(("_NCS2", "_BK2_NCS")):
619+
xspincs2_list.append([pin, name, signal])
613620
elif "_CLK" in signal:
614621
xspisclk_list.append([pin, name, signal])
615-
elif "_NCS" in signal:
616-
xspissel_list.append([pin, name, signal])
617622

618623

619624
# Store SYS pins
@@ -1001,9 +1006,17 @@ def can_pinmap(lst):
10011006

10021007
def eth_pinmap():
10031008
eth_pins_list = []
1009+
seen_pins = {}
10041010
wpin = [0]
10051011
inst = "ETH"
10061012
for p in eth_list:
1013+
pin = re.sub(r"_ALT\d+$", "", p[0])
1014+
key = (pin, p[1], p[3])
1015+
if key in seen_pins:
1016+
entry = eth_pins_list[seen_pins[key]]
1017+
if p[2] not in entry["cmt"].split(" | "):
1018+
entry["cmt"] += " | " + p[2]
1019+
continue
10071020
# Note: Some pins are duplicated with only a different signal
10081021
# Now considered as an ALTX pins even ifsame AF
10091022
wpin.append(len(p[0]))
@@ -1017,6 +1030,7 @@ def eth_pinmap():
10171030
"cmt": p[2],
10181031
}
10191032
)
1033+
seen_pins[key] = len(eth_pins_list) - 1
10201034
return dict(
10211035
name="ETHERNET",
10221036
hal=(
@@ -1038,11 +1052,14 @@ def xspi_pinmap(lst):
10381052
wpin = [0]
10391053
name = "QUADSPI"
10401054
hal = "QSPI"
1041-
ospi_regex = r"OCTOSPI(?:M_P)?(\d).*"
1055+
xspi_regex = r"(OCTOSPI|XSPI)(?:M_P)?(\d).*"
10421056

10431057
if xspidata0_list and "OCTOSPI" in xspidata0_list[0][2]:
10441058
name = "OCTOSPI"
10451059
hal = "OSPI"
1060+
elif xspidata0_list and "XSPI" in xspidata0_list[0][2]:
1061+
name = "XSPI"
1062+
hal = "XSPI"
10461063
if lst == xspidata0_list:
10471064
aname = f"{name}_DATA0"
10481065
elif lst == xspidata1_list:
@@ -1061,16 +1078,21 @@ def xspi_pinmap(lst):
10611078
aname = f"{name}_DATA7"
10621079
elif lst == xspisclk_list:
10631080
aname = f"{name}_SCLK"
1081+
elif lst == xspinclk_list:
1082+
aname = f"{name}_NCLK"
1083+
elif lst == xspidqs_list:
1084+
aname = f"{name}_DQS"
1085+
elif lst == xspincs2_list:
1086+
aname = f"{name}_NCS2"
1087+
elif lst == xspincs1_list:
1088+
aname = f"{name}_NCS1"
10641089
else:
1065-
aname = f"{name}_SSEL"
1090+
aname = f"{name}_NCS1"
10661091
for p in lst:
10671092
# 2nd element is the XXXXSPI_YYYY signal
1068-
instm = re.match(ospi_regex, p[2])
1093+
instm = re.match(xspi_regex, p[2])
10691094
if instm:
1070-
if "1" in instm.group(1):
1071-
inst = "OCTOSPI1"
1072-
elif "2" in instm.group(1):
1073-
inst = "OCTOSPI2"
1095+
inst = f"{instm.group(1)}{instm.group(2)}"
10741096
else:
10751097
inst = "QUADSPI"
10761098
winst.append(len(inst))
@@ -1099,33 +1121,27 @@ def xspi_pinmap(lst):
10991121
def usb_pinmap(lst):
11001122
usb_pins_list = []
11011123
wpin = [0]
1102-
use_hs_in_fs = False
1103-
nb_loop = 1
11041124

11051125
if lst == usb_otgfs_list:
11061126
inst = usb_inst["otg_fs"]
1127+
pin_groups = [(lst, 0)]
11071128
elif lst == usb_otghs_list:
11081129
inst = usb_inst["otg_hs"]
1109-
nb_loop = 2
1130+
sof_pins = [p for p in lst if "SOF" in p[2]]
1131+
fs_pins = [p for p in lst if "SOF" not in p[2] and "ULPI" not in p[2]]
1132+
ulpi_pins = [p for p in lst if "ULPI" in p[2]]
1133+
pin_groups = [(sof_pins, 0)]
1134+
if fs_pins:
1135+
pin_groups.append((fs_pins, 1))
1136+
if ulpi_pins:
1137+
pin_groups.append((ulpi_pins, 2 if fs_pins else 0))
11101138
else:
11111139
inst = usb_inst["usb"]
1112-
for nb in range(nb_loop):
1113-
for p in lst:
1114-
hsinfs = 0
1115-
if lst == usb_otghs_list:
1116-
hsinfs = 3
1117-
if nb == 0:
1118-
if "ULPI" in p[2]:
1119-
continue
1120-
elif not use_hs_in_fs:
1121-
hsinfs = 1
1122-
use_hs_in_fs = True
1123-
else:
1124-
if "ULPI" not in p[2]:
1125-
continue
1126-
elif use_hs_in_fs:
1127-
hsinfs = 2
1128-
use_hs_in_fs = False
1140+
pin_groups = [(lst, 0)]
1141+
1142+
for pins, group_marker in pin_groups:
1143+
for pin_index, p in enumerate(pins):
1144+
hsinfs = group_marker if pin_index == 0 else 3
11291145

11301146
# 2nd element is the USB_XXXX signal
11311147
if not p[2].startswith("USB_D") and "VBUS" not in p[2]:
@@ -1159,6 +1175,7 @@ def usb_pinmap(lst):
11591175
hal=["PCD", "HCD"],
11601176
aname=inst,
11611177
data="",
1178+
hsinfs=any(marker == 1 for _, marker in pin_groups),
11621179
wpin=max(wpin) + 1,
11631180
winst=len(inst) + 1,
11641181
list=usb_pins_list,
@@ -1242,6 +1259,21 @@ def print_peripheral():
12421259
else:
12431260
usb_pinmmap = [usb_pinmap(usb_otghs_list)]
12441261

1262+
xspi_pinmaps = (
1263+
xspi_pinmap(xspidata0_list),
1264+
xspi_pinmap(xspidata1_list),
1265+
xspi_pinmap(xspidata2_list),
1266+
xspi_pinmap(xspidata3_list),
1267+
xspi_pinmap(ospidata4_list),
1268+
xspi_pinmap(ospidata5_list),
1269+
xspi_pinmap(ospidata6_list),
1270+
xspi_pinmap(ospidata7_list),
1271+
xspi_pinmap(xspisclk_list),
1272+
xspi_pinmap(xspincs1_list),
1273+
xspi_pinmap(xspincs2_list),
1274+
)
1275+
xspi_pinmaps += (xspi_pinmap(xspinclk_list), xspi_pinmap(xspidqs_list))
1276+
12451277
periph_c_file.write(
12461278
periph_c_template.render(
12471279
year=year,
@@ -1267,18 +1299,7 @@ def print_peripheral():
12671299
),
12681300
(can_pinmap(canrd_list), can_pinmap(cantd_list)),
12691301
[eth_pinmap()],
1270-
(
1271-
xspi_pinmap(xspidata0_list),
1272-
xspi_pinmap(xspidata1_list),
1273-
xspi_pinmap(xspidata2_list),
1274-
xspi_pinmap(xspidata3_list),
1275-
xspi_pinmap(ospidata4_list),
1276-
xspi_pinmap(ospidata5_list),
1277-
xspi_pinmap(ospidata6_list),
1278-
xspi_pinmap(ospidata7_list),
1279-
xspi_pinmap(xspisclk_list),
1280-
xspi_pinmap(xspissel_list),
1281-
),
1302+
xspi_pinmaps,
12821303
usb_pinmmap,
12831304
(
12841305
sdx_pinmap(sdxcmd_list),
@@ -1984,7 +2005,10 @@ def sort_my_lists():
19842005
ospidata6_list.sort(key=natural_sortkey)
19852006
ospidata7_list.sort(key=natural_sortkey)
19862007
xspisclk_list.sort(key=natural_sortkey)
1987-
xspissel_list.sort(key=natural_sortkey)
2008+
xspincs1_list.sort(key=natural_sortkey)
2009+
xspincs2_list.sort(key=natural_sortkey)
2010+
xspinclk_list.sort(key=natural_sortkey)
2011+
xspidqs_list.sort(key=natural_sortkey)
19882012
syswkup_list.sort(key=natural_sortkey2)
19892013
usb_list.sort(key=natural_sortkey)
19902014
usb_otgfs_list.sort(key=natural_sortkey)
@@ -2037,7 +2061,10 @@ def clean_all_lists():
20372061
del ospidata6_list[:]
20382062
del ospidata7_list[:]
20392063
del xspisclk_list[:]
2040-
del xspissel_list[:]
2064+
del xspincs1_list[:]
2065+
del xspincs2_list[:]
2066+
del xspinclk_list[:]
2067+
del xspidqs_list[:]
20412068
del syswkup_list[:]
20422069
del usb_list[:]
20432070
del usb_otgfs_list[:]
@@ -2085,7 +2112,10 @@ def manage_af_and_alternate():
20852112
add_af(ospidata6_list)
20862113
add_af(ospidata7_list)
20872114
add_af(xspisclk_list)
2088-
add_af(xspissel_list)
2115+
add_af(xspincs1_list)
2116+
add_af(xspincs2_list)
2117+
add_af(xspinclk_list)
2118+
add_af(xspidqs_list)
20892119
add_af(usb_list)
20902120
add_af(usb_otgfs_list)
20912121
add_af(usb_otghs_list)
@@ -2133,7 +2163,10 @@ def manage_af_and_alternate():
21332163
update_alternate(ospidata6_list)
21342164
update_alternate(ospidata7_list)
21352165
update_alternate(xspisclk_list)
2136-
update_alternate(xspissel_list)
2166+
update_alternate(xspincs1_list)
2167+
update_alternate(xspincs2_list)
2168+
update_alternate(xspinclk_list)
2169+
update_alternate(xspidqs_list)
21372170
update_alternate(syswkup_list)
21382171
update_alternate(usb_list)
21392172
update_alternate(usb_otgfs_list)
@@ -2249,7 +2282,7 @@ def parse_pins():
22492282
elif re.match("^(LPU|US|U)ART", sig) is not None:
22502283
store_uart(pin, name, sig)
22512284
elif "SPI" in sig:
2252-
if "QUADSPI" in sig or "OCTOSPI" in sig:
2285+
if "QUADSPI" in sig or "OCTOSPI" in sig or "XSPI" in sig:
22532286
store_xspi(pin, name, sig)
22542287
else:
22552288
store_spi(pin, name, sig)

0 commit comments

Comments
 (0)