27
27
from argparse import RawTextHelpFormatter
28
28
import subprocess
29
29
30
- GENPINMAP_VERSION = "1.20.2 "
30
+ GENPINMAP_VERSION = "1.20.3 "
31
31
32
32
ADD_DEVICE_IF = 0
33
33
ADD_GPIO_PINMAP = 0
@@ -388,9 +388,36 @@ def store_osc(pin, name, signal):
388
388
389
389
# function to store SYS pins
390
390
def store_sys (pin , name , signal ):
391
+ if 'PWR_WKUP' in signal :
392
+ signal = "SYS_" + signal
391
393
sys_list .append ([pin , name , signal ])
392
394
393
395
396
+
397
+ def make_cmakelist ():
398
+ mbed_target = "mbed-" + TARGET_NAME .replace ("_" , "-" ).lower ()
399
+ mbed_family = "mbed-" + TARGET_SUBFAMILY .lower ()
400
+
401
+ line_to_write = ("""# Copyright (c) %i ARM Limited. All rights reserved.
402
+ # SPDX-License-Identifier: Apache-2.0
403
+
404
+ add_library(%s INTERFACE)
405
+
406
+ target_sources(%s
407
+ INTERFACE
408
+ PeripheralPins.c
409
+ )
410
+
411
+ target_include_directories(%s
412
+ INTERFACE
413
+ .
414
+ )
415
+
416
+ target_link_libraries(%s INTERFACE %s)
417
+ """ % (datetime .datetime .now ().year , mbed_target , mbed_target , mbed_target , mbed_target , mbed_family ))
418
+ cmake_file .write (line_to_write )
419
+
420
+
394
421
def print_header ():
395
422
global ALTERNATE_DEFINITION
396
423
date_year = datetime .datetime .now ().year
@@ -501,7 +528,8 @@ def print_footer():
501
528
LED_list .append ("Pxx" )
502
529
StandardLED = {}
503
530
for EachLED in LED_list :
504
- PinLabel [EachLED ] = "TODO"
531
+ if EachLED not in PinLabel :
532
+ PinLabel [EachLED ] = "TODO"
505
533
StandardLED [PinLabel [EachLED ]] = EachLED
506
534
507
535
for EachLED in sorted (StandardLED ):
@@ -1567,9 +1595,13 @@ def parse_board_file(file_name):
1567
1595
parser .add_argument ("-g" , "--gpio" , help = "Add GPIO PinMap table" , action = "store_true" )
1568
1596
parser .add_argument ("-n" , "--nopull" , help = "Avoid STM32_open_pin_data git pull" , action = "store_true" )
1569
1597
parser .add_argument ("-f" , "--flat" , help = "All targets stored in targets_custom/TARGET_STM/" , action = "store_true" )
1598
+ parser .add_argument ("-d" , "--debug" , help = "Few debug info in console" , action = "store_true" )
1570
1599
1571
1600
args = parser .parse_args ()
1572
1601
1602
+ if args .debug :
1603
+ DEBUG_PRINT = 1
1604
+
1573
1605
print ("\n Checking STM32_open_pin_data repo..." )
1574
1606
if not os .path .exists ("STM32_open_pin_data" ):
1575
1607
print ("*** git clone https://github.com/STMicroelectronics/STM32_open_pin_data.git ***" )
@@ -1652,6 +1684,9 @@ def parse_board_file(file_name):
1652
1684
board_file_name = os .path .join (cubemxdirBOARDS , args .target )
1653
1685
if not (os .path .isfile (board_file_name )):
1654
1686
board_list = fnmatch .filter (os .listdir (cubemxdirBOARDS ), '*%s*AllConfig.ioc' % args .target )
1687
+ for item in list (board_list ):
1688
+ if "TrustZone" in item :
1689
+ board_list .remove (item )
1655
1690
if len (board_list ) == 0 :
1656
1691
print (" ! ! ! No file contains " + args .target )
1657
1692
print (" ! ! ! Check in " + cubemxdirBOARDS + " the correct filter to apply" )
@@ -1698,12 +1733,12 @@ def parse_board_file(file_name):
1698
1733
1699
1734
parse_board_file (board_file_name )
1700
1735
if "Nucleo" in board_file_name :
1701
- TARGET_NAME + = "NUCLEO_"
1736
+ TARGET_NAME = "NUCLEO_"
1702
1737
elif "Discovery" in board_file_name :
1703
- TARGET_NAME + = "DISCO_"
1738
+ TARGET_NAME = "DISCO_"
1704
1739
elif "Evaluation" in board_file_name :
1705
- TARGET_NAME + = "EVAL_"
1706
- m = re .search (r'STM32([MFLGWH ][\w]*)_Board' , board_file_name )
1740
+ TARGET_NAME = "EVAL_"
1741
+ m = re .search (r'STM32([MFLGWHU ][\w]*)_Board' , board_file_name )
1707
1742
if m :
1708
1743
TARGET_NAME += "%s" % m .group (1 )
1709
1744
# specific case
@@ -1718,6 +1753,7 @@ def parse_board_file(file_name):
1718
1753
"DISCO_L4S5V" : "B_L4S5I_IOT01A" ,
1719
1754
"DISCO_G071RBT" : "DISCO_G071RB" ,
1720
1755
"DISCO_L4R9A" : "DISCO_L4R9I" ,
1756
+ "DISCO_U585AI" : "B_U585I_IOT02A" ,
1721
1757
"NUCLEO_WB55R" : "NUCLEO_WB55RG" ,
1722
1758
"NUCLEO_WL55JCI" : "NUCLEO_WL55JC" ,
1723
1759
"NUCLEO_H743ZIT" : "NUCLEO_H743ZI2" ,
@@ -1845,12 +1881,14 @@ def parse_board_file(file_name):
1845
1881
print (" * Generating %s and %s with '%s'" % (PeripheralPins_c_filename , PinNames_h_filename , input_file_name ))
1846
1882
output_cfilename = os .path .join (out_path , PeripheralPins_c_filename )
1847
1883
output_hfilename = os .path .join (out_path , PinNames_h_filename )
1884
+ cmake_filename = os .path .join (out_path , "CMakeLists.txt" )
1848
1885
1849
1886
if os .path .isfile (output_cfilename ):
1850
1887
print_debug (" * Requested %s file already exists and will be overwritten" % PeripheralPins_c_filename )
1851
1888
os .remove (output_cfilename )
1852
1889
out_c_file = open (output_cfilename , 'w' )
1853
1890
out_h_file = open (output_hfilename , 'w' )
1891
+ cmake_file = open (cmake_filename , 'w' )
1854
1892
1855
1893
#open input file
1856
1894
try :
@@ -1897,6 +1935,7 @@ def parse_board_file(file_name):
1897
1935
print_header ()
1898
1936
print_all_lists ()
1899
1937
print_footer ()
1938
+ make_cmakelist ()
1900
1939
1901
1940
nb_pin = (len (gpio_list ))
1902
1941
nb_connected_pin = len (PinLabel )
@@ -1905,3 +1944,4 @@ def parse_board_file(file_name):
1905
1944
1906
1945
out_c_file .close ()
1907
1946
out_h_file .close ()
1947
+ cmake_file .close ()
0 commit comments