2
2
from builtins import str
3
3
4
4
import os
5
- from os .path import sep , normpath , join , exists , dirname
5
+ from os .path import normpath , exists , dirname
6
6
import ntpath
7
7
import copy
8
8
from collections import namedtuple
11
11
import re
12
12
13
13
from tools .resources import FileType
14
- from tools .arm_pack_manager import Cache
15
14
from tools .targets import TARGET_MAP
16
- from tools .export .exporters import Exporter , apply_supported_whitelist
15
+ from tools .export .exporters import Exporter
17
16
from tools .export .cmsis import DeviceCMSIS
18
17
18
+
19
19
class DeviceUvision (DeviceCMSIS ):
20
20
"""Uvision Device class, inherits CMSIS Device class
21
21
@@ -32,7 +32,7 @@ def __init__(self, target):
32
32
33
33
def uv_debug (self ):
34
34
"""Return a namedtuple of information about uvision debug settings"""
35
- UVDebug = namedtuple ('UVDebug' ,['bin_loc' ,'core_flag' , 'key' ])
35
+ UVDebug = namedtuple ('UVDebug' , ['bin_loc' , 'core_flag' , 'key' ])
36
36
37
37
# CortexMXn => pCMX
38
38
cpu = self .core .replace ("Cortex-" , "C" )
@@ -42,10 +42,13 @@ def uv_debug(self):
42
42
cpu_flag = "p" + cpu
43
43
44
44
# Locations found in Keil_v5/TOOLS.INI
45
- debuggers = {"st-link" : ('STLink\\ ST-LINKIII-KEIL_SWO.dll' , 'ST-LINKIII-KEIL_SWO' ),
46
- "j-link" :('Segger\\ JL2CM3.dll' , 'JL2CM3' ),
47
- "cmsis-dap" :('BIN\\ CMSIS_AGDI.dll' , 'CMSIS_AGDI' ),
48
- "nulink" :('NULink\\ Nu_Link.dll' ,'Nu_Link' )}
45
+ debuggers = {
46
+ "st-link" : ('STLink\\ ST-LINKIII-KEIL_SWO.dll' ,
47
+ 'ST-LINKIII-KEIL_SWO' ),
48
+ "j-link" : ('Segger\\ JL2CM3.dll' , 'JL2CM3' ),
49
+ "cmsis-dap" : ('BIN\\ CMSIS_AGDI.dll' , 'CMSIS_AGDI' ),
50
+ "nulink" : ('NULink\\ Nu_Link.dll' , 'Nu_Link' )
51
+ }
49
52
res = debuggers [self .debug .lower ()]
50
53
binary = res [0 ]
51
54
key = res [1 ]
@@ -57,7 +60,7 @@ def generate_flash_dll(self):
57
60
S = SW/JTAG Clock ID
58
61
C = CPU index in JTAG chain
59
62
P = Access Port
60
- For the Options for Target -> Debug tab -> settings -> "Flash" tab in the dialog:
63
+ For the Options for Target -> Debug -> settings -> "Flash" dialog:
61
64
FD = RAM Start for Flash Functions
62
65
FC = RAM Size for Flash Functions
63
66
FN = Number of Flash types
@@ -66,44 +69,55 @@ def generate_flash_dll(self):
66
69
FL = Size of the Flash Device
67
70
FP = Full path to the Device algorithm (RTE)
68
71
69
- Necessary to flash some targets. Info gathered from algorithms field of pdsc file.
72
+ Necessary to flash some targets.
70
73
'''
71
74
fl_count = 0
75
+
72
76
def get_mem_no_x (mem_str ):
73
77
mem_reg = "\dx(\w+)"
74
78
m = re .search (mem_reg , mem_str )
75
79
return m .group (1 ) if m else None
76
80
77
- RAMS = [(get_mem_no_x (info ["start" ]), get_mem_no_x (info ["size" ]))
78
- for mem , info in self .target_info ["memory" ].items () if "RAM" in mem ]
79
- format_str = "UL2CM3(-S0 -C0 -P0 -FD{ramstart}" + " -FC{ramsize} " + "-FN{num_algos} {extra_flags})"
81
+ RAMS = [
82
+ (get_mem_no_x (info ["start" ]), get_mem_no_x (info ["size" ]))
83
+ for mem , info in self .target_info ["memory" ].items () if "RAM" in mem
84
+ ]
85
+ format_str = (
86
+ "UL2CM3(-S0 -C0 -P0 -FD{ramstart}"
87
+ " -FC{ramsize} -FN{num_algos} {extra_flags})"
88
+ )
80
89
ramstart = ''
81
- #Default according to Keil developer
90
+ # Default according to Keil developer
82
91
ramsize = '1000'
83
- if len (RAMS )>= 1 :
92
+ if len (RAMS ) >= 1 :
84
93
ramstart = RAMS [0 ][0 ]
85
94
extra_flags = []
86
95
for name , info in self .target_info ["algorithm" ].items ():
87
96
if not name or not info :
88
97
continue
89
- if int (info ["default" ])== 0 :
98
+ if int (info ["default" ]) == 0 :
90
99
continue
91
100
name_reg = "\w*/([\w_]+)\.flm"
92
101
m = re .search (name_reg , name .lower ())
93
102
fl_name = m .group (1 ) if m else None
94
103
name_flag = "-FF" + str (fl_count ) + fl_name
95
104
96
- start , size = get_mem_no_x (info ["start" ]), get_mem_no_x (info ["size" ])
97
- rom_start_flag = "-FS" + str (fl_count )+ str (start )
105
+ start = get_mem_no_x (info ["start" ])
106
+ size = get_mem_no_x (info ["size" ])
107
+ rom_start_flag = "-FS" + str (fl_count ) + str (start )
98
108
rom_size_flag = "-FL" + str (fl_count ) + str (size )
99
109
100
110
if info ["ramstart" ] is not None and info ["ramsize" ] is not None :
101
111
ramstart = get_mem_no_x (info ["ramstart" ])
102
112
ramsize = get_mem_no_x (info ["ramsize" ])
103
113
104
- path_flag = "-FP" + str (fl_count ) + "($$Device:" + self .dname + "$" + name + ")"
114
+ path_flag = "-FP{}($$Device:{}${})" .format (
115
+ str (fl_count ), self .dname , name
116
+ )
105
117
106
- extra_flags .extend ([name_flag , rom_start_flag , rom_size_flag , path_flag ])
118
+ extra_flags .extend ([
119
+ name_flag , rom_start_flag , rom_size_flag , path_flag
120
+ ])
107
121
fl_count += 1
108
122
109
123
extra = " " .join (extra_flags )
@@ -130,8 +144,7 @@ class Uvision(Exporter):
130
144
"NCS36510TargetCode.ncs36510_addfib"
131
145
])
132
146
133
-
134
- #File associations within .uvprojx file
147
+ # File associations within .uvprojx file
135
148
file_types = {'.cpp' : 8 , '.c' : 1 , '.s' : 2 ,
136
149
'.obj' : 3 , '.o' : 3 , '.lib' : 4 ,
137
150
'.ar' : 4 , '.h' : 5 , '.hpp' : 5 , '.sct' : 4 }
@@ -149,8 +162,8 @@ def uv_files(self, files):
149
162
</File>
150
163
"""
151
164
for loc in files :
152
- #Encapsulates the information necessary for template entry above
153
- UVFile = namedtuple ('UVFile' , ['type' ,'loc' ,'name' ])
165
+ # Encapsulates the information necessary for template entry above
166
+ UVFile = namedtuple ('UVFile' , ['type' , 'loc' , 'name' ])
154
167
_ , ext = os .path .splitext (loc )
155
168
if ext .lower () in self .file_types :
156
169
type = self .file_types [ext .lower ()]
@@ -212,11 +225,11 @@ def format_fpu(core):
212
225
213
226
def generate (self ):
214
227
"""Generate the .uvproj file"""
215
- cache = Cache ( True , False )
216
-
217
- srcs = self .resources .headers + self .resources .s_sources + \
218
- self .resources .c_sources + self .resources . cpp_sources + \
219
- self . resources . objects + self . libraries
228
+ srcs = (
229
+ self . resources . headers + self . resources . s_sources +
230
+ self .resources .c_sources + self .resources .cpp_sources +
231
+ self .resources .objects + self .libraries
232
+ )
220
233
ctx = {
221
234
'name' : self .project_name ,
222
235
# project_files => dict of generators - file group to generator of
@@ -227,7 +240,8 @@ def generate(self):
227
240
self .resources .inc_dirs ).encode ('utf-8' ),
228
241
'device' : DeviceUvision (self .target ),
229
242
}
230
- sct_name , sct_path = self .resources .get_file_refs (FileType .LD_SCRIPT )[0 ]
243
+ sct_name , sct_path = self .resources .get_file_refs (
244
+ FileType .LD_SCRIPT )[0 ]
231
245
ctx ['linker_script' ] = self .toolchain .correct_scatter_shebang (
232
246
sct_path , dirname (sct_name ))
233
247
if ctx ['linker_script' ] != sct_path :
@@ -243,8 +257,12 @@ def generate(self):
243
257
ctx ['armc6' ] = int (self .TOOLCHAIN is 'ARMC6' )
244
258
ctx ['toolchain_name' ] = self .TOOLCHAIN_NAME
245
259
ctx .update (self .format_flags ())
246
- self .gen_file ('uvision/uvision.tmpl' , ctx , self .project_name + ".uvprojx" )
247
- self .gen_file ('uvision/uvision_debug.tmpl' , ctx , self .project_name + ".uvoptx" )
260
+ self .gen_file (
261
+ 'uvision/uvision.tmpl' , ctx , self .project_name + ".uvprojx"
262
+ )
263
+ self .gen_file (
264
+ 'uvision/uvision_debug.tmpl' , ctx , self .project_name + ".uvoptx"
265
+ )
248
266
249
267
@staticmethod
250
268
def clean (project_name ):
@@ -284,6 +302,7 @@ def build(project_name, log_name='build_log.txt', cleanup=True):
284
302
else :
285
303
return 0
286
304
305
+
287
306
class UvisionArmc5 (Uvision ):
288
307
NAME = 'uvision5-armc5'
289
308
TOOLCHAIN = 'ARM'
@@ -306,12 +325,6 @@ def is_target_supported(cls, target_name):
306
325
else :
307
326
return False
308
327
309
- @classmethod
310
- def is_target_supported (cls , target_name ):
311
- target = TARGET_MAP [target_name ]
312
- return apply_supported_whitelist (
313
- cls .TOOLCHAIN , cls .POST_BINARY_WHITELIST , target ) and \
314
- DeviceCMSIS .check_supported (target_name )
315
328
316
329
class UvisionArmc6 (Uvision ):
317
330
NAME = 'uvision5-armc6'
0 commit comments