Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
66047f8
[variant] Group each variant per STM32 series
fpistm Jun 5, 2020
c64a09c
[PIO] Fix variants path changes
fpistm Jul 10, 2020
7011b58
[ThunderPack] Split variant per series
fpistm Jul 16, 2020
99c49a2
Rename PinMap_PWM to PinMap_TIM
fpistm Dec 6, 2020
7469071
Extend Arduino pin naming to the max possibilities
fpistm Dec 5, 2020
4afab84
Clean up old way to define Ax pins definition
fpistm Dec 5, 2020
0a7489d
Introduce all alternative pins per peripheral
fpistm Aug 24, 2020
ff7f85e
Rework analog pin management
fpistm Jan 29, 2021
ac2d9cc
Change Ax constants to an enum
fpistm Jan 25, 2021
0898a85
Remap pin management
fpistm Dec 8, 2020
71108a3
Add Alternate pins (ALTx) management
fpistm Jan 8, 2021
0cafa3c
Definition and comments improvements for pins management
fpistm Jan 25, 2021
da7ef68
Move genpinmap from Arduino_Tools repository
fpistm Feb 19, 2021
e4edbf4
[stm32variant] Update to generate in the core
fpistm Feb 19, 2021
49a09e9
[stm32variant] Use Mcu description
fpistm Feb 19, 2021
4fae0c7
[stm32variant] Add board_entry.txt
fpistm Feb 19, 2021
8ff95b8
[stm32variant] Add option to generate only one family
fpistm Feb 22, 2021
e6ac2bd
[stm32variant] Aggregate generated variant if they are the same
fpistm Mar 1, 2021
66d6408
[stm32variant] Add generic_clock.c generation
fpistm Feb 24, 2021
4fbc7c7
[stm32variant] Comment option to generate from one mcu file
fpistm Mar 8, 2021
677c076
Allow use of a custom peripheral pins file
fpistm Feb 24, 2021
abf08af
[CI] arduino-builder is replaced by arduino-cli
fpistm Mar 9, 2021
d046589
[stm32variant] Change generic variant generation
fpistm Mar 10, 2021
d2674fd
[stm32variant] Fix USB mode when AF is not none
fpistm Mar 27, 2021
cfd7cff
[stm32variant] Rework dirname aggregation
fpistm Mar 30, 2021
0b4c5f7
[stm32variant] Fix ALTx issue with remapped pins
fpistm Apr 8, 2021
b4cdfc8
[stm32variant] Fix AFIO definition for F1
fpistm Apr 8, 2021
8366f41
[stm32variant] Add a README.md
fpistm Apr 15, 2021
20e6e72
[stm32variant] Rename ND by PNUM_NOT_DEFINED
fpistm Apr 15, 2021
b5662d7
Add all generated STM32F0xx generic variant files
fpistm Apr 7, 2021
6b2b23d
Add all generated STM32F1xx generic variant files
fpistm Apr 7, 2021
b78ebe7
Add all generated STM32F2xx generic variant files
fpistm Apr 7, 2021
e0cfa88
Add all generated STM32F3xx generic variant files
fpistm Apr 7, 2021
046afd7
Add all generated STM32F4xx generic variant files
fpistm Apr 7, 2021
0b3dac6
Add all generated STM32F7xx generic variant files
fpistm Apr 7, 2021
4d23012
Add all generated STM32G0xx generic variant files
fpistm Apr 7, 2021
ec30479
Add all generated STM32G4xx generic variant files
fpistm Apr 7, 2021
2f7d688
Add all generated STM32H7xx generic variant files
fpistm Apr 7, 2021
e0157b7
Add all generated STM32L0xx generic variant files
fpistm Apr 7, 2021
b9e45d1
Add all generated STM32L1xx generic variant files
fpistm Apr 7, 2021
f1685bd
Add all generated STM32L4xx generic variant files
fpistm Apr 7, 2021
b04d918
Add all generated STM32L5xx generic variant files
fpistm Apr 7, 2021
7c2fddd
Add all generated STM32MP1xx generic variant files
fpistm Apr 7, 2021
f3f7c43
Add all generated STM32WBxx generic variant files
fpistm Apr 7, 2021
d71f287
Add all generated STM32WLxx generic variant files
fpistm Apr 7, 2021
7a95366
Update variant header management
fpistm Mar 11, 2021
d61905e
[variant] Add Generic L4xx
fpistm Apr 6, 2021
24c724a
[variant] Add Generic G4xx
ABOSTM Apr 7, 2021
55c761f
[variant] Add support of board B-G431B-ESC1
owennewo Mar 23, 2021
606b131
[variant] Add Generic G0xx
fpistm Apr 7, 2021
2a78e9d
Add Aurora One Variant
jhleekr Sep 15, 2020
cfd0b17
Add Nucleo G031K8 and generic G031Kx
fpistm Mar 15, 2021
503f79e
[variant] Update Generic F0xx
fpistm Jan 22, 2021
9234b65
Add Generic F042Cx
seeers Mar 10, 2021
6a45026
Added NUCLEO_F070RB
gbmhunter Sep 10, 2020
51b7236
[variant] Update Generic MP1xx
fpistm Jan 27, 2021
db9b6ed
[variant] Add Generic F2xx
fpistm Mar 14, 2021
b20c5ed
[variant] Add Generic L5xx and Nucleo L552ZE-Q
fpistm Mar 14, 2021
1920959
[variant] Add Generic WBxx
fpistm Mar 14, 2021
5bd495f
[variant] Add Generic L1xx
fpistm Mar 15, 2021
4f033ba
[variant] Update Generic H7xx
fpistm Mar 15, 2021
f79a926
Added Generic H743Vx
vladkozlov69 Sep 25, 2020
30ddea4
Enable HAL MDMA by default
fpistm Mar 16, 2021
7a3a084
[variant] Add Generic F7xx
ABOSTM Mar 16, 2021
d3438df
[variant] Add Generic L0xx
ABOSTM Mar 18, 2021
2315591
Add Generic L010RB
mkals Mar 23, 2021
87bb2ed
[variant] Add Generic F3xx
ABOSTM Mar 23, 2021
f4d5b62
[Variant] Add DISCO F303VC
dnandha Mar 25, 2021
0bc6d02
[Variant] Add OLIMEXINO-STM32F3
Stanimir-Petev Mar 25, 2021
51e9a15
[variant] Add Generic F4xx
ABOSTM Mar 26, 2021
0496974
BlackPill F401CC: add USER_BTN on PA0
ABOSTM Apr 2, 2021
9207aaa
[variant] Add STM32F407ZGT6 Mini and Generic_F407Zx
dds90 Apr 2, 2021
7582527
BLACK_F407ZX: invert PF9 and PF10 in digitalPin[]
ABOSTM Apr 6, 2021
f17e7be
[variant] Add Generic F1xx
ABOSTM Apr 9, 2021
6a94738
[variant] Add Generic F100Cx
mcer12 Apr 13, 2021
cbbb14c
[PIO]Fix variant header and path changes
fpistm Mar 12, 2021
1e38015
[CI] Update configuration to build only one generic per variant
fpistm Mar 16, 2021
ba52cf2
[variant] Remove board_template
fpistm Apr 15, 2021
088209c
Group system IP clock enable in separate function called at init
ABOSTM Apr 16, 2021
f8ddc9c
Manage dualpad analog switch
ABOSTM Apr 16, 2021
7ec57a1
[CI] Update core configuration
fpistm Apr 15, 2021
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
Prev Previous commit
Next Next commit
[stm32variant] Add board_entry.txt
This will help to add generic board entry.
Note:
upload.maximum_size and product_line have to be verified
and changed if needed.

