61
61
mcu_refname = ""
62
62
mcu_flash = []
63
63
mcu_ram = []
64
- legacy_hal = {"CAN" : ["F0" , "F1" , "F2" , "F3" , "F4" , "F7" , "L4" ], "ETH" : ["F4" , "F7" , "H7" ]}
64
+ legacy_hal = {
65
+ "CAN" : ["F0" , "F1" , "F2" , "F3" , "F4" , "F7" , "L4" ],
66
+ "ETH" : ["F4" , "F7" , "H7" ],
67
+ }
68
+ openocd_list = {
69
+ "STM32F0" : "stm32f0x" ,
70
+ "STM32F1" : "stm32f1x" ,
71
+ "STM32F2" : "stm32f2x" ,
72
+ "STM32F3" : "stm32f3x" ,
73
+ "STM32F4" : "stm32f4x" ,
74
+ "STM32F7" : "stm32f7x" ,
75
+ "STM32G0" : "stm32g0x" ,
76
+ "STM32G4" : "stm32g4x" ,
77
+ "STM32H7" : "stm32h7x" ,
78
+ "STM32L0" : "stm32l0" ,
79
+ "STM32L1" : "stm32l1" ,
80
+ "STM32L4" : "stm32l4x" ,
81
+ "STM32L5" : "stm32l5x" ,
82
+ "STM32MP13" : "stm32mp13x" ,
83
+ "STM32MP15" : "stm32mp15x" ,
84
+ "STM32U5" : "stm32u5x" ,
85
+ "STM32WB" : "stm32wbx" ,
86
+ "STM32WL" : "stm32wlx" ,
87
+ }
65
88
# Cube information
66
89
product_line_dict = {}
67
90
@@ -1547,6 +1570,7 @@ def print_boards_entry():
1547
1570
mcu_dir = mcu_refname .replace ("STM32" , "" ),
1548
1571
mcu_family_dir = mcu_family_dir ,
1549
1572
product_line = product_line ,
1573
+ openocd_filename = openocd_filename ,
1550
1574
)
1551
1575
)
1552
1576
return generic_list
@@ -1561,6 +1585,15 @@ def print_general_clock(generic_list):
1561
1585
)
1562
1586
1563
1587
1588
+ def print_openocd (openocd_target ):
1589
+ openocd_template = j2_env .get_template (openocd_filename )
1590
+ openocd_file .write (
1591
+ openocd_template .render (
1592
+ openocd_target = openocd_target ,
1593
+ )
1594
+ )
1595
+
1596
+
1564
1597
# List management
1565
1598
tokenize = re .compile (r"(\d+)|(\D+)" ).findall
1566
1599
@@ -2289,6 +2322,7 @@ def manage_repo():
2289
2322
templates_dir = cur_dir / "templates"
2290
2323
mcu_family_dir = ""
2291
2324
filtered_family = ""
2325
+ openocd_target = ""
2292
2326
# filtered_mcu_file = ""
2293
2327
periph_c_filename = "PeripheralPins.c"
2294
2328
pinvar_h_filename = "PinNamesVar.h"
@@ -2297,6 +2331,7 @@ def manage_repo():
2297
2331
variant_cpp_filename = "variant_generic.cpp"
2298
2332
boards_entry_filename = "boards_entry.txt"
2299
2333
generic_clock_filename = "generic_clock.c"
2334
+ openocd_filename = "openocd.cfg"
2300
2335
repo_local_path = cur_dir / "repo"
2301
2336
cubemxdir = Path ()
2302
2337
gh_url = "https://github.com/STMicroelectronics/STM32_open_pin_data"
@@ -2315,8 +2350,9 @@ def manage_repo():
2315
2350
- { pinvar_h_filename } ,
2316
2351
- { variant_cpp_filename } ,
2317
2352
- { variant_h_filename } ,
2318
- - { boards_entry_filename }
2319
- - { generic_clock_filename }
2353
+ - { boards_entry_filename } ,
2354
+ - { generic_clock_filename } ,
2355
+ - { openocd_filename }
2320
2356
for all xml files description available in STM32CubeMX internal database.
2321
2357
Internal database path must be defined in { config_filename } .
2322
2358
It can be the one from STM32CubeMX directory if defined:
@@ -2462,6 +2498,23 @@ def manage_repo():
2462
2498
quit ()
2463
2499
xml_gpio = parse (str (dirIP / f"GPIO-{ gpiofile } _Modes.xml" ))
2464
2500
2501
+ if mcu_family == "STM32MP1" :
2502
+ if mcu_refname .startswith ("STM32MP13" ):
2503
+ openocd_target = openocd_list .get ("STM32MP13" )
2504
+ elif mcu_refname .startswith ("STM32MP15" ):
2505
+ openocd_target = openocd_list .get ("STM32MP15" )
2506
+ else :
2507
+ openocd_target = openocd_list .get (mcu_family , "" )
2508
+ if openocd_target == "" :
2509
+ print (
2510
+ """
2511
+ --> Could not find appropriate openocd target for this family.
2512
+ - If a script for this family is available in openocd/scripts/target
2513
+ please add it to the openocd_list
2514
+ - Please also update boards.txt to add the openocdscript variable for this
2515
+ family: {new_family}.build.openocdscript=openocd.cfg
2516
+ """
2517
+ )
2465
2518
mcu_family_dir = mcu_family + "xx"
2466
2519
out_temp_path = tmp_dir / mcu_family_dir / mcu_file .stem .replace ("STM32" , "" )
2467
2520
periph_c_filepath = out_temp_path / periph_c_filename
@@ -2470,6 +2523,7 @@ def manage_repo():
2470
2523
variant_h_filepath = out_temp_path / variant_h_filename
2471
2524
boards_entry_filepath = out_temp_path / boards_entry_filename
2472
2525
generic_clock_filepath = out_temp_path / generic_clock_filename
2526
+ openocd_filepath = out_temp_path / openocd_filename
2473
2527
out_temp_path .mkdir (parents = True , exist_ok = True )
2474
2528
2475
2529
# open output file
@@ -2479,11 +2533,13 @@ def manage_repo():
2479
2533
variant_h_file = open (variant_h_filepath , "w" , newline = "\n " )
2480
2534
boards_entry_file = open (boards_entry_filepath , "w" , newline = "\n " )
2481
2535
generic_clock_file = open (generic_clock_filepath , "w" , newline = "\n " )
2536
+ openocd_file = open (openocd_filepath , "w" , newline = "\n " )
2482
2537
parse_pins ()
2483
2538
manage_af_and_alternate ()
2484
2539
2485
2540
generic_list = print_boards_entry ()
2486
2541
print_general_clock (generic_list )
2542
+ print_openocd (openocd_target )
2487
2543
print_peripheral ()
2488
2544
alt_syswkup_list = print_pinamevar ()
2489
2545
print_variant (generic_list , alt_syswkup_list )
@@ -2509,6 +2565,7 @@ def manage_repo():
2509
2565
variant_cpp_file .close ()
2510
2566
boards_entry_file .close ()
2511
2567
generic_clock_file .close ()
2568
+ openocd_file .close ()
2512
2569
xml_mcu .unlink ()
2513
2570
xml_gpio .unlink ()
2514
2571
0 commit comments