23
23
24
24
25
25
class Sw4STM32 (Exporter ):
26
+ """
27
+ Sw4STM32 class
28
+ """
26
29
NAME = 'Sw4STM32'
27
30
TOOLCHAIN = 'GCC_ARM'
28
31
29
32
BOARDS = {
30
- 'B96B_F446VE' : {'name' : 'B96B-F446VE' , 'mcuId' : 'STM32F446VETx' },
31
- 'DISCO_F051R8' : {'name' : 'STM32F0DISCOVERY' , 'mcuId' : 'STM32F051R8Tx' },
32
- 'DISCO_F303VC' : {'name' : 'STM32F3DISCOVERY' , 'mcuId' : 'STM32F303VCTx' },
33
- 'DISCO_F334C8' : {'name' : 'STM32F3348DISCOVERY' , 'mcuId' : 'STM32F334C8Tx' },
34
- 'DISCO_F401VC' : {'name' : 'STM32F401C-DISCO' , 'mcuId' : 'STM32F401VCTx' },
35
- 'DISCO_F407VG' : {'name' : 'STM32F4DISCOVERY' , 'mcuId' : 'STM32F407VGTx' },
36
- 'DISCO_F413ZH' : {'name' : 'DISCO_F413' , 'mcuId' : 'STM32F413ZHTx' },
37
- 'DISCO_F429ZI' : {'name' : 'STM32F429I-DISCO' , 'mcuId' : 'STM32F429ZITx' },
38
- 'DISCO_F469NI' : {'name' : 'DISCO-F469NI' , 'mcuId' : 'STM32F469NIHx' },
39
- 'DISCO_F746NG' : {'name' : 'STM32F746G-DISCO' , 'mcuId' : 'STM32F746NGHx' },
40
- 'DISCO_F769NI' : {'name' : 'DISCO-F769NI' , 'mcuId' : 'STM32F769NIHx' },
41
- 'DISCO_L053C8' : {'name' : 'STM32L0538DISCOVERY' , 'mcuId' : 'STM32L053C8Tx' },
42
- 'DISCO_L072CZ_LRWAN1' : {'name' : 'DISCO-L072CZ-LRWAN1' , 'mcuId' : 'STM32L072CZTx' },
43
- 'DISCO_L475VG_IOT01A' : {'name' : 'STM32L475G-DISCO' , 'mcuId' : 'STM32L475VGTx' },
44
- 'DISCO_L476VG' : {'name' : 'STM32L476G-DISCO' , 'mcuId' : 'STM32L476VGTx' },
45
- 'NUCLEO_F030R8' : {'name' : 'NUCLEO-F030R8' , 'mcuId' : 'STM32F030R8Tx' },
46
- 'NUCLEO_F031K6' : {'name' : 'NUCLEO-F031K6' , 'mcuId' : 'STM32F031K6Tx' },
47
- 'NUCLEO_F042K6' : {'name' : 'NUCLEO-F042K6' , 'mcuId' : 'STM32F042K6Tx' },
48
- 'NUCLEO_F070RB' : {'name' : 'NUCLEO-F070RB' , 'mcuId' : 'STM32F070RBTx' },
49
- 'NUCLEO_F072RB' : {'name' : 'NUCLEO-F072RB' , 'mcuId' : 'STM32F072RBTx' },
50
- 'NUCLEO_F091RC' : {'name' : 'NUCLEO-F091RC' , 'mcuId' : 'STM32F091RCTx' },
51
- 'NUCLEO_F103RB' : {'name' : 'NUCLEO-F103RB' , 'mcuId' : 'STM32F103RBTx' },
52
- 'NUCLEO_F207ZG' : {'name' : 'NUCLEO-F207ZG' , 'mcuId' : 'STM32F207ZGTx' },
53
- 'NUCLEO_F302R8' : {'name' : 'NUCLEO-F302R8' , 'mcuId' : 'STM32F302R8Tx' },
54
- 'NUCLEO_F303K8' : {'name' : 'NUCLEO-F303K8' , 'mcuId' : 'STM32F303K8Tx' },
55
- 'NUCLEO_F303RE' : {'name' : 'NUCLEO-F303RE' , 'mcuId' : 'STM32F303RETx' },
56
- 'NUCLEO_F303ZE' : {'name' : 'NUCLEO-F303ZE' , 'mcuId' : 'STM32F303ZETx' },
57
- 'NUCLEO_F334R8' : {'name' : 'NUCLEO-F334R8' , 'mcuId' : 'STM32F334R8Tx' },
58
- 'NUCLEO_F401RE' : {'name' : 'NUCLEO-F401RE' , 'mcuId' : 'STM32F401RETx' },
59
- 'NUCLEO_F410RB' : {'name' : 'NUCLEO-F410RB' , 'mcuId' : 'STM32F410RBTx' },
60
- 'NUCLEO_F411RE' : {'name' : 'NUCLEO-F411RE' , 'mcuId' : 'STM32F411RETx' },
61
- 'NUCLEO_F429ZI' : {'name' : 'NUCLEO-F429ZI' , 'mcuId' : 'STM32F429ZITx' },
62
- 'NUCLEO_F446RE' : {'name' : 'NUCLEO-F446RE' , 'mcuId' : 'STM32F446RETx' },
63
- 'NUCLEO_F446ZE' : {'name' : 'NUCLEO-F446ZE' , 'mcuId' : 'STM32F446ZETx' },
64
- 'NUCLEO_F746ZG' : {'name' : 'NUCLEO-F746ZG' , 'mcuId' : 'STM32F746ZGTx' },
65
- 'NUCLEO_F767ZI' : {'name' : 'NUCLEO-F767ZI' , 'mcuId' : 'STM32F767ZITx' },
66
- 'NUCLEO_L011K4' : {'name' : 'NUCLEO-L011K4' , 'mcuId' : 'STM32L011K4Tx' },
67
- 'NUCLEO_L031K6' : {'name' : 'NUCLEO-L031K6' , 'mcuId' : 'STM32L031K6Tx' },
68
- 'NUCLEO_L053R8' : {'name' : 'NUCLEO-L053R8' , 'mcuId' : 'STM32L053R8Tx' },
69
- 'NUCLEO_L073RZ' : {'name' : 'NUCLEO-L073RZ' , 'mcuId' : 'STM32L073RZTx' },
70
- 'NUCLEO_L152RE' : {'name' : 'NUCLEO-L152RE' , 'mcuId' : 'STM32L152RETx' },
71
- 'NUCLEO_L432KC' : {'name' : 'NUCLEO-L432KC' , 'mcuId' : 'STM32L432KCUx' },
72
- 'NUCLEO_L476RG' : {'name' : 'NUCLEO-L476RG' , 'mcuId' : 'STM32L476RGTx' },
33
+ 'B96B_F446VE' :
34
+ {
35
+ 'name' : 'B96B-F446VE' ,
36
+ 'mcuId' : 'STM32F446VETx'
37
+ },
38
+ 'DISCO_F051R8' :
39
+ {
40
+ 'name' : 'STM32F0DISCOVERY' ,
41
+ 'mcuId' : 'STM32F051R8Tx'
42
+ },
43
+ 'DISCO_F303VC' :
44
+ {
45
+ 'name' : 'STM32F3DISCOVERY' ,
46
+ 'mcuId' : 'STM32F303VCTx'
47
+ },
48
+ 'DISCO_F334C8' :
49
+ {
50
+ 'name' : 'STM32F3348DISCOVERY' ,
51
+ 'mcuId' : 'STM32F334C8Tx'
52
+ },
53
+ 'DISCO_F401VC' :
54
+ {
55
+ 'name' : 'STM32F401C-DISCO' ,
56
+ 'mcuId' : 'STM32F401VCTx'
57
+ },
58
+ 'DISCO_F407VG' :
59
+ {
60
+ 'name' : 'STM32F4DISCOVERY' ,
61
+ 'mcuId' : 'STM32F407VGTx'
62
+ },
63
+ 'DISCO_F413ZH' :
64
+ {
65
+ 'name' : 'DISCO_F413' ,
66
+ 'mcuId' : 'STM32F413ZHTx'
67
+ },
68
+ 'DISCO_F429ZI' :
69
+ {
70
+ 'name' : 'STM32F429I-DISCO' ,
71
+ 'mcuId' : 'STM32F429ZITx'
72
+ },
73
+ 'DISCO_F469NI' :
74
+ {
75
+ 'name' : 'DISCO-F469NI' ,
76
+ 'mcuId' : 'STM32F469NIHx'
77
+ },
78
+ 'DISCO_F746NG' :
79
+ {
80
+ 'name' : 'STM32F746G-DISCO' ,
81
+ 'mcuId' : 'STM32F746NGHx'
82
+ },
83
+ 'DISCO_F769NI' :
84
+ {
85
+ 'name' : 'DISCO-F769NI' ,
86
+ 'mcuId' : 'STM32F769NIHx'
87
+ },
88
+ 'DISCO_L053C8' :
89
+ {
90
+ 'name' : 'STM32L0538DISCOVERY' ,
91
+ 'mcuId' : 'STM32L053C8Tx'
92
+ },
93
+ 'DISCO_L072CZ_LRWAN1' :
94
+ {
95
+ 'name' : 'DISCO-L072CZ-LRWAN1' ,
96
+ 'mcuId' : 'STM32L072CZTx'
97
+ },
98
+ 'DISCO_L475VG_IOT01A' :
99
+ {
100
+ 'name' : 'STM32L475G-DISCO' ,
101
+ 'mcuId' : 'STM32L475VGTx'
102
+ },
103
+ 'DISCO_L476VG' :
104
+ {
105
+ 'name' : 'STM32L476G-DISCO' ,
106
+ 'mcuId' : 'STM32L476VGTx'
107
+ },
108
+ 'NUCLEO_F030R8' :
109
+ {
110
+ 'name' : 'NUCLEO-F030R8' ,
111
+ 'mcuId' : 'STM32F030R8Tx'
112
+ },
113
+ 'NUCLEO_F031K6' :
114
+ {
115
+ 'name' : 'NUCLEO-F031K6' ,
116
+ 'mcuId' : 'STM32F031K6Tx'
117
+ },
118
+ 'NUCLEO_F042K6' :
119
+ {
120
+ 'name' : 'NUCLEO-F042K6' ,
121
+ 'mcuId' : 'STM32F042K6Tx'
122
+ },
123
+ 'NUCLEO_F070RB' :
124
+ {
125
+ 'name' : 'NUCLEO-F070RB' ,
126
+ 'mcuId' : 'STM32F070RBTx'
127
+ },
128
+ 'NUCLEO_F072RB' :
129
+ {
130
+ 'name' : 'NUCLEO-F072RB' ,
131
+ 'mcuId' : 'STM32F072RBTx'
132
+ },
133
+ 'NUCLEO_F091RC' :
134
+ {
135
+ 'name' : 'NUCLEO-F091RC' ,
136
+ 'mcuId' : 'STM32F091RCTx'
137
+ },
138
+ 'NUCLEO_F103RB' :
139
+ {
140
+ 'name' : 'NUCLEO-F103RB' ,
141
+ 'mcuId' : 'STM32F103RBTx'
142
+ },
143
+ 'NUCLEO_F207ZG' :
144
+ {
145
+ 'name' : 'NUCLEO-F207ZG' ,
146
+ 'mcuId' : 'STM32F207ZGTx'
147
+ },
148
+ 'NUCLEO_F302R8' :
149
+ {
150
+ 'name' : 'NUCLEO-F302R8' ,
151
+ 'mcuId' : 'STM32F302R8Tx'
152
+ },
153
+ 'NUCLEO_F303K8' :
154
+ {
155
+ 'name' : 'NUCLEO-F303K8' ,
156
+ 'mcuId' : 'STM32F303K8Tx'
157
+ },
158
+ 'NUCLEO_F303RE' :
159
+ {
160
+ 'name' : 'NUCLEO-F303RE' ,
161
+ 'mcuId' : 'STM32F303RETx'
162
+ },
163
+ 'NUCLEO_F303ZE' :
164
+ {
165
+ 'name' : 'NUCLEO-F303ZE' ,
166
+ 'mcuId' : 'STM32F303ZETx'
167
+ },
168
+ 'NUCLEO_F334R8' :
169
+ {
170
+ 'name' : 'NUCLEO-F334R8' ,
171
+ 'mcuId' : 'STM32F334R8Tx'
172
+ },
173
+ 'NUCLEO_F401RE' :
174
+ {
175
+ 'name' : 'NUCLEO-F401RE' ,
176
+ 'mcuId' : 'STM32F401RETx'
177
+ },
178
+ 'NUCLEO_F410RB' :
179
+ {
180
+ 'name' : 'NUCLEO-F410RB' ,
181
+ 'mcuId' : 'STM32F410RBTx'
182
+ },
183
+ 'NUCLEO_F411RE' :
184
+ {
185
+ 'name' : 'NUCLEO-F411RE' ,
186
+ 'mcuId' : 'STM32F411RETx'
187
+ },
188
+ 'NUCLEO_F429ZI' :
189
+ {
190
+ 'name' : 'NUCLEO-F429ZI' ,
191
+ 'mcuId' : 'STM32F429ZITx'
192
+ },
193
+ 'NUCLEO_F446RE' :
194
+ {
195
+ 'name' : 'NUCLEO-F446RE' ,
196
+ 'mcuId' : 'STM32F446RETx'
197
+ },
198
+ 'NUCLEO_F446ZE' :
199
+ {
200
+ 'name' : 'NUCLEO-F446ZE' ,
201
+ 'mcuId' : 'STM32F446ZETx'
202
+ },
203
+ 'NUCLEO_F746ZG' :
204
+ {
205
+ 'name' : 'NUCLEO-F746ZG' ,
206
+ 'mcuId' : 'STM32F746ZGTx'
207
+ },
208
+ 'NUCLEO_F767ZI' :
209
+ {
210
+ 'name' : 'NUCLEO-F767ZI' ,
211
+ 'mcuId' : 'STM32F767ZITx'
212
+ },
213
+ 'NUCLEO_L011K4' :
214
+ {
215
+ 'name' : 'NUCLEO-L011K4' ,
216
+ 'mcuId' : 'STM32L011K4Tx'
217
+ },
218
+ 'NUCLEO_L031K6' :
219
+ {
220
+ 'name' : 'NUCLEO-L031K6' ,
221
+ 'mcuId' : 'STM32L031K6Tx'
222
+ },
223
+ 'NUCLEO_L053R8' :
224
+ {
225
+ 'name' : 'NUCLEO-L053R8' ,
226
+ 'mcuId' : 'STM32L053R8Tx'
227
+ },
228
+ 'NUCLEO_L073RZ' :
229
+ {
230
+ 'name' : 'NUCLEO-L073RZ' ,
231
+ 'mcuId' : 'STM32L073RZTx'
232
+ },
233
+ 'NUCLEO_L152RE' :
234
+ {
235
+ 'name' : 'NUCLEO-L152RE' ,
236
+ 'mcuId' : 'STM32L152RETx'
237
+ },
238
+ 'NUCLEO_L432KC' :
239
+ {
240
+ 'name' : 'NUCLEO-L432KC' ,
241
+ 'mcuId' : 'STM32L432KCUx'
242
+ },
243
+ 'NUCLEO_L476RG' :
244
+ {
245
+ 'name' : 'NUCLEO-L476RG' ,
246
+ 'mcuId' : 'STM32L476RGTx'
247
+ },
73
248
}
74
249
75
250
TARGETS = BOARDS .keys ()
76
251
77
- def __gen_dir (self , dirname ):
78
- settings = join (self .export_dir , dirname )
252
+ def __gen_dir (self , dir_name ):
253
+ """
254
+ Method that created directory
255
+ """
256
+ settings = join (self .export_dir , dir_name )
79
257
mkdir (settings )
80
258
81
259
def __generate_uid (self ):
260
+ """
261
+ Method to create random int
262
+ """
82
263
return "%0.9u" % randint (0 , 999999999 )
83
264
84
265
@staticmethod
@@ -94,32 +275,44 @@ def filter_dot(path):
94
275
return path
95
276
96
277
def build_excludelist (self ):
97
- self .source_folders = [self .filter_dot (s ) for s in set (dirname (
98
- src ) for src in self .resources .c_sources + self .resources .cpp_sources + self .resources .s_sources )]
278
+ """
279
+ This method creates list for excluded directories.
280
+ """
281
+ self .source_folders = [self .filter_dot (s )
282
+ for s in set (dirname (src ) for src in
283
+ self .resources .c_sources +
284
+ self .resources .cpp_sources +
285
+ self .resources .s_sources )]
99
286
if '.' in self .source_folders :
100
287
self .source_folders .remove ('.' )
101
288
102
- top_folders = [f for f in set (s .split ('/' )[0 ] for s in self .source_folders )]
289
+ top_folders = [f for f in set (s .split ('/' )[0 ]
290
+ for s in self .source_folders )]
103
291
104
292
for top_folder in top_folders :
105
293
for root , dirs , files in walk (top_folder , topdown = True ):
106
294
# Paths returned by os.walk() must be split with os.dep
107
295
# to accomodate Windows weirdness.
108
296
parts = root .split (sep )
109
297
self .remove_unused ('/' .join (parts ))
110
-
298
+
111
299
def remove_unused (self , path ):
112
- found = False
300
+ """
301
+ Method for checking if path is needed.
302
+ Method adds path to excluded list if not needed
303
+ and is not subdirectory of already excluded directory
304
+ """
305
+ found = False
113
306
for used in self .include_path :
114
307
if path == used :
115
308
found = True
116
- needToAdd = True
309
+ needtoadd = True
117
310
if not found :
118
- for dir in self .exclude_dirs :
311
+ for directory in self .exclude_dirs :
119
312
# Do not exclude subfolders from excluded folder
120
- if path .find (dir + '/' ) != - 1 :
121
- needToAdd = False
122
- if needToAdd :
313
+ if path .find (directory + '/' ) != - 1 :
314
+ needtoadd = False
315
+ if needtoadd :
123
316
self .exclude_dirs .append (path )
124
317
125
318
def generate (self ):
@@ -137,10 +330,11 @@ def generate(self):
137
330
138
331
libraries = []
139
332
for lib in self .resources .libraries :
140
- l , _ = splitext (basename (lib ))
141
- libraries .append (l [3 :])
333
+ library , _ = splitext (basename (lib ))
334
+ libraries .append (library [3 :])
142
335
143
- self .include_path = [self .filter_dot (s ) for s in self .resources .inc_dirs ]
336
+ self .include_path = [self .filter_dot (s )
337
+ for s in self .resources .inc_dirs ]
144
338
print 'Include folders: %d' % len (self .include_path )
145
339
146
340
self .exclude_dirs = []
@@ -150,21 +344,23 @@ def generate(self):
150
344
151
345
self .exclude_dirs = '|' .join (self .exclude_dirs )
152
346
153
- self . ld_script = self .filter_dot (self .resources .linker_script )
347
+ ld_script = self .filter_dot (self .resources .linker_script )
154
348
155
- self .lib_dirs = [self .filter_dot (s ) for s in self .resources .lib_dirs ]
349
+ # self.lib_dirs = [self.filter_dot(s) for s in self.resources.lib_dirs]
350
+ lib_dirs = [self .filter_dot (s ) for s in self .resources .lib_dirs ]
156
351
157
- self .symbols = [s .replace ('"' , '"' ) for s in self .toolchain .get_symbols ()]
352
+ symbols = [s .replace ('"' , '"' )
353
+ for s in self .toolchain .get_symbols ()]
158
354
159
355
ctx = {
160
356
'name' : self .project_name ,
161
357
'include_paths' : self .include_path ,
162
358
'exclude_paths' : self .exclude_dirs ,
163
- 'linker_script' : self . ld_script ,
164
- 'library_paths' : self . lib_dirs ,
359
+ 'linker_script' : ld_script ,
360
+ 'library_paths' : lib_dirs ,
165
361
'object_files' : self .resources .objects ,
166
362
'libraries' : libraries ,
167
- 'symbols' : self . symbols ,
363
+ 'symbols' : symbols ,
168
364
'board_name' : self .BOARDS [self .target .upper ()]['name' ],
169
365
'mcu_name' : self .BOARDS [self .target .upper ()]['mcuId' ],
170
366
'c_include_uid' : self .__generate_uid (),
0 commit comments