82
82
}
83
83
# Cube information
84
84
product_line_dict = {}
85
+ svd_dict = {} # 'name':'svd file'
85
86
86
87
# format
87
88
# Peripheral
@@ -1606,6 +1607,27 @@ def search_product_line(valueline):
1606
1607
return product_line
1607
1608
1608
1609
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
+
1609
1631
def print_boards_entry ():
1610
1632
boards_entry_template = j2_env .get_template (boards_entry_filename )
1611
1633
@@ -1651,6 +1673,7 @@ def print_boards_entry():
1651
1673
"board" : gen_name .upper (),
1652
1674
"flash" : mcu_flash [index ],
1653
1675
"ram" : mcu_ram [index ],
1676
+ "svd" : search_svdfile (f"STM32{ gen_name } " ),
1654
1677
}
1655
1678
)
1656
1679
# Search product line for last flash size
@@ -1668,6 +1691,7 @@ def print_boards_entry():
1668
1691
"board" : mcu_refname .replace ("STM32" , "" ).upper (),
1669
1692
"flash" : mcu_flash [0 ],
1670
1693
"ram" : mcu_ram [0 ],
1694
+ "svd" : search_svdfile (mcu_refname ),
1671
1695
}
1672
1696
)
1673
1697
product_line = search_product_line (package_regex .sub (r"" , valueline ))
@@ -2389,6 +2413,7 @@ def checkConfig():
2389
2413
global cubemxdir
2390
2414
global repo_local_path
2391
2415
global repo_path
2416
+ global cubeclt_mcu_path
2392
2417
default_cubemxdir ()
2393
2418
if config_filename .is_file ():
2394
2419
try :
@@ -2410,6 +2435,21 @@ def checkConfig():
2410
2435
defaultConfig (config_filename , path_config )
2411
2436
else :
2412
2437
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 )
2413
2453
except IOError :
2414
2454
print (f"Failed to open { config_filename } " )
2415
2455
else :
@@ -2484,6 +2524,7 @@ def manage_repo():
2484
2524
generic_clock_filename = "generic_clock.c"
2485
2525
repo_local_path = script_path / "repo"
2486
2526
cubemxdir = Path ()
2527
+ cubeclt_mcu_path = Path ()
2487
2528
gh_url = "https://github.com/STMicroelectronics/STM32_open_pin_data"
2488
2529
repo_name = gh_url .rsplit ("/" , 1 )[- 1 ]
2489
2530
repo_path = repo_local_path / repo_name
@@ -2580,6 +2621,7 @@ def manage_repo():
2580
2621
PackDescription_item = xml_file .getElementsByTagName ("PackDescription" )
2581
2622
for item in PackDescription_item :
2582
2623
db_release = item .attributes ["Release" ].value
2624
+ xml_file .unlink ()
2583
2625
2584
2626
# Process DB release
2585
2627
release_regex = r".*(\d+\.\d+\.\d+)$"
@@ -2588,6 +2630,14 @@ def manage_repo():
2588
2630
db_release = release_match .group (1 )
2589
2631
print (f"CubeMX DB release { db_release } \n " )
2590
2632
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
+
2591
2641
if args .family :
2592
2642
filtered_family = args .family .upper ()
2593
2643
# Get all xml files
0 commit comments