Signed-off-by: Frederic Pillon <[email protected]>
  • Loading branch information
fpistm committed Apr 6, 2021
commit 4fae0c7b11c969f397a317e6682f0064c178c993
132 changes: 111 additions & 21 deletions CI/utils/stm32variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
tim_inst_list = [] # TIMx instance
usb_inst = {"usb": "", "otg_fs": "", "otg_hs": ""}
mcu_family = ""
mcu_refname = ""
mcu_flash = []
mcu_ram = ""

# Cube information
startup_dict = {}

# format
# Peripheral
Expand All @@ -59,19 +65,31 @@


# mcu file parsing
def parse_IP_file():
def parse_mcu_file():
global gpiofile
global mcu_family
global mcu_refname
global mcu_ram

tim_regex = r"^(TIM\d+)$"
usb_regex = r"^(USB(?!PD|_HOST|_DEVICE).*)$"
gpiofile = ""
del tim_inst_list[:]
del mcu_flash[:]
usb_inst["usb"] = ""
usb_inst["otg_fs"] = ""
usb_inst["otg_hs"] = ""

mcu_node = xml_mcu.getElementsByTagName("Mcu")[0]
mcu_family = mcu_node.attributes["Family"].value
if mcu_family.endswith("+"):
mcu_family = mcu_family[:-1]
mcu_refname = mcu_node.attributes["RefName"].value

mcu_ram = int(mcu_node.getElementsByTagName("Ram")[0].firstChild.nodeValue) * 1024
flash_node = mcu_node.getElementsByTagName("Flash")
for f in flash_node:
mcu_flash.append(int(f.firstChild.nodeValue) * 1024)

