9
9
from xml .dom .minidom import parse , Node
10
10
from argparse import RawTextHelpFormatter
11
11
12
- GENPINMAP_VERSION = "1.1 "
12
+ GENPINMAP_VERSION = "1.2 "
13
13
14
14
ADD_DEVICE_IFDEF = 0
15
15
ADD_QSPI_FEATURE = 0
65
65
"NUCLEO_F746ZG" :"TIM5" ,
66
66
"NUCLEO_F767ZI" :"TIM5" ,
67
67
"NUCLEO_F722ZE" :"TIM5" ,
68
+ "NUCLEO_H743ZI" :"TIM5" ,
68
69
"NUCLEO_L053R8" :"TIM21" ,
69
70
"NUCLEO_L073RZ" :"TIM21" ,
70
71
"NUCLEO_L031K6" :"TIM21" ,
@@ -312,7 +313,6 @@ def print_header():
312
313
*******************************************************************************
313
314
*
314
315
* Automatically generated from %s
315
- * genpinmap script version %s
316
316
*/
317
317
318
318
#include "PeripheralPins.h"
@@ -336,7 +336,7 @@ def print_header():
336
336
//
337
337
//==============================================================================
338
338
339
- """ % (datetime .datetime .now ().year , os .path .basename (input_file_name ), GENPINMAP_VERSION ))
339
+ """ % (datetime .datetime .now ().year , os .path .basename (input_file_name )))
340
340
out_c_file .write ( s )
341
341
342
342
s = ("""/* mbed Microcontroller Library
@@ -369,7 +369,6 @@ def print_header():
369
369
*******************************************************************************
370
370
*
371
371
* Automatically generated from %s
372
- * genpinmap script version %s
373
372
*/
374
373
375
374
#ifndef MBED_PINNAMES_H
@@ -391,7 +390,7 @@ def print_header():
391
390
392
391
typedef enum {
393
392
394
- """ % (datetime .datetime .now ().year , os .path .basename (input_file_name ), GENPINMAP_VERSION ))
393
+ """ % (datetime .datetime .now ().year , os .path .basename (input_file_name )))
395
394
out_h_file .write ( s )
396
395
397
396
@@ -992,8 +991,8 @@ def parse_BoardFile(fileName):
992
991
except :
993
992
pass
994
993
995
-
996
994
# main
995
+ print ("\n Script version %s" % GENPINMAP_VERSION )
997
996
cur_dir = os .getcwd ()
998
997
PeripheralPins_c_filename = 'PeripheralPins.c'
999
998
PinNames_h_filename = 'PinNames.h'
@@ -1006,16 +1005,16 @@ def parse_BoardFile(fileName):
1006
1005
config_file = open (config_filename , "w" )
1007
1006
if sys .platform .startswith ('win32' ):
1008
1007
print ("Platform is Windows" )
1009
- cubemxdir = 'C:\\ Program Files (x86)\\ STMicroelectronics\\ STM32Cube\\ STM32CubeMX\\ db '
1008
+ cubemxdir = 'C:\\ Program Files (x86)\\ STMicroelectronics\\ STM32Cube\\ STM32CubeMX'
1010
1009
elif sys .platform .startswith ('linux' ):
1011
1010
print ("Platform is Linux" )
1012
- cubemxdir = os .getenv ("HOME" )+ '/STM32CubeMX/db '
1011
+ cubemxdir = os .getenv ("HOME" )+ '/STM32CubeMX'
1013
1012
elif sys .platform .startswith ('darwin' ):
1014
1013
print ("Platform is Mac OSX" )
1015
- cubemxdir = '/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources/db '
1014
+ cubemxdir = '/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources'
1016
1015
else :
1017
1016
print ("Platform unknown" )
1018
- cubemxdir = '<Set CubeMX install directory>/db '
1017
+ cubemxdir = '<Set CubeMX install directory>'
1019
1018
config_file .write (json .dumps ({"CUBEMX_DIRECTORY" :cubemxdir }))
1020
1019
config_file .close ()
1021
1020
exit (1 )
@@ -1056,9 +1055,19 @@ def parse_BoardFile(fileName):
1056
1055
print ("\n ! ! ! please check the value you set for 'CUBEMX_DIRECTORY' in '%s' file" % config_filename )
1057
1056
quit ()
1058
1057
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 )
1062
1071
1063
1072
if args .list :
1064
1073
FileCount = 0
@@ -1090,7 +1099,7 @@ def parse_BoardFile(fileName):
1090
1099
else :
1091
1100
mcu_list = fnmatch .filter (os .listdir (cubemxdirMCU ), '*%s*' % args .mcu )
1092
1101
if len (mcu_list ) == 0 :
1093
- print ("\n ! ! ! " + args .mcu + " file not found" )
1102
+ print (" ! ! ! " + args .mcu + " file not found" )
1094
1103
print (" ! ! ! Check in " + cubemxdirMCU + " the correct name of this file" )
1095
1104
print (" ! ! ! You may use double quotes for this file if it contains special characters" )
1096
1105
quit ()
@@ -1100,16 +1109,16 @@ def parse_BoardFile(fileName):
1100
1109
if not (os .path .isfile (board_file_name )):
1101
1110
board_list = fnmatch .filter (os .listdir (cubemxdirBOARDS ), '*%s*AllConfig.ioc' % args .target )
1102
1111
if len (board_list ) == 0 :
1103
- print ("\n ! ! ! No file contains " + args .target )
1112
+ print (" ! ! ! No file contains " + args .target )
1104
1113
print (" ! ! ! Check in " + cubemxdirBOARDS + " the correct filter to apply" )
1105
1114
quit ()
1106
1115
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 )
1109
1118
print (" ! ! ! Only the first one will be parsed\n " )
1110
1119
board_file_name = os .path .join (cubemxdirBOARDS ,board_list [0 ])
1111
1120
if not (os .path .isfile (board_file_name )):
1112
- print ("\n ! ! ! " + args .target + " file not found" )
1121
+ print (" ! ! ! " + args .target + " file not found" )
1113
1122
print (" ! ! ! Check in " + cubemxdirBOARDS + " the correct name of this file" )
1114
1123
print (" ! ! ! You may use double quotes for this file if it contains special characters" )
1115
1124
quit ()
@@ -1199,7 +1208,6 @@ def parse_BoardFile(fileName):
1199
1208
nb_pin = (len (io_list ))
1200
1209
nb_connected_pin = len (PinLabel )
1201
1210
print (" * I/O pins found: %i connected: %i\n " % (nb_pin , nb_connected_pin ))
1202
- # print ("done\n")
1203
1211
clean_all_lists ()
1204
1212
1205
1213
out_c_file .close ()
0 commit comments