Skip to content

Commit 5b43961

Browse files
committed
STM32: move STM32_gen_PeripheralPins.py to tools/targets
1 parent 959ecf9 commit 5b43961

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

targets/TARGET_STM/tools/genpinmap_mbed.py renamed to tools/targets/STM32_gen_PeripheralPins.py

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from xml.dom.minidom import parse, Node
1010
from argparse import RawTextHelpFormatter
1111

12-
GENPINMAP_VERSION = "1.1"
12+
GENPINMAP_VERSION = "1.2"
1313

1414
ADD_DEVICE_IFDEF = 0
1515
ADD_QSPI_FEATURE = 0
@@ -65,6 +65,7 @@
6565
"NUCLEO_F746ZG":"TIM5",
6666
"NUCLEO_F767ZI":"TIM5",
6767
"NUCLEO_F722ZE":"TIM5",
68+
"NUCLEO_H743ZI":"TIM5",
6869
"NUCLEO_L053R8":"TIM21",
6970
"NUCLEO_L073RZ":"TIM21",
7071
"NUCLEO_L031K6":"TIM21",
@@ -312,7 +313,6 @@ def print_header():
312313
*******************************************************************************
313314
*
314315
* Automatically generated from %s
315-
* genpinmap script version %s
316316
*/
317317
318318
#include "PeripheralPins.h"
@@ -336,7 +336,7 @@ def print_header():
336336
//
337337
//==============================================================================
338338
339-
""" % (datetime.datetime.now().year, os.path.basename(input_file_name), GENPINMAP_VERSION))
339+
""" % (datetime.datetime.now().year, os.path.basename(input_file_name)))
340340
out_c_file.write( s )
341341

