@@ -1647,12 +1647,36 @@ def print_variant(generic_list, alt_syswkup_list):
16471647def search_product_line (valueline :str ,extra :str )-> str :
16481648product_line = ""
16491649product_line_list = product_line_dict [mcu_family ]
1650- if not valueline .startswith ("STM32MP1" ):
1650+ if valueline .startswith ("STM32MP1" ):
1651+ # previous
1652+ # Unfortunately, MP1 does not follows the same naming rules
1653+ for pline in product_line_dict [mcu_family ]:
1654+ vline = valueline
1655+ product_line = pline
1656+ # Remove the 'x' character from pline and
1657+ # the one at same index in the vline
1658+ while 1 :
1659+ idx = pline .find ("x" )
1660+ if idx > 0 :
1661+ pline = pline .replace ("x" ,"" ,1 )
1662+ if "STM32MP15xx" != vline :
1663+ vline = vline [:idx ]+ vline [idx + 1 :]
1664+ else :
1665+ break
1666+ if pline >= vline and pline [:10 ]== vline [:10 ]:
1667+ break
1668+ else :
1669+ # In case of CMSIS device does not exist
1670+ product_line = "STM32MP15xx"
1671+ elif valueline .startswith ("STM32WL3" ):
16511672for idx_pline ,pline in enumerate (product_line_list ):
16521673vline = valueline
1674+ # Add an 'x' at the end to match the length
1675+ # as startup file contains only one 'x' at the end
1676+ # STM32WL3xx -> STM32WL30K8
1677+ # STM32WL3Rx -> STM32WL3RK8
16531678product_line = pline
1654- if vline .startswith ("STM32WB0" )or vline .startswith ("STM32WL3" ):
1655- pline = pline + "xx"
1679+ pline = pline + "x"
16561680# Remove the 'x' character from pline and
16571681# the one at same index in the vline
16581682while 1 :
@@ -1662,7 +1686,8 @@ def search_product_line(valueline: str, extra: str) -> str:
16621686vline = vline [:idx ]+ vline [idx + 1 :]
16631687else :
16641688break
1665- if pline >= vline :
1689+ # Exact match or generic name
1690+ if pline == vline or product_line == "STM32WL3xx" :
16661691if (
16671692extra
16681693and len (product_line_list )> idx_pline + 1
@@ -1674,27 +1699,34 @@ def search_product_line(valueline: str, extra: str) -> str:
16741699else :
16751700# In case of CMSIS device does not exist
16761701product_line = ""
1702+ product_line = product_line .upper ()
16771703else :
1678- # previous
1679- # Unfortunately, MP1 does not follows the same naming rules
1680- for pline in product_line_dict [mcu_family ]:
1704+ for idx_pline ,pline in enumerate (product_line_list ):
16811705vline = valueline
16821706product_line = pline
1707+ if vline .startswith ("STM32WB0" ):
1708+ pline = pline + "xx"
16831709# Remove the 'x' character from pline and
16841710# the one at same index in the vline
16851711while 1 :
16861712idx = pline .find ("x" )
16871713if idx > 0 :
16881714pline = pline .replace ("x" ,"" ,1 )
1689- if "STM32MP15xx" != vline :
1690- vline = vline [:idx ]+ vline [idx + 1 :]
1715+ vline = vline [:idx ]+ vline [idx + 1 :]
16911716else :
16921717break
1693- if pline >= vline and pline [:10 ]== vline [:10 ]:
1718+ if pline >= vline :
1719+ if (
1720+ extra
1721+ and len (product_line_list )> idx_pline + 1
1722+ and product_line_list [idx_pline + 1 ]== (product_line + extra )
1723+ ):
1724+ # Look for the next product line if contains the extra
1725+ product_line = product_line_list [idx_pline + 1 ]
16941726break
16951727else :
16961728# In case of CMSIS device does not exist
1697- product_line = "STM32MP15xx "
1729+ product_line = ""
16981730return product_line
16991731
17001732