Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32_gen_PeripheralPins script update #14956

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 46 additions & 6 deletions targets/TARGET_STM/tools/STM32_gen_PeripheralPins.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from argparse import RawTextHelpFormatter
import subprocess

GENPINMAP_VERSION = "1.20.2"
GENPINMAP_VERSION = "1.20.3"

ADD_DEVICE_IF = 0
ADD_GPIO_PINMAP = 0
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -1567,9 +1595,13 @@ def parse_board_file(file_name):
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 ***")
Expand Down Expand Up @@ -1652,6 +1684,9 @@ def parse_board_file(file_name):
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")
Expand Down Expand Up @@ -1698,12 +1733,12 @@ def parse_board_file(file_name):

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
Expand All @@ -1718,6 +1753,7 @@ def parse_board_file(file_name):
"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",
Expand Down Expand Up @@ -1845,12 +1881,14 @@ def parse_board_file(file_name):
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:
Expand Down Expand Up @@ -1897,6 +1935,7 @@ def parse_board_file(file_name):
print_header()
print_all_lists()
print_footer()
make_cmakelist()

nb_pin = (len(gpio_list))
nb_connected_pin = len(PinLabel)
Expand All @@ -1905,3 +1944,4 @@ def parse_board_file(file_name):

out_c_file.close()
out_h_file.close()
cmake_file.close()