342342
s = ("""/* mbed Microcontroller Library
@@ -369,7 +369,6 @@ def print_header():
369369
*******************************************************************************
370370
*
371371
* Automatically generated from %s
372-
* genpinmap script version %s
373372
*/
374373
375374
#ifndef MBED_PINNAMES_H
@@ -391,7 +390,7 @@ def print_header():
391390
392391
typedef enum {
393392
394-
""" % (datetime.datetime.now().year, os.path.basename(input_file_name), GENPINMAP_VERSION))
393+
""" % (datetime.datetime.now().year, os.path.basename(input_file_name)))
395394
out_h_file.write( s )
396395

397396

@@ -992,8 +991,8 @@ def parse_BoardFile(fileName):
992991
except:
993992
pass
994993

995-
996994
# main
995+
print ("\nScript version %s" % GENPINMAP_VERSION)
997996
cur_dir = os.getcwd()
998997
PeripheralPins_c_filename = 'PeripheralPins.c'
999998
PinNames_h_filename = 'PinNames.h'
@@ -1006,16 +1005,16 @@ def parse_BoardFile(fileName):
10061005
config_file = open(config_filename, "w")
10071006
if sys.platform.startswith('win32'):
10081007
print("Platform is Windows")
1009-
cubemxdir = 'C:\\Program Files (x86)\\STMicroelectronics\\STM32Cube\\STM32CubeMX\\db'
1008+
cubemxdir = 'C:\\Program Files (x86)\\STMicroelectronics\\STM32Cube\\STM32CubeMX'
10101009
elif sys.platform.startswith('linux'):
10111010
print("Platform is Linux")
1012-
cubemxdir = os.getenv("HOME")+'/STM32CubeMX/db'
1011+
cubemxdir = os.getenv("HOME")+'/STM32CubeMX'
10131012
elif sys.platform.startswith('darwin'):
10141013
print("Platform is Mac OSX")
1015-
cubemxdir = '/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources/db'
1014+
cubemxdir = '/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources'
10161015
else:
10171016
print("Platform unknown")
1018-
cubemxdir = '<Set CubeMX install directory>/db'
1017+
cubemxdir = '<Set CubeMX install directory>'
10191018
config_file.write(json.dumps({"CUBEMX_DIRECTORY":cubemxdir}))
10201019
config_file.close()
10211020
exit(1)
@@ -1056,9 +1055,19 @@ def parse_BoardFile(fileName):
10561055
print ("\n ! ! ! please check the value you set for 'CUBEMX_DIRECTORY' in '%s' file" % config_filename)
10571056
quit()
10581057

1059-
cubemxdirMCU = os.path.join(cubemxdir, 'mcu')
1060-
cubemxdirIP = os.path.join(cubemxdir, 'mcu', 'IP')
1061-
cubemxdirBOARDS = os.path.join(cubemxdir, 'plugins', 'boardmanager', 'boards')
1058+
cubemxdirMCU = os.path.join(cubemxdir, 'db', 'mcu')
1059+
cubemxdirIP = os.path.join(cubemxdir, 'db', 'mcu', 'IP')
1060+
cubemxdirBOARDS = os.path.join(cubemxdir, 'db', 'plugins', 'boardmanager', 'boards')
1061+
1062+
version_file = os.path.join(cubemxdir, 'db', 'package.xml')
1063+
try:
1064+
xml_file = parse(version_file)
1065+
PackDescription_item = xml_file.getElementsByTagName('PackDescription')
1066+
for item in PackDescription_item:
1067+
CUBEMX_DB_VERSION = item.attributes['Release'].value
1068+
except:
1069+
CUBEMX_DB_VERSION = "NOT_FOUND"
1070+
print ("CubeMX DB version %s\n" % CUBEMX_DB_VERSION)
10621071

10631072
if args.list:
10641073
FileCount = 0
@@ -1090,7 +1099,7 @@ def parse_BoardFile(fileName):
10901099
else:
10911100
mcu_list = fnmatch.filter(os.listdir(cubemxdirMCU), '*%s*' % args.mcu)
10921101
if len(mcu_list) == 0:
1093-
print ("\n ! ! ! " + args.mcu + " file not found")
1102+
print (" ! ! ! " + args.mcu + " file not found")
10941103
print (" ! ! ! Check in " + cubemxdirMCU + " the correct name of this file")
10951104
print (" ! ! ! You may use double quotes for this file if it contains special characters")
10961105
quit()
@@ -1100,16 +1109,16 @@ def parse_BoardFile(fileName):
11001109
if not(os.path.isfile(board_file_name)):
11011110
board_list = fnmatch.filter(os.listdir(cubemxdirBOARDS), '*%s*AllConfig.ioc' % args.target)
11021111
if len(board_list) == 0:
1103-
print ("\n ! ! ! No file contains " + args.target)
1112+
print (" ! ! ! No file contains " + args.target)
11041113
print (" ! ! ! Check in " + cubemxdirBOARDS + " the correct filter to apply")
11051114
quit()
11061115
elif len(board_list) > 1:
1107-
print ("\n ! ! ! Multiple files contains " + args.target)
1108-
print (board_list)
1116+
print (" ! ! ! Multiple files contains " + args.target)
1117+
for board_elem in board_list: print (board_elem)
11091118
print (" ! ! ! Only the first one will be parsed\n")
11101119
board_file_name = os.path.join(cubemxdirBOARDS,board_list[0])
11111120
if not (os.path.isfile(board_file_name)):
1112-
print ("\n ! ! ! " + args.target + " file not found")
1121+
print (" ! ! ! " + args.target + " file not found")
11131122
print (" ! ! ! Check in " + cubemxdirBOARDS + " the correct name of this file")
11141123
print (" ! ! ! You may use double quotes for this file if it contains special characters")
11151124
quit()
@@ -1199,7 +1208,6 @@ def parse_BoardFile(fileName):
11991208
nb_pin = (len(io_list))
12001209
nb_connected_pin = len(PinLabel)
12011210
print (" * I/O pins found: %i connected: %i\n" % (nb_pin, nb_connected_pin))
1202-
# print ("done\n")
12031211
clean_all_lists()
12041212

12051213
out_c_file.close()

0 commit comments

Comments
 (0)