2727from  argparse  import  RawTextHelpFormatter 
2828import  subprocess 
2929
30- GENPINMAP_VERSION  =  "1.20.2 " 
30+ GENPINMAP_VERSION  =  "1.20.3 " 
3131
3232ADD_DEVICE_IF  =  0 
3333ADD_GPIO_PINMAP  =  0 
@@ -388,9 +388,36 @@ def store_osc(pin, name, signal):
388388
389389# function to store SYS pins 
390390def  store_sys (pin , name , signal ):
391+     if  'PWR_WKUP'  in  signal :
392+         signal  =  "SYS_"  +  signal 
391393    sys_list .append ([pin , name , signal ])
392394
393395
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+ 
394421def  print_header ():
395422    global  ALTERNATE_DEFINITION 
396423    date_year  =  datetime .datetime .now ().year 
@@ -501,7 +528,8 @@ def print_footer():
501528       LED_list .append ("Pxx" )
502529    StandardLED  =  {}
503530    for  EachLED  in  LED_list :
504-         PinLabel [EachLED ] =  "TODO" 
531+         if  EachLED  not  in PinLabel :
532+             PinLabel [EachLED ] =  "TODO" 
505533        StandardLED [PinLabel [EachLED ]] =  EachLED 
506534
507535    for  EachLED  in  sorted (StandardLED ):
@@ -1567,9 +1595,13 @@ def parse_board_file(file_name):
15671595parser .add_argument ("-g" , "--gpio" , help = "Add GPIO PinMap table" , action = "store_true" )
15681596parser .add_argument ("-n" , "--nopull" , help = "Avoid STM32_open_pin_data git pull" , action = "store_true" )
15691597parser .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" )
15701599
15711600args  =  parser .parse_args ()
15721601
1602+ if  args .debug :
1603+     DEBUG_PRINT  =  1 
1604+ 
15731605print  ("\n Checking STM32_open_pin_data repo..." )
15741606if  not  os .path .exists ("STM32_open_pin_data" ):
15751607    print ("*** git clone https://github.com/STMicroelectronics/STM32_open_pin_data.git ***" )
@@ -1652,6 +1684,9 @@ def parse_board_file(file_name):
16521684    board_file_name  =  os .path .join (cubemxdirBOARDS , args .target )
16531685    if  not (os .path .isfile (board_file_name )):
16541686        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 )
16551690        if  len (board_list ) ==  0 :
16561691            print  (" ! ! ! No file contains "  +  args .target )
16571692            print  (" ! ! ! Check in "  +  cubemxdirBOARDS  +  " the correct filter to apply" )
@@ -1698,12 +1733,12 @@ def parse_board_file(file_name):
16981733
16991734    parse_board_file (board_file_name )
17001735    if  "Nucleo"  in  board_file_name :
1701-         TARGET_NAME  + ="NUCLEO_" 
1736+         TARGET_NAME  =  "NUCLEO_" 
17021737    elif  "Discovery"  in  board_file_name :
1703-         TARGET_NAME  + ="DISCO_" 
1738+         TARGET_NAME  =  "DISCO_" 
17041739    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 )
17071742    if  m :
17081743        TARGET_NAME  +=  "%s"  %  m .group (1 )
17091744        # specific case 
@@ -1718,6 +1753,7 @@ def parse_board_file(file_name):
17181753            "DISCO_L4S5V" : "B_L4S5I_IOT01A" ,
17191754            "DISCO_G071RBT" : "DISCO_G071RB" ,
17201755            "DISCO_L4R9A" : "DISCO_L4R9I" ,
1756+             "DISCO_U585AI" : "B_U585I_IOT02A" ,
17211757            "NUCLEO_WB55R" : "NUCLEO_WB55RG" ,
17221758            "NUCLEO_WL55JCI" : "NUCLEO_WL55JC" ,
17231759            "NUCLEO_H743ZIT" : "NUCLEO_H743ZI2" ,
@@ -1845,12 +1881,14 @@ def parse_board_file(file_name):
18451881        print (" * Generating %s and %s with '%s'"  %  (PeripheralPins_c_filename , PinNames_h_filename , input_file_name ))
18461882        output_cfilename  =  os .path .join (out_path , PeripheralPins_c_filename )
18471883        output_hfilename  =  os .path .join (out_path , PinNames_h_filename )
1884+         cmake_filename  =  os .path .join (out_path , "CMakeLists.txt" )
18481885
18491886        if  os .path .isfile (output_cfilename ):
18501887            print_debug (" * Requested %s file already exists and will be overwritten"  %  PeripheralPins_c_filename )
18511888            os .remove (output_cfilename )
18521889        out_c_file  =  open (output_cfilename , 'w' )
18531890        out_h_file  =  open (output_hfilename , 'w' )
1891+         cmake_file  =  open (cmake_filename , 'w' )
18541892
18551893        #open input file 
18561894        try :
@@ -1897,6 +1935,7 @@ def parse_board_file(file_name):
18971935        print_header ()
18981936        print_all_lists ()
18991937        print_footer ()
1938+         make_cmakelist ()
19001939
19011940        nb_pin  =  (len (gpio_list ))
19021941        nb_connected_pin  =  len (PinLabel )
@@ -1905,3 +1944,4 @@ def parse_board_file(file_name):
19051944
19061945        out_c_file .close ()
19071946        out_h_file .close ()
1947+         cmake_file .close ()
0 commit comments