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

feat(debug): implement latest arduino-cli specifications #2409

Merged
merged 12 commits into from
Jun 27, 2024
Merged
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ boards.local.txt
platform.local.txt
path_config.json
update_config.json
variant_config.json

# Backup
*.bak
Expand Down
28 changes: 9 additions & 19 deletions CI/update/stm32cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
script_path = Path(__file__).parent.resolve()
sys.path.append(str(script_path.parent))
from utils import copyFile, copyFolder, createFolder, deleteFolder, genSTM32List
from utils import execute_cmd, getRepoBranchName
from utils import defaultConfig, execute_cmd, getRepoBranchName

if sys.platform.startswith("win32"):
from colorama import init

init(autoreset=True)

home = Path.home()
path_config_filename = "update_config.json"

# GitHub
gh_st = "https://github.com/STMicroelectronics/"
Expand Down Expand Up @@ -85,19 +84,6 @@
out_separator = "-" * 70


def create_config(config_file_path):
global repo_local_path

# Create a Json file for a better path management
print(f"'{config_file_path}' file created. Please check the configuration.")
path_config_file = open(config_file_path, "w")
path_config_file.write(
json.dumps({"REPO_LOCAL_PATH": str(repo_local_path)}, indent=2)
)
path_config_file.close()
exit(1)


def checkConfig():
global repo_local_path
global hal_dest_path
Expand All @@ -107,14 +93,18 @@ def checkConfig():
global md_CMSIS_path
global stm32_def

config_file_path = script_path / path_config_filename
config_file_path = script_path / "update_config.json"
if config_file_path.is_file():
try:
config_file = open(config_file_path, "r")
path_config = json.load(config_file)
# Common path
repo_local_path = Path(path_config["REPO_LOCAL_PATH"])
config_file.close()
# Common path
if "REPO_LOCAL_PATH" not in path_config:
path_config["REPO_LOCAL_PATH"] = str(repo_local_path)
defaultConfig(config_file_path, path_config)
else:
repo_local_path = Path(path_config["REPO_LOCAL_PATH"])
hal_dest_path = repo_local_path / repo_core_name / hal_dest_path
md_HAL_path = hal_dest_path / md_HAL_path
cmsis_dest_path = repo_local_path / repo_core_name / cmsis_dest_path
Expand All @@ -130,7 +120,7 @@ def checkConfig():
except IOError:
print(f"Failed to open {config_file}!")
else:
create_config(config_file_path)
defaultConfig(config_file_path, {"REPO_LOCAL_PATH": str(repo_local_path)})
createFolder(repo_local_path)


Expand Down
97 changes: 97 additions & 0 deletions CI/update/stm32svd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import json
import sys
from pathlib import Path

script_path = Path(__file__).parent.resolve()
sys.path.append(str(script_path.parent))
from utils import copyFile, copyFolder, createFolder, deleteFolder
from utils import defaultConfig, genSTM32List

stm32_list = [] # series
root_path = script_path.parent.parent.resolve()
hal_path = root_path / "system" / "Drivers"
cubeclt_path = Path("")
cubeclt_svd_path = Path("")
stm32_svd_repo = Path("")
stm32_svd_dir = Path("")


def checkConfig():
global cubeclt_path
global cubeclt_svd_path
global stm32_svd_repo
global stm32_svd_dir
config_file_path = script_path / "update_config.json"
if config_file_path.is_file():
try:
config_file = open(config_file_path, "r")
path_config = json.load(config_file)
config_file.close()

if "STM32CUBECLT_PATH" not in path_config:
path_config["STM32CUBECLT_PATH"] = str(
"Path to STM32CubeCLT installation directory"
)
defaultConfig(config_file_path, path_config)
else:
cubeclt_path = Path(path_config["STM32CUBECLT_PATH"])
if not cubeclt_path.is_dir():
print(f"{cubeclt_path} does not exist!")
exit(1)
else:
cubeclt_svd_path = cubeclt_path / "STMicroelectronics_CMSIS_SVD"
if not cubeclt_svd_path.is_dir():
print(f"{cubeclt_svd_path} does not exist!")
exit(1)
if "STM32_SVD_PATH" not in path_config:
path_config["STM32_SVD_PATH"] = str("Path to stm32_svd repository")
defaultConfig(config_file_path, path_config)
else:
stm32_svd_repo = Path(path_config["STM32_SVD_PATH"])
if not stm32_svd_repo.is_dir():
print(f"{stm32_svd_repo} does not exist!")
exit(1)
else:
stm32_svd_dir = stm32_svd_repo / "svd"
except IOError:
print(f"Failed to open {config_file}!")
else:
defaultConfig(
config_file_path,
{"STM32CUBECLT_PATH": "Path to STM32CubeCLT installation directory"},
)


def main():
global stm32_list
# check config have to be done first
checkConfig()
stm32_list = genSTM32List(hal_path, None)
# Reverse order to get WBA before WB to ease svd sorting
stm32_list.sort(reverse=True)
# Clean up core svd folder
deleteFolder(stm32_svd_dir)
createFolder(stm32_svd_dir)
# Update the Core folder
copyFolder(cubeclt_svd_path / "Core", stm32_svd_dir / "Core")
# Update the license
copyFile(cubeclt_svd_path / "about.html", stm32_svd_dir)
# Copy the version
copyFile(cubeclt_path / ".version", stm32_svd_dir / "STM32CubeCLT.version")
# Create all directories
for serie in stm32_list:
createFolder(stm32_svd_dir / f"STM32{serie}xx")
# Get all xml files
svd_list = sorted(cubeclt_svd_path.glob("STM32*.svd"))

# Copy all svd files per series
for svd_file in svd_list:
svd_name = svd_file.name
for serie in stm32_list:
if svd_name.find(f"STM32{serie}") != -1:
copyFile(svd_file, stm32_svd_dir / f"STM32{serie}xx")
break


if __name__ == "__main__":
main()
Loading
Loading