itemlist = xml_mcu.getElementsByTagName("IP")
for s in itemlist:
Expand All @@ -95,7 +113,7 @@ def parse_IP_file():


def get_gpio_af_num(pintofind, iptofind):
if "STM32F10" in mcu_file.stem:
if "STM32F1" in mcu_family:
return get_gpio_af_numF1(pintofind, iptofind)
# DBG print ('pin to find ' + pintofind)
i = 0
Expand Down Expand Up @@ -325,7 +343,7 @@ def adc_pinmap():
wpin = []
# For STM32L47xxx/48xxx, it is necessary to configure
# the GPIOx_ASCR register
if re.match("STM32L4[78]+", mcu_file.stem):
if re.match("STM32L4[78]+", mcu_refname):
default_mode = "STM_MODE_ANALOG_ADC_CONTROL"
else:
default_mode = "STM_MODE_ANALOG"
Expand Down Expand Up @@ -512,7 +530,7 @@ def uart_pinmap(lst):
inst = p[2].split("_")[0]
winst.append(len(inst))
wpin.append(len(p[0]))
if "STM32F10" in mcu_file.stem and lst == uartrx_list:
if "STM32F1" in mcu_family and lst == uartrx_list:
mode = "STM_MODE_INPUT"
else:
mode = "STM_MODE_AF_PP"
Expand Down Expand Up @@ -598,7 +616,7 @@ def can_pinmap(lst):
inst += "1"
winst.append(len(inst))
wpin.append(len(p[0]))
if "STM32F10" in mcu_file.stem and lst == canrd_list:
if "STM32F1" in mcu_family and lst == canrd_list:
mode = "STM_MODE_INPUT"
else:
mode = "STM_MODE_AF_PP"
Expand Down Expand Up @@ -1106,7 +1124,7 @@ def timer_variant():
return dict(tone=tone, servo=servo)


def print_variant(generic_def):
def print_variant(generic_list):
variant_h_template = j2_env.get_template(variant_h_filename)
variant_cpp_template = j2_env.get_template(variant_cpp_filename)

