@@ -1130,7 +1130,9 @@ def print_pinamevar():
1130
1130
1131
1131
# Variant files generation
1132
1132
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"
1134
1136
1135
1137
# Iterate to find match instance if any
1136
1138
for mosi in spimosi_list :
@@ -2030,28 +2032,30 @@ def aggregate_dir():
2030
2032
del mcu_dir1_files_list [:]
2031
2033
2032
2034
2035
+ def default_cubemxdir ():
2036
+ global cubemxdir
2037
+ if sys .platform .startswith ("win32" ):
2038
+ print ("Platform is Windows" )
2039
+ cubemxdir = Path (r"C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX" )
2040
+ elif sys .platform .startswith ("linux" ):
2041
+ print ("Platform is Linux" )
2042
+ cubemxdir = Path .home () / "STM32CubeMX"
2043
+ elif sys .platform .startswith ("darwin" ):
2044
+ print ("Platform is Mac OSX" )
2045
+ cubemxdir = Path (
2046
+ "/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources"
2047
+ )
2048
+ else :
2049
+ print ("Platform unknown" )
2050
+ cubemxdir = "<Set CubeMX install directory>"
2051
+
2052
+
2033
2053
# Config management
2034
2054
def create_config ():
2035
2055
# Create a Json file for a better path management
2036
2056
try :
2037
2057
print ("Please set your configuration in '{}' file" .format (config_filename ))
2038
2058
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>"
2055
2059
config_file .write (
2056
2060
json .dumps (
2057
2061
{
@@ -2071,21 +2075,23 @@ def check_config():
2071
2075
global cubemxdir
2072
2076
global repo_local_path
2073
2077
global repo_path
2074
-
2078
+ default_cubemxdir ()
2075
2079
if config_filename .is_file ():
2076
2080
try :
2077
2081
config_file = open (config_filename , "r" )
2078
2082
config = json .load (config_file )
2079
2083
config_file .close ()
2080
2084
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 )
2085
+ if "REPO_LOCAL_PATH" in config :
2086
+ conf = config ["REPO_LOCAL_PATH" ]
2087
+ if conf :
2088
+ if conf != "" :
2089
+ repo_local_path = Path (conf )
2090
+ repo_path = repo_local_path / repo_name
2091
+ if "CUBEMX_DIRECTORY" in config :
2092
+ conf = config ["CUBEMX_DIRECTORY" ]
2093
+ if conf :
2094
+ cubemxdir = Path (conf )
2089
2095
except IOError :
2090
2096
print ("Failed to open " + config_filename )
2091
2097
else :
@@ -2096,9 +2102,9 @@ def manage_repo():
2096
2102
global db_release
2097
2103
repo_local_path .mkdir (parents = True , exist_ok = True )
2098
2104
2099
- print ("Updating " + repo_name + "..." )
2100
2105
try :
2101
2106
if not args .skip :
2107
+ print ("Updating " + repo_name + "..." )
2102
2108
if repo_path .is_dir ():
2103
2109
# Get new tags from the remote
2104
2110
git_cmds = [
@@ -2156,7 +2162,7 @@ def manage_repo():
2156
2162
boards_entry_filename = "boards_entry.txt"
2157
2163
generic_clock_filename = "generic_clock.c"
2158
2164
repo_local_path = cur_dir / "repo"
2159
- cubemxdir = ""
2165
+ cubemxdir = Path ()
2160
2166
gh_url = "https://github.com/STMicroelectronics/STM32_open_pin_data"
2161
2167
repo_name = gh_url .rsplit ("/" , 1 )[- 1 ]
2162
2168
repo_path = repo_local_path / repo_name
@@ -2255,6 +2261,7 @@ def manage_repo():
2255
2261
if manage_repo ():
2256
2262
dirMCU = repo_path / "mcu"
2257
2263
dirIP = dirMCU / "IP"
2264
+ print ("Using GitHub repository database" )
2258
2265
else :
2259
2266
fallback = True
2260
2267
if fallback or args .cube :
@@ -2271,6 +2278,7 @@ def manage_repo():
2271
2278
2272
2279
dirMCU = cubemxdir / "db" / "mcu"
2273
2280
dirIP = dirMCU / "IP"
2281
+ print ("Using STM32CubeMX internal database" )
2274
2282
version_file = cubemxdir / "db" / "package.xml"
2275
2283
if version_file .is_file ():
2276
2284
xml_file = parse (str (version_file ))
0 commit comments