|
1 | 1 | import argparse
|
2 | 2 | import re
|
| 3 | +from itertools import groupby |
3 | 4 | from jinja2 import Environment, FileSystemLoader, Template
|
4 | 5 | from pathlib import Path
|
5 | 6 | from stm32common import createFolder, deleteFolder, genSTM32List
|
@@ -102,16 +103,29 @@ def checkConfig(arg_core, arg_cmsis):
|
102 | 103 |
|
103 | 104 | def printCMSISStartup(log):
|
104 | 105 | filelist = sorted(CMSIS_Device_ST_path.glob("**/startup_*.s"))
|
| 106 | + filelist = [pth.name for pth in filelist] |
105 | 107 | if len(filelist):
|
106 | 108 | if log:
|
107 | 109 | print("Number of startup files: {}".format(len(filelist)))
|
| 110 | + # Some mcu have two startup files |
| 111 | + # Ex: WL one for cm0plus and one for cm4 |
| 112 | + # In that case this is the same value line so add an extra defined |
| 113 | + # to use the correct one. |
| 114 | + group_startup_list = [ |
| 115 | + list(g) for _, g in groupby(filelist, lambda x: re.split("_|\\.", x)[1]) |
| 116 | + ] |
108 | 117 | cmsis_list = []
|
109 |
| - for fp in filelist: |
110 |
| - # File name |
111 |
| - fn = fp.name |
112 |
| - valueline = re.split("_|\\.", fn) |
113 |
| - vline = valueline[1].upper().replace("X", "x") |
114 |
| - cmsis_list.append({"vline": vline, "fn": fn}) |
| 118 | + for fn_list in group_startup_list: |
| 119 | + if len(fn_list) == 1: |
| 120 | + valueline = re.split("_|\\.", fn_list[0]) |
| 121 | + vline = valueline[1].upper().replace("X", "x") |
| 122 | + cmsis_list.append({"vline": vline, "fn": fn_list[0], "cm": ""}) |
| 123 | + else: |
| 124 | + for fn in fn_list: |
| 125 | + valueline = re.split("_|\\.", fn) |
| 126 | + vline = valueline[1].upper().replace("X", "x") |
| 127 | + cm = valueline[2].upper() |
| 128 | + cmsis_list.append({"vline": vline, "fn": fn, "cm": cm}) |
115 | 129 | out_file = open(CMSIS_Startupfile, "w", newline="\n")
|
116 | 130 | out_file.write(stm32_def_build_template.render(cmsis_list=cmsis_list))
|
117 | 131 | out_file.close()
|
|
0 commit comments