Expand Down Expand Up @@ -1192,7 +1210,7 @@ def print_variant(generic_def):
variant_h_file.write(
variant_h_template.render(
year=datetime.datetime.now().year,
generic_def=generic_def,
generic_list=generic_list,
pins_number_list=pins_number_list,
alt_pins_list=alt_pins_list,
waltpin=max(waltpin),
Expand All @@ -1211,13 +1229,83 @@ def print_variant(generic_def):
variant_cpp_file.write(
variant_cpp_template.render(
year=datetime.datetime.now().year,
generic_def=generic_def,
generic_list=generic_list,
pinnames_list=pinnames_list,
analog_pins_list=analog_pins_list,
)
)


def print_boards_entry():
boards_entry_template = j2_env.get_template(boards_entry_filename)
# Search if several flash size
# Also used to manage define name (ARDUINO_GENERIC_*)
sub = re.search(r"STM32(.*)\((.*)\)(.*)", mcu_refname)
generic_list = []
if sub:
valueline = re.sub(r"\([\s\S]*\)", "x", mcu_refname)
for index, flash in enumerate(sub.group(2).split("-")):
gen_name = sub.group(1) + flash + sub.group(3)
generic_list.append(
{
"name": gen_name,
"board": gen_name.upper(),
"flash": mcu_flash[index],
}
)
else:
valueline = mcu_refname
generic_list.append(
{
"name": mcu_refname.replace("STM32", ""),
"board": mcu_refname.replace("STM32", "").upper(),
"flash": mcu_flash[0],
}
)

gen_entry = mcu_family.replace("STM32", "Gen")

# Parse only one time the CMSIS startup file
if mcu_family not in startup_dict:
# Search the product line
CMSIS_startup_file_path = (
system_path
/ "Drivers"
/ "CMSIS"
/ "Device"
/ "ST"
/ mcu_dir
/ "Source"
/ "Templates"
/ "gcc"
)
startup_dict[mcu_family] = sorted(
[s.name for s in CMSIS_startup_file_path.glob("startup_*.s")]
)
for s in startup_dict[mcu_family]:
mcu_line = re.split("_|\\.", s)[1]
if "stm32mp15" in mcu_line and not mcu_line.endswith("xx"):
mcu_line += "xx"
mcu_line = mcu_line.upper().replace("X", "x")
if mcu_line > valueline:
break
else:
# In case of CMSIS device does not exist
mcu_line = ""

boards_entry_file.write(
boards_entry_template.render(
generic_list=generic_list,
gen_entry=gen_entry,
mcu_name=mcu_refname,
mcu_dir=mcu_dir,
mcu_ram=mcu_ram,
product_line=mcu_line,
)
)
return generic_list


# List management
tokenize = re.compile(r"(\d+)|(\D+)").findall

Expand Down Expand Up @@ -1536,12 +1624,15 @@ def manage_repo():
root_dir = cur_dir.parents[1]
system_path = root_dir / "system"
templates_dir = cur_dir / "templates"
mcu_dir = ""
periph_c_filename = "PeripheralPins.c"
pinvar_h_filename = "PinNamesVar.h"
config_filename = Path("variant_config.json")
variant_h_filename = "variant.h"
variant_cpp_filename = "variant.cpp"
boards_entry_filename = "boards_entry.txt"
repo_local_path = cur_dir / "repo"
cubemxdir = ""
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 All @@ -1553,7 +1644,7 @@ def manage_repo():
parser = argparse.ArgumentParser(
description=textwrap.dedent(
"""\
By default, generate {}, {}, {} and {}
By default, generate {}, {}, {}, {} and {}
for all xml files description available in STM32CubeMX internal database.
Internal database path must be defined in {}.
It can be the one from STM32CubeMX directory if defined:
Expand All @@ -1566,6 +1657,7 @@ def manage_repo():
pinvar_h_filename,
variant_cpp_filename,
variant_h_filename,
boards_entry_filename,
config_filename,
cubemxdir,
gh_url,
Expand Down Expand Up @@ -1687,7 +1779,7 @@ def manage_repo():

# Open input file
xml_mcu = parse(str(mcu_file))
parse_IP_file()
parse_mcu_file()
if not gpiofile:
print("Could not find GPIO file")
quit()
Expand All @@ -1699,6 +1791,7 @@ def manage_repo():
pinvar_h_filepath = out_path / pinvar_h_filename
variant_cpp_filepath = out_path / variant_cpp_filename
variant_h_filepath = out_path / variant_h_filename
boards_entry_filepath = out_path / boards_entry_filename
out_path.mkdir(parents=True, exist_ok=True)

# open output file
Expand All @@ -1715,24 +1808,18 @@ def manage_repo():
if variant_h_filepath.exists():
variant_h_filepath.unlink()
variant_h_file = open(variant_h_filepath, "w", newline="\n")
if boards_entry_filepath.exists():
boards_entry_filepath.unlink()
boards_entry_file = open(boards_entry_filepath, "w", newline="\n")

parse_pins()
sort_my_lists()
manage_alternate()

# manage ARDUINO_GENERIC_* define name
# Search if several flash size
sub = re.search(r"STM32(.*)\((.*)\)(.*)", mcu_file.stem)
generic_def = []
if sub:
for flash in sub.group(2).split("-"):
generic_def.append((sub.group(1) + flash + sub.group(3)).upper())
else:
generic_def = [mcu_file.stem.upper()]

generic_list = print_boards_entry()
print_peripheral()
print_pinamevar()
print_variant(generic_def)
print_variant(generic_list)

print(
"* Total I/O pins found: {}".format(
Expand All @@ -1755,3 +1842,6 @@ def manage_repo():
pinvar_h_file.close()
variant_h_file.close()
variant_cpp_file.close()
boards_entry_file.close()
xml_mcu.unlink()
xml_gpio.unlink()
16 changes: 16 additions & 0 deletions CI/utils/templates/boards_entry.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file help to add generic board entry.
# upload.maximum_size and product_line have to be verified
# and changed if needed.
# See: https://github.com/stm32duino/wiki/wiki/Add-a-new-variant-%28board%29

{% for generic in generic_list %}
# Generic {{generic.name}}
{{gen_entry}}.menu.pnum.GENERIC_{{generic.board}}=Generic {{generic.name}}
{{gen_entry}}.menu.pnum.GENERIC_{{generic.board}}.upload.maximum_size={{generic.flash}}
{{gen_entry}}.menu.pnum.GENERIC_{{generic.board}}.upload.maximum_data_size={{mcu_ram}}
{{gen_entry}}.menu.pnum.GENERIC_{{generic.board}}.build.board=GENERIC_{{generic.board}}
{{gen_entry}}.menu.pnum.GENERIC_{{generic.board}}.build.product_line={{product_line}}
{{gen_entry}}.menu.pnum.GENERIC_{{generic.board}}.build.mcu_name={{mcu_name}}
{{gen_entry}}.menu.pnum.GENERIC_{{generic.board}}.build.variant={{mcu_dir}}/{{mcu_name}}

{% endfor %}