mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			STM32_gen_PeripheralPins script update
- add CMakeLists.txt - patch for STM32U5 boardspull/14956/head
							parent
							
								
									df00ed4efe
								
							
						
					
					
						commit
						79d403a0db
					
				| 
						 | 
				
			
			@ -27,7 +27,7 @@ from xml.dom.minidom import parse, Node
 | 
			
		|||
from argparse import RawTextHelpFormatter
 | 
			
		||||
import subprocess
 | 
			
		||||
 | 
			
		||||
GENPINMAP_VERSION = "1.20.2"
 | 
			
		||||
GENPINMAP_VERSION = "1.20.3"
 | 
			
		||||
 | 
			
		||||
ADD_DEVICE_IF = 0
 | 
			
		||||
ADD_GPIO_PINMAP = 0
 | 
			
		||||
| 
						 | 
				
			
			@ -388,9 +388,36 @@ def store_osc(pin, name, signal):
 | 
			
		|||
 | 
			
		||||
# function to store SYS pins
 | 
			
		||||
def store_sys(pin, name, signal):
 | 
			
		||||
    if 'PWR_WKUP' in signal:
 | 
			
		||||
        signal = "SYS_" + signal
 | 
			
		||||
    sys_list.append([pin, name, signal])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def make_cmakelist():
 | 
			
		||||
    mbed_target = "mbed-" + TARGET_NAME.replace("_", "-").lower()
 | 
			
		||||
    mbed_family = "mbed-" + TARGET_SUBFAMILY.lower()
 | 
			
		||||
 | 
			
		||||
    line_to_write =  ("""# Copyright (c) %i ARM Limited. All rights reserved.
 | 
			
		||||
# SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 | 
			
		||||
add_library(%s INTERFACE)
 | 
			
		||||
 | 
			
		||||
target_sources(%s
 | 
			
		||||
    INTERFACE
 | 
			
		||||
        PeripheralPins.c
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
target_include_directories(%s
 | 
			
		||||
    INTERFACE
 | 
			
		||||
        .
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
target_link_libraries(%s INTERFACE %s)
 | 
			
		||||
""" % (datetime.datetime.now().year, mbed_target, mbed_target, mbed_target, mbed_target, mbed_family))
 | 
			
		||||
    cmake_file.write(line_to_write)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def print_header():
 | 
			
		||||
    global ALTERNATE_DEFINITION
 | 
			
		||||
    date_year = datetime.datetime.now().year
 | 
			
		||||
| 
						 | 
				
			
			@ -501,7 +528,8 @@ def print_footer():
 | 
			
		|||
       LED_list.append("Pxx")
 | 
			
		||||
    StandardLED = {}
 | 
			
		||||
    for EachLED in LED_list:
 | 
			
		||||
        PinLabel[EachLED] = "TODO"
 | 
			
		||||
        if EachLED not in PinLabel:
 | 
			
		||||
            PinLabel[EachLED] = "TODO"
 | 
			
		||||
        StandardLED[PinLabel[EachLED]] = EachLED
 | 
			
		||||
 | 
			
		||||
    for EachLED in sorted(StandardLED):
 | 
			
		||||
| 
						 | 
				
			
			@ -1567,9 +1595,13 @@ specify a custom board .ioc file description to use (use double quotes).
 | 
			
		|||
parser.add_argument("-g", "--gpio", help="Add GPIO PinMap table", action="store_true")
 | 
			
		||||
parser.add_argument("-n", "--nopull", help="Avoid STM32_open_pin_data git pull", action="store_true")
 | 
			
		||||
parser.add_argument("-f", "--flat", help="All targets stored in targets_custom/TARGET_STM/", action="store_true")
 | 
			
		||||
parser.add_argument("-d", "--debug", help="Few debug info in console", action="store_true")
 | 
			
		||||
 | 
			
		||||
args = parser.parse_args()
 | 
			
		||||
 | 
			
		||||
if args.debug:
 | 
			
		||||
    DEBUG_PRINT = 1
 | 
			
		||||
 | 
			
		||||
print ("\nChecking STM32_open_pin_data repo...")
 | 
			
		||||
if not os.path.exists("STM32_open_pin_data"):
 | 
			
		||||
    print("*** git clone https://github.com/STMicroelectronics/STM32_open_pin_data.git ***")
 | 
			
		||||
