8282}
8383# Cube information
8484product_line_dict = {}
85+ svd_dict = {} # 'name':'svd file'
8586
8687# format
8788# Peripheral
@@ -1606,6 +1607,27 @@ def search_product_line(valueline):
16061607 return product_line
16071608
16081609
1610+ def parse_stm32targets ():
1611+ global svd_dict
1612+ xml_stm32targets = parse (str (stm32targets_file ))
1613+ mcu_nodes = xml_stm32targets .getElementsByTagName ("mcu" )
1614+ for mcu_node in mcu_nodes :
1615+ mcu_node_name = mcu_node .getElementsByTagName ("name" )[0 ].firstChild .data
1616+ cpus_node_name = mcu_node .getElementsByTagName ("cpus" )
1617+ cpu_node_name = cpus_node_name [0 ].getElementsByTagName ("cpu" )
1618+ svd_node = cpu_node_name [0 ].getElementsByTagName ("svd" )
1619+ svd_file = svd_node [0 ].getElementsByTagName ("name" )[0 ].firstChild .data
1620+ svd_dict [mcu_node_name ] = svd_file
1621+ xml_stm32targets .unlink ()
1622+
1623+
1624+ def search_svdfile (mcu_name ):
1625+ svd_file = ""
1626+ if mcu_name in svd_dict :
1627+ svd_file = svd_dict [mcu_name ]
1628+ return svd_file
1629+
1630+
16091631def print_boards_entry ():
16101632 boards_entry_template = j2_env .get_template (boards_entry_filename )
16111633
@@ -1651,6 +1673,7 @@ def print_boards_entry():
16511673 "board" : gen_name .upper (),
16521674 "flash" : mcu_flash [index ],
16531675 "ram" : mcu_ram [index ],
1676+ "svd" : search_svdfile (f"STM32{ gen_name } " ),
16541677 }
16551678 )
16561679 # Search product line for last flash size
@@ -1668,6 +1691,7 @@ def print_boards_entry():
16681691 "board" : mcu_refname .replace ("STM32" , "" ).upper (),
16691692 "flash" : mcu_flash [0 ],
16701693 "ram" : mcu_ram [0 ],
1694+ "svd" : search_svdfile (mcu_refname ),
16711695 }
16721696 )
16731697 product_line = search_product_line (package_regex .sub (r"" , valueline ))
@@ -2389,6 +2413,7 @@ def checkConfig():
23892413 global cubemxdir
23902414 global repo_local_path
23912415 global repo_path
2416+ global cubeclt_mcu_path
23922417 default_cubemxdir ()
23932418 if config_filename .is_file ():
23942419 try :
@@ -2410,6 +2435,21 @@ def checkConfig():
24102435 defaultConfig (config_filename , path_config )
24112436 else :
24122437 cubemxdir = Path (path_config ["CUBEMX_DIRECTORY" ])
2438+ if "STM32CUBECLT_PATH" not in path_config :
2439+ path_config ["STM32CUBECLT_PATH" ] = str (
2440+ "Path to STM32CubeCLT installation directory"
2441+ )
2442+ defaultConfig (config_filename , path_config )
2443+ else :
2444+ cubeclt_path = Path (path_config ["STM32CUBECLT_PATH" ])
2445+ if not cubeclt_path .is_dir ():
2446+ print (f"{ cubeclt_path } does not exist!" )
2447+ exit (1 )
2448+ else :
2449+ cubeclt_mcu_path = cubeclt_path / "STM32target-mcu"
2450+ if not cubeclt_mcu_path .is_dir ():
2451+ print (f"{ cubeclt_mcu_path } does not exist!" )
2452+ exit (1 )
24132453 except IOError :
24142454 print (f"Failed to open { config_filename } " )
24152455 else :
@@ -2484,6 +2524,7 @@ def manage_repo():
24842524generic_clock_filename = "generic_clock.c"
24852525repo_local_path = script_path / "repo"
24862526cubemxdir = Path ()
2527+ cubeclt_mcu_path = Path ()
24872528gh_url = "https://github.com/STMicroelectronics/STM32_open_pin_data"
24882529repo_name = gh_url .rsplit ("/" , 1 )[- 1 ]
24892530repo_path = repo_local_path / repo_name
@@ -2580,6 +2621,7 @@ def manage_repo():
25802621 PackDescription_item = xml_file .getElementsByTagName ("PackDescription" )
25812622 for item in PackDescription_item :
25822623 db_release = item .attributes ["Release" ].value
2624+ xml_file .unlink ()
25832625
25842626# Process DB release
25852627release_regex = r".*(\d+\.\d+\.\d+)$"
@@ -2588,6 +2630,14 @@ def manage_repo():
25882630 db_release = release_match .group (1 )
25892631print (f"CubeMX DB release { db_release } \n " )
25902632
2633+ # Open stm32targets.xml to get svd file
2634+ stm32targets_file = cubeclt_mcu_path / "stm32targets.xml"
2635+ if stm32targets_file .is_file ():
2636+ parse_stm32targets ()
2637+ else :
2638+ print (f"{ stm32targets_file } does not exits!" )
2639+ exit (1 )
2640+
25912641if args .family :
25922642 filtered_family = args .family .upper ()
25932643# Get all xml files
0 commit comments