Skip to content

Commit 291cebc

Browse files
authored
Merge pull request #1405 from fpistm/ci-variant
script: stm32variant fixes
2 parents a728373 + 37da736 commit 291cebc

File tree

501 files changed

+33123
-33117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

501 files changed

+33123
-33117
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,4 @@ __pycache__/
3131

3232
# VisualStudioCode
3333
.vscode/*
34-
!.vscode/settings.json
35-
!.vscode/tasks.json
36-
!.vscode/launch.json
37-
!.vscode/extensions.json
3834
*.code-workspace

CI/utils/stm32variant.py

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,9 @@ def print_pinamevar():
11301130

11311131
# Variant files generation
11321132
def spi_pins_variant():
1133-
ss_pin = ss1_pin = ss2_pin = ss3_pin = mosi_pin = miso_pin = sck_pin = "PNUM_NOT_DEFINED"
1133+
ss_pin = (
1134+
ss1_pin
1135+
) = ss2_pin = ss3_pin = mosi_pin = miso_pin = sck_pin = "PNUM_NOT_DEFINED"
11341136

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

20322036

2037+
def default_cubemxdir():
2038+
global cubemxdir
2039+
if sys.platform.startswith("win32"):
2040+
print("Platform is Windows")
2041+
cubemxdir = Path(r"C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX")
2042+
elif sys.platform.startswith("linux"):
2043+
print("Platform is Linux")
2044+
cubemxdir = Path.home() / "STM32CubeMX"
2045+
elif sys.platform.startswith("darwin"):
2046+
print("Platform is Mac OSX")
2047+
cubemxdir = Path(
2048+
"/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources"
2049+
)
2050+
else:
2051+
print("Platform unknown")
2052+
cubemxdir = "<Set CubeMX install directory>"
2053+
2054+
20332055
# Config management
20342056
def create_config():
20352057
# Create a Json file for a better path management
20362058
try:
20372059
print("Please set your configuration in '{}' file".format(config_filename))
20382060
config_file = open(config_filename, "w", newline="\n")
2039-
if sys.platform.startswith("win32"):
2040-
print("Platform is Windows")
2041-
cubemxdir = Path(
2042-
r"C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX"
2043-
)
2044-
elif sys.platform.startswith("linux"):
2045-
print("Platform is Linux")
2046-
cubemxdir = Path.home() / "STM32CubeMX"
2047-
elif sys.platform.startswith("darwin"):
2048-
print("Platform is Mac OSX")
2049-
cubemxdir = Path(
2050-
"/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources"
2051-
)
2052-
else:
2053-
print("Platform unknown")
2054-
cubemxdir = "<Set CubeMX install directory>"
20552061
config_file.write(
20562062
json.dumps(
20572063
{
@@ -2071,21 +2077,23 @@ def check_config():
20712077
global cubemxdir
20722078
global repo_local_path
20732079
global repo_path
2074-
2080+
default_cubemxdir()
20752081
if config_filename.is_file():
20762082
try:
20772083
config_file = open(config_filename, "r")
20782084
config = json.load(config_file)
20792085
config_file.close()
20802086

2081-
conf = config["REPO_LOCAL_PATH"]
2082-
if conf:
2083-
if conf != "":
2084-
repo_local_path = Path(conf)
2085-
repo_path = repo_local_path / repo_name
2086-
conf = config["CUBEMX_DIRECTORY"]
2087-
if conf:
2088-
cubemxdir = Path(conf)
2087+
if "REPO_LOCAL_PATH" in config:
2088+
conf = config["REPO_LOCAL_PATH"]
2089+
if conf:
2090+
if conf != "":
2091+
repo_local_path = Path(conf)
2092+
repo_path = repo_local_path / repo_name
2093+
if "CUBEMX_DIRECTORY" in config:
2094+
conf = config["CUBEMX_DIRECTORY"]
2095+
if conf:
2096+
cubemxdir = Path(conf)
20892097
except IOError:
20902098
print("Failed to open " + config_filename)
20912099
else:
@@ -2096,9 +2104,9 @@ def manage_repo():
20962104
global db_release
20972105
repo_local_path.mkdir(parents=True, exist_ok=True)
20982106

2099-
print("Updating " + repo_name + "...")
21002107
try:
21012108
if not args.skip:
2109+
print("Updating " + repo_name + "...")
21022110
if repo_path.is_dir():
21032111
# Get new tags from the remote
21042112
git_cmds = [
@@ -2156,7 +2164,7 @@ def manage_repo():
21562164
boards_entry_filename = "boards_entry.txt"
21572165
generic_clock_filename = "generic_clock.c"
21582166
repo_local_path = cur_dir / "repo"
2159-
cubemxdir = ""
2167+
cubemxdir = Path()
21602168
gh_url = "https://github.com/STMicroelectronics/STM32_open_pin_data"
21612169
repo_name = gh_url.rsplit("/", 1)[-1]
21622170
repo_path = repo_local_path / repo_name
@@ -2255,6 +2263,7 @@ def manage_repo():
22552263
if manage_repo():
22562264
dirMCU = repo_path / "mcu"
22572265
dirIP = dirMCU / "IP"
2266+
print("Using GitHub repository database")
22582267
else:
22592268
fallback = True
22602269
if fallback or args.cube:
@@ -2271,6 +2280,7 @@ def manage_repo():
22712280

22722281
dirMCU = cubemxdir / "db" / "mcu"
22732282
dirIP = dirMCU / "IP"
2283+
print("Using STM32CubeMX internal database")
22742284
version_file = cubemxdir / "db" / "package.xml"
22752285
if version_file.is_file():
22762286
xml_file = parse(str(version_file))

CI/utils/templates/variant_generic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
const PinName digitalPin[] = {
1919
{% for pinname in pinnames_list %}
2020
{% if not loop.last %}
21-
{{"%-7s // %s"|format("{},".format(pinname.name), "D{}{}".format(loop.index, "" if pinname.ax == -1 else "/A{}".format(pinname.ax)))}}
21+
{{"%-7s // %s"|format("{},".format(pinname.name), "D{}{}".format(loop.index-1, "" if pinname.ax == -1 else "/A{}".format(pinname.ax)))}}
2222
{% else %}
23-
{{"%-7s // %s"|format(pinname.name, "D{}{}".format(loop.index, "" if pinname.ax == -1 else "/A{}".format(pinname.ax)))}}
23+
{{"%-7s // %s"|format(pinname.name, "D{}{}".format(loop.index-1, "" if pinname.ax == -1 else "/A{}".format(pinname.ax)))}}
2424
{% endif %}
2525
{% endfor %}
2626
};

variants/STM32F0xx/F030C6T/variant_generic.cpp

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,45 @@
1515

1616
// Digital PinName array
1717
const PinName digitalPin[] = {
18-
PA_0, // D1/A0
19-
PA_1, // D2/A1
20-
PA_2, // D3/A2
21-
PA_3, // D4/A3
22-
PA_4, // D5/A4
23-
PA_5, // D6/A5
24-
PA_6, // D7/A6
25-
PA_7, // D8/A7
26-
PA_8, // D9
27-
PA_9, // D10
28-
PA_10, // D11
29-
PA_11, // D12
30-
PA_12, // D13
31-
PA_13, // D14
32-
PA_14, // D15
33-
PA_15, // D16
34-
PB_0, // D17/A8
35-
PB_1, // D18/A9
36-
PB_2, // D19
37-
PB_3, // D20
38-
PB_4, // D21
39-
PB_5, // D22
40-
PB_6, // D23
41-
PB_7, // D24
42-
PB_8, // D25
43-
PB_9, // D26
44-
PB_10, // D27
45-
PB_11, // D28
46-
PB_12, // D29
47-
PB_13, // D30
48-
PB_14, // D31
49-
PB_15, // D32
50-
PC_13, // D33
51-
PC_14, // D34
52-
PC_15, // D35
53-
PF_0, // D36
54-
PF_1, // D37
55-
PF_6, // D38
56-
PF_7 // D39
18+
PA_0, // D0/A0
19+
PA_1, // D1/A1
20+
PA_2, // D2/A2
21+
PA_3, // D3/A3
22+
PA_4, // D4/A4
23+
PA_5, // D5/A5
24+
PA_6, // D6/A6
25+
PA_7, // D7/A7
26+
PA_8, // D8
27+
PA_9, // D9
28+
PA_10, // D10
29+
PA_11, // D11
30+
PA_12, // D12
31+
PA_13, // D13
32+
PA_14, // D14
33+
PA_15, // D15
34+
PB_0, // D16/A8
35+
PB_1, // D17/A9
36+
PB_2, // D18
37+
PB_3, // D19
38+
PB_4, // D20
39+
PB_5, // D21
40+
PB_6, // D22
41+
PB_7, // D23
42+
PB_8, // D24
43+
PB_9, // D25
44+
PB_10, // D26
45+
PB_11, // D27
46+
PB_12, // D28
47+
PB_13, // D29
48+
PB_14, // D30
49+
PB_15, // D31
50+
PC_13, // D32
51+
PC_14, // D33
52+
PC_15, // D34
53+
PF_0, // D35
54+
PF_1, // D36
55+
PF_6, // D37
56+
PF_7 // D38
5757
};
5858

5959
// Analog (Ax) pin number array

variants/STM32F0xx/F030C8T/variant_generic.cpp

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,45 @@
1515

1616
// Digital PinName array
1717
const PinName digitalPin[] = {
18-
PA_0, // D1/A0
19-
PA_1, // D2/A1
20-
PA_2, // D3/A2
21-
PA_3, // D4/A3
22-
PA_4, // D5/A4
23-
PA_5, // D6/A5
24-
PA_6, // D7/A6
25-
PA_7, // D8/A7
26-
PA_8, // D9
27-
PA_9, // D10
28-
PA_10, // D11
29-
PA_11, // D12
30-
PA_12, // D13
31-
PA_13, // D14
32-
PA_14, // D15
33-
PA_15, // D16
34-
PB_0, // D17/A8
35-
PB_1, // D18/A9
36-
PB_2, // D19
37-
PB_3, // D20
38-
PB_4, // D21
39-
PB_5, // D22
40-
PB_6, // D23
41-
PB_7, // D24
42-
PB_8, // D25
43-
PB_9, // D26
44-
PB_10, // D27
45-
PB_11, // D28
46-
PB_12, // D29
47-
PB_13, // D30
48-
PB_14, // D31
49-
PB_15, // D32
50-
PC_13, // D33
51-
PC_14, // D34
52-
PC_15, // D35
53-
PF_0, // D36
54-
PF_1, // D37
55-
PF_6, // D38
56-
PF_7 // D39
18+
PA_0, // D0/A0
19+
PA_1, // D1/A1
20+
PA_2, // D2/A2
21+
PA_3, // D3/A3
22+
PA_4, // D4/A4
23+
PA_5, // D5/A5
24+
PA_6, // D6/A6
25+
PA_7, // D7/A7
26+
PA_8, // D8
27+
PA_9, // D9
28+
PA_10, // D10
29+
PA_11, // D11
30+
PA_12, // D12
31+
PA_13, // D13
32+
PA_14, // D14
33+
PA_15, // D15
34+
PB_0, // D16/A8
35+
PB_1, // D17/A9
36+
PB_2, // D18
37+
PB_3, // D19
38+
PB_4, // D20
39+
PB_5, // D21
40+
PB_6, // D22
41+
PB_7, // D23
42+
PB_8, // D24
43+
PB_9, // D25
44+
PB_10, // D26
45+
PB_11, // D27
46+
PB_12, // D28
47+
PB_13, // D29
48+
PB_14, // D30
49+
PB_15, // D31
50+
PC_13, // D32
51+
PC_14, // D33
52+
PC_15, // D34
53+
PF_0, // D35
54+
PF_1, // D36
55+
PF_6, // D37
56+
PF_7 // D38
5757
};
5858

5959
// Analog (Ax) pin number array

0 commit comments

Comments
 (0)