Skip to content

Commit 52f189a

Browse files
committed
Add script to update HAL drivers and CMSIS devices
from STM32cube released on GitHub Signed-off-by: Frederic Pillon <[email protected]>
1 parent f5768cb commit 52f189a

File tree

3 files changed

+576
-0
lines changed

3 files changed

+576
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ astyle.out
33
boards.local.txt
44
platform.local.txt
55
path_config.json
6+
update_config.json
67

78
# Backup
89
*.bak

Diff for: CI/utils/stm32common.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import os
2+
import re
3+
import shutil
4+
5+
6+
# Create a folder if not exists
7+
def createFolder(path):
8+
try:
9+
if not os.path.exists(path):
10+
os.makedirs(path)
11+
except OSError:
12+
print("Error: Creating directory. " + path)
13+
14+
15+
# Delete targeted folder recursively
16+
def deleteFolder(path):
17+
if os.path.isdir(path):
18+
shutil.rmtree(path, ignore_errors=True)
19+
20+
21+
# copy src folder recursively to dest
22+
def copyFolder(src, dest, ign_patt=set()):
23+
try:
24+
if os.path.isdir(src):
25+
shutil.copytree(src, dest, ignore=shutil.ignore_patterns(*ign_patt))
26+
except OSError as e:
27+
print("Error: Folder %s not copied. %s" % src, e)
28+
29+
30+
def genSTM32List(path, pattern):
31+
stm32_list = [] # Serie
32+
dir_pattern = re.compile("^STM32(.*)xx_HAL_Driver$", re.IGNORECASE)
33+
34+
if pattern is not None:
35+
serie_pattern = re.compile(pattern, re.IGNORECASE)
36+
else:
37+
serie_pattern = re.compile(".*", re.IGNORECASE)
38+
39+
for file in os.listdir(path):
40+
res = dir_pattern.match(file)
41+
if res and serie_pattern.search(res.group(1)):
42+
stm32_list.append(res.group(1))
43+
stm32_list.sort()
44+
return stm32_list

0 commit comments

Comments
 (0)