| 
						 | 
				
			
			@ -1652,6 +1684,9 @@ if args.target:
 | 
			
		|||
    board_file_name = os.path.join(cubemxdirBOARDS, args.target)
 | 
			
		||||
    if not(os.path.isfile(board_file_name)):
 | 
			
		||||
        board_list = fnmatch.filter(os.listdir(cubemxdirBOARDS), '*%s*AllConfig.ioc' % args.target)
 | 
			
		||||
        for item in list(board_list):
 | 
			
		||||
            if "TrustZone" in item:
 | 
			
		||||
                board_list.remove(item)
 | 
			
		||||
        if len(board_list) == 0:
 | 
			
		||||
            print (" ! ! ! No file contains " + args.target)
 | 
			
		||||
            print (" ! ! ! Check in " + cubemxdirBOARDS + " the correct filter to apply")
 | 
			
		||||
| 
						 | 
				
			
			@ -1698,12 +1733,12 @@ if args.target:
 | 
			
		|||
 | 
			
		||||
    parse_board_file(board_file_name)
 | 
			
		||||
    if "Nucleo" in board_file_name:
 | 
			
		||||
        TARGET_NAME += "NUCLEO_"
 | 
			
		||||
        TARGET_NAME = "NUCLEO_"
 | 
			
		||||
    elif "Discovery" in board_file_name:
 | 
			
		||||
        TARGET_NAME += "DISCO_"
 | 
			
		||||
        TARGET_NAME = "DISCO_"
 | 
			
		||||
    elif "Evaluation" in board_file_name:
 | 
			
		||||
        TARGET_NAME += "EVAL_"
 | 
			
		||||
    m = re.search(r'STM32([MFLGWH][\w]*)_Board', board_file_name)
 | 
			
		||||
        TARGET_NAME = "EVAL_"
 | 
			
		||||
    m = re.search(r'STM32([MFLGWHU][\w]*)_Board', board_file_name)
 | 
			
		||||
    if m:
 | 
			
		||||
        TARGET_NAME += "%s" % m.group(1)
 | 
			
		||||
        # specific case
 | 
			
		||||
| 
						 | 
				
			
			@ -1718,6 +1753,7 @@ if args.target:
 | 
			
		|||
            "DISCO_L4S5V": "B_L4S5I_IOT01A",
 | 
			
		||||
            "DISCO_G071RBT": "DISCO_G071RB",
 | 
			
		||||
            "DISCO_L4R9A": "DISCO_L4R9I",
 | 
			
		||||
            "DISCO_U585AI": "B_U585I_IOT02A",
 | 
			
		||||
            "NUCLEO_WB55R": "NUCLEO_WB55RG",
 | 
			
		||||
            "NUCLEO_WL55JCI": "NUCLEO_WL55JC",
 | 
			
		||||
            "NUCLEO_H743ZIT": "NUCLEO_H743ZI2",
 | 
			
		||||
| 
						 | 
				
			
			@ -1845,12 +1881,14 @@ for mcu_file in mcu_list:
 | 
			
		|||
        print(" * Generating %s and %s with '%s'" % (PeripheralPins_c_filename, PinNames_h_filename, input_file_name))
 | 
			
		||||
        output_cfilename = os.path.join(out_path, PeripheralPins_c_filename)
 | 
			
		||||
        output_hfilename = os.path.join(out_path, PinNames_h_filename)
 | 
			
		||||
        cmake_filename = os.path.join(out_path, "CMakeLists.txt")
 | 
			
		||||
 | 
			
		||||
        if os.path.isfile(output_cfilename):
 | 
			
		||||
            print_debug(" * Requested %s file already exists and will be overwritten" % PeripheralPins_c_filename)
 | 
			
		||||
            os.remove(output_cfilename)
 | 
			
		||||
        out_c_file = open(output_cfilename, 'w')
 | 
			
		||||
        out_h_file = open(output_hfilename, 'w')
 | 
			
		||||
        cmake_file = open(cmake_filename, 'w')
 | 
			
		||||
 | 
			
		||||
        #open input file
 | 
			
		||||
        try:
 | 
			
		||||
| 
						 | 
				
			
			@ -1897,6 +1935,7 @@ for mcu_file in mcu_list:
 | 
			
		|||
        print_header()
 | 
			
		||||
        print_all_lists()
 | 
			
		||||
        print_footer()
 | 
			
		||||
        make_cmakelist()
 | 
			
		||||
 | 
			
		||||
        nb_pin = (len(gpio_list))
 | 
			
		||||
        nb_connected_pin = len(PinLabel)
 | 
			
		||||
| 
						 | 
				
			
			@ -1905,3 +1944,4 @@ for mcu_file in mcu_list:
 | 
			
		|||
 | 
			
		||||
        out_c_file.close()
 | 
			
		||||
        out_h_file.close()
 | 
			
		||||
        cmake_file.close()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue