Skip to content

script: stm32variant fixes #1405

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

Merged
merged 5 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,4 @@ __pycache__/

# VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
66 changes: 38 additions & 28 deletions CI/utils/stm32variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,9 @@ def print_pinamevar():

# Variant files generation
def spi_pins_variant():
ss_pin = ss1_pin = ss2_pin = ss3_pin = mosi_pin = miso_pin = sck_pin = "PNUM_NOT_DEFINED"
ss_pin = (
ss1_pin
) = ss2_pin = ss3_pin = mosi_pin = miso_pin = sck_pin = "PNUM_NOT_DEFINED"

# Iterate to find match instance if any
for mosi in spimosi_list:
Expand Down Expand Up @@ -1766,6 +1768,8 @@ def group_by_flash(group_base_list, glist, index_mcu_base):
expanded_dir_list.append(flash + subf.group(3))
else:
expanded_dir_list.append(dir_name[index_mcu_base:])
# Remove duplicate
expanded_dir_list = list(dict.fromkeys(expanded_dir_list))
expanded_dir_list.sort()
group_flash_list = [list(g) for _, g in groupby(expanded_dir_list, keyflash)]
packages_per_flash = OrderedDict()
Expand Down Expand Up @@ -2030,28 +2034,30 @@ def aggregate_dir():
del mcu_dir1_files_list[:]


def default_cubemxdir():
global cubemxdir
if sys.platform.startswith("win32"):
print("Platform is Windows")
cubemxdir = Path(r"C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX")
elif sys.platform.startswith("linux"):
print("Platform is Linux")
cubemxdir = Path.home() / "STM32CubeMX"
elif sys.platform.startswith("darwin"):
print("Platform is Mac OSX")
cubemxdir = Path(
"/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources"
)
else:
print("Platform unknown")
cubemxdir = "<Set CubeMX install directory>"


# Config management
def create_config():
# Create a Json file for a better path management
try:
print("Please set your configuration in '{}' file".format(config_filename))
config_file = open(config_filename, "w", newline="\n")
if sys.platform.startswith("win32"):
print("Platform is Windows")
cubemxdir = Path(
r"C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX"
)
elif sys.platform.startswith("linux"):
print("Platform is Linux")
cubemxdir = Path.home() / "STM32CubeMX"
elif sys.platform.startswith("darwin"):
print("Platform is Mac OSX")
cubemxdir = Path(
"/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources"
)
else:
print("Platform unknown")
cubemxdir = "<Set CubeMX install directory>"
config_file.write(
json.dumps(
{
Expand All @@ -2071,21 +2077,23 @@ def check_config():
global cubemxdir
global repo_local_path
global repo_path

default_cubemxdir()
if config_filename.is_file():
try:
config_file = open(config_filename, "r")
config = json.load(config_file)
config_file.close()

conf = config["REPO_LOCAL_PATH"]
if conf:
if conf != "":
repo_local_path = Path(conf)
repo_path = repo_local_path / repo_name
conf = config["CUBEMX_DIRECTORY"]
if conf:
cubemxdir = Path(conf)
if "REPO_LOCAL_PATH" in config:
conf = config["REPO_LOCAL_PATH"]
if conf:
if conf != "":
repo_local_path = Path(conf)
repo_path = repo_local_path / repo_name
if "CUBEMX_DIRECTORY" in config:
conf = config["CUBEMX_DIRECTORY"]
if conf:
cubemxdir = Path(conf)
except IOError:
print("Failed to open " + config_filename)
else:
Expand All @@ -2096,9 +2104,9 @@ def manage_repo():
global db_release
repo_local_path.mkdir(parents=True, exist_ok=True)

print("Updating " + repo_name + "...")
try:
if not args.skip:
print("Updating " + repo_name + "...")
if repo_path.is_dir():
# Get new tags from the remote
git_cmds = [
Expand Down Expand Up @@ -2156,7 +2164,7 @@ def manage_repo():
boards_entry_filename = "boards_entry.txt"
generic_clock_filename = "generic_clock.c"
repo_local_path = cur_dir / "repo"
cubemxdir = ""
cubemxdir = Path()
gh_url = "https://github.com/STMicroelectronics/STM32_open_pin_data"
repo_name = gh_url.rsplit("/", 1)[-1]
repo_path = repo_local_path / repo_name
Expand Down Expand Up @@ -2255,6 +2263,7 @@ def manage_repo():
if manage_repo():
dirMCU = repo_path / "mcu"
dirIP = dirMCU / "IP"
print("Using GitHub repository database")
else:
fallback = True
if fallback or args.cube:
Expand All @@ -2271,6 +2280,7 @@ def manage_repo():

dirMCU = cubemxdir / "db" / "mcu"
dirIP = dirMCU / "IP"
print("Using STM32CubeMX internal database")
version_file = cubemxdir / "db" / "package.xml"
if version_file.is_file():
xml_file = parse(str(version_file))
Expand Down
4 changes: 2 additions & 2 deletions CI/utils/templates/variant_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
const PinName digitalPin[] = {
{% for pinname in pinnames_list %}
{% if not loop.last %}
{{"%-7s // %s"|format("{},".format(pinname.name), "D{}{}".format(loop.index, "" if pinname.ax == -1 else "/A{}".format(pinname.ax)))}}
{{"%-7s // %s"|format("{},".format(pinname.name), "D{}{}".format(loop.index-1, "" if pinname.ax == -1 else "/A{}".format(pinname.ax)))}}
{% else %}
{{"%-7s // %s"|format(pinname.name, "D{}{}".format(loop.index, "" if pinname.ax == -1 else "/A{}".format(pinname.ax)))}}
{{"%-7s // %s"|format(pinname.name, "D{}{}".format(loop.index-1, "" if pinname.ax == -1 else "/A{}".format(pinname.ax)))}}
{% endif %}
{% endfor %}
};
Expand Down
78 changes: 39 additions & 39 deletions variants/STM32F0xx/F030C6T/variant_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,45 @@

// Digital PinName array
const PinName digitalPin[] = {
PA_0, // D1/A0
PA_1, // D2/A1
PA_2, // D3/A2
PA_3, // D4/A3
PA_4, // D5/A4
PA_5, // D6/A5
PA_6, // D7/A6
PA_7, // D8/A7
PA_8, // D9
PA_9, // D10
PA_10, // D11
PA_11, // D12
PA_12, // D13
PA_13, // D14
PA_14, // D15
PA_15, // D16
PB_0, // D17/A8
PB_1, // D18/A9
PB_2, // D19
PB_3, // D20
PB_4, // D21
PB_5, // D22
PB_6, // D23
PB_7, // D24
PB_8, // D25
PB_9, // D26
PB_10, // D27
PB_11, // D28
PB_12, // D29
PB_13, // D30
PB_14, // D31
PB_15, // D32
PC_13, // D33
PC_14, // D34
PC_15, // D35
PF_0, // D36
PF_1, // D37
PF_6, // D38
PF_7 // D39
PA_0, // D0/A0
PA_1, // D1/A1
PA_2, // D2/A2
PA_3, // D3/A3
PA_4, // D4/A4
PA_5, // D5/A5
PA_6, // D6/A6
PA_7, // D7/A7
PA_8, // D8
PA_9, // D9
PA_10, // D10
PA_11, // D11
PA_12, // D12
PA_13, // D13
PA_14, // D14
PA_15, // D15
PB_0, // D16/A8
PB_1, // D17/A9
PB_2, // D18
PB_3, // D19
PB_4, // D20
PB_5, // D21
PB_6, // D22
PB_7, // D23
PB_8, // D24
PB_9, // D25
PB_10, // D26
PB_11, // D27
PB_12, // D28
PB_13, // D29
PB_14, // D30
PB_15, // D31
PC_13, // D32
PC_14, // D33
PC_15, // D34
PF_0, // D35
PF_1, // D36
PF_6, // D37
PF_7 // D38
};

// Analog (Ax) pin number array
Expand Down
78 changes: 39 additions & 39 deletions variants/STM32F0xx/F030C8T/variant_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,45 @@

// Digital PinName array
const PinName digitalPin[] = {
PA_0, // D1/A0
PA_1, // D2/A1
PA_2, // D3/A2
PA_3, // D4/A3
PA_4, // D5/A4
PA_5, // D6/A5
PA_6, // D7/A6
PA_7, // D8/A7
PA_8, // D9
PA_9, // D10
PA_10, // D11
PA_11, // D12
PA_12, // D13
PA_13, // D14
PA_14, // D15
PA_15, // D16
PB_0, // D17/A8
PB_1, // D18/A9
PB_2, // D19
PB_3, // D20
PB_4, // D21
PB_5, // D22
PB_6, // D23
PB_7, // D24
PB_8, // D25
PB_9, // D26
PB_10, // D27
PB_11, // D28
PB_12, // D29
PB_13, // D30
PB_14, // D31
PB_15, // D32
PC_13, // D33
PC_14, // D34
PC_15, // D35
PF_0, // D36
PF_1, // D37
PF_6, // D38
PF_7 // D39
PA_0, // D0/A0
PA_1, // D1/A1
PA_2, // D2/A2
PA_3, // D3/A3
PA_4, // D4/A4
PA_5, // D5/A5
PA_6, // D6/A6
PA_7, // D7/A7
PA_8, // D8
PA_9, // D9
PA_10, // D10
PA_11, // D11
PA_12, // D12
PA_13, // D13
PA_14, // D14
PA_15, // D15
PB_0, // D16/A8
PB_1, // D17/A9
PB_2, // D18
PB_3, // D19
PB_4, // D20
PB_5, // D21
PB_6, // D22
PB_7, // D23
PB_8, // D24
PB_9, // D25
PB_10, // D26
PB_11, // D27
PB_12, // D28
PB_13, // D29
PB_14, // D30
PB_15, // D31
PC_13, // D32
PC_14, // D33
PC_15, // D34
PF_0, // D35
PF_1, // D36
PF_6, // D37
PF_7 // D38
};

// Analog (Ax) pin number array
Expand Down
Loading