Skip to content

Commit 6bd3caa

Browse files
committed
Merge pull request #1607 from 0xc0170/dev_uvision_progen
uvision progen
2 parents 287c3b7 + 439c779 commit 6bd3caa

File tree

170 files changed

+212
-52238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+212
-52238
lines changed

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ prettytable
44
Jinja2
55
IntelHex
66
mbed-ls
7-
project-generator>=0.8.8,<0.9.0
7+
project-generator>=0.8.11,<0.9.0
88
junit-xml
9-
requests
9+
requests

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
url='https://github.com/mbedmicro/mbed',
4141
packages=find_packages(),
4242
license=LICENSE,
43-
install_requires=["PrettyTable>=0.7.2", "PySerial>=2.7", "IntelHex>=1.3", "colorama>=0.3.3", "Jinja2>=2.7.3", "project-generator>=0.8.8,<0.9.0", "junit-xml", "requests"])
43+
install_requires=["PrettyTable>=0.7.2", "PySerial>=2.7", "IntelHex>=1.3", "colorama>=0.3.3", "Jinja2>=2.7.3", "project-generator>=0.8.11,<0.9.0", "junit-xml", "requests"])
4444

4545
# Restore previous private_settings if needed
4646
if backup:

workspace_tools/export/uvision4_kl25z.uvproj.tmpl renamed to workspace_tools/export/uvision.uvproj.tmpl

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<InvalidFlash>1</InvalidFlash>
4545
</TargetStatus>
4646
<OutputDirectory>.\build\</OutputDirectory>
47-
<OutputName>{{name}}</OutputName>
47+
<OutputName>MBED_11</OutputName>
4848
<CreateExecutable>1</CreateExecutable>
4949
<CreateLib>0</CreateLib>
5050
<CreateHexFile>0</CreateHexFile>
@@ -75,7 +75,7 @@
7575
<AfterMake>
7676
<RunUserProg1>1</RunUserProg1>
7777
<RunUserProg2>0</RunUserProg2>
78-
<UserProg1Name>fromelf --bin -o build\{{name}}_KL25Z.bin build\{{name}}.axf</UserProg1Name>
78+
<UserProg1Name>fromelf --bin --output=@L.bin !L</UserProg1Name>
7979
<UserProg2Name></UserProg2Name>
8080
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
8181
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
@@ -345,11 +345,12 @@
345345
<wLevel>0</wLevel>
346346
<uThumb>0</uThumb>
347347
<uSurpInc>0</uSurpInc>
348+
<uC99>1</uC99>
348349
<VariousControls>
349-
<MiscControls>{% for flag in flags %}{{flag}} {% endfor %}</MiscControls>
350-
<Define>{% for s in symbols %} {{s}}, {% endfor %}</Define>
350+
<MiscControls>--gnu --no_rtti</MiscControls>
351+
<Define> </Define>
351352
<Undefine></Undefine>
352-
<IncludePath> {% for path in include_paths %} {{path}}; {% endfor %} </IncludePath>
353+
<IncludePath> </IncludePath>
353354
</VariousControls>
354355
</Cads>
355356
<Aads>
@@ -377,45 +378,24 @@
377378
<useFile>0</useFile>
378379
<TextAddressRange>0x00000000</TextAddressRange>
379380
<DataAddressRange>0x10000000</DataAddressRange>
380-
<ScatterFile>{{scatter_file}}</ScatterFile>
381+
<ScatterFile>mbed\TARGET_KL25Z\TOOLCHAIN_ARM_STD\MKL25Z4.sct</ScatterFile>
381382
<IncludeLibs></IncludeLibs>
382383
<IncludeLibsPath></IncludeLibsPath>
383384
<Misc>
384-
{% for file in object_files %}
385-
{{file}}
386-
{% endfor %}
387385
</Misc>
388386
<LinkerInputFile></LinkerInputFile>
389387
<DisabledWarnings></DisabledWarnings>
390388
</LDads>
391389
</TargetArmAds>
392390
</TargetOption>
393391
<Groups>
394-
{% for group,files in source_files %}
392+
395393
<Group>
396-
<GroupName>{{group}}</GroupName>
394+
<GroupName>src</GroupName>
397395
<Files>
398-
{% for file in files %}
399-
<File>
400-
<FileName>{{file.name}}</FileName>
401-
<FileType>{{file.type}}</FileType>
402-
<FilePath>{{file.path}}</FilePath>
403-
{%if file.type == "1" %}
404-
<FileOption>
405-
<FileArmAds>
406-
<Cads>
407-
<VariousControls>
408-
<MiscControls>--c99</MiscControls>
409-
</VariousControls>
410-
</Cads>
411-
</FileArmAds>
412-
</FileOption>
413-
{% endif %}
414-
</File>
415-
{% endfor %}
416396
</Files>
417397
</Group>
418-
{% endfor %}
398+
419399
</Groups>
420400
</Target>
421401
</Targets>

workspace_tools/export/uvision4.py

Lines changed: 50 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -14,199 +14,62 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17-
from exporters import Exporter
18-
from os.path import basename
17+
from os.path import basename, join, dirname
18+
from project_generator_definitions.definitions import ProGenDef
1919

20+
from workspace_tools.export.exporters import Exporter
21+
from workspace_tools.targets import TARGET_MAP, TARGET_NAMES
2022

23+
# If you wish to add a new target, add it to project_generator_definitions, and then
24+
# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
25+
# There are 2 default mbed templates (predefined settings) uvision.uvproj and uvproj_microlib.uvproj.tmpl
2126
class Uvision4(Exporter):
27+
"""
28+
Exporter class for uvision. This class uses project generator.
29+
"""
30+
# These 2 are currently for exporters backward compatiblity
2231
NAME = 'uVision4'
32+
TOOLCHAIN = 'ARM'
33+
# PROGEN_ACTIVE contains information for exporter scripts that this is using progen
34+
PROGEN_ACTIVE = True
2335

24-
TARGETS = [
25-
'LPC1768',
26-
'LPC11U24',
27-
'LPC11U35_401',
28-
'LPC11U35_501',
29-
'KL05Z',
30-
'KL25Z',
31-
'KL43Z',
32-
'KL46Z',
33-
'K64F',
34-
'K22F',
35-
'K20D50M',
36-
'TEENSY3_1',
37-
'LPC1347',
38-
'LPC1114',
39-
'LPC11C24',
40-
'LPC4088',
41-
'LPC4088_DM',
42-
'LPC4330_M4',
43-
'LPC4337',
44-
'LPC812',
45-
'LPC824',
46-
'SSCI824',
47-
'NUCLEO_F030R8',
48-
'NUCLEO_F031K6',
49-
'NUCLEO_F042K6',
50-
'NUCLEO_F070RB',
51-
'NUCLEO_F072RB',
52-
'NUCLEO_F091RC',
53-
'NUCLEO_F103RB',
54-
'NUCLEO_F302R8',
55-
'NUCLEO_F303K8',
56-
'NUCLEO_F303RE',
57-
'NUCLEO_F334R8',
58-
'NUCLEO_F401RE',
59-
'NUCLEO_F410RB',
60-
'NUCLEO_F411RE',
61-
'NUCLEO_F446RE',
62-
'NUCLEO_F746ZG',
63-
'NUCLEO_L053R8',
64-
'NUCLEO_L073RZ',
65-
'NUCLEO_L152RE',
66-
'NUCLEO_L476RG',
67-
'B96B_F446VE',
68-
'UBLOX_C027',
69-
'LPC1549',
70-
'LPC11U68',
71-
# Removed as uvision4_lpc11u35_501.uvproj.tmpl is missing.
72-
#'LPC11U35_501',
73-
'NRF51822',
74-
'HRM1017',
75-
'RBLAB_NRF51822',
76-
'ARCH_PRO',
77-
'ARCH_BLE',
78-
'DISCO_F051R8',
79-
'DISCO_F100RB',
80-
'DISCO_F303VC',
81-
'DISCO_F407VG',
82-
'DISCO_F429ZI',
83-
'DISCO_F469NI',
84-
'DISCO_L053C8',
85-
'DISCO_F334C8',
86-
'DISCO_F746NG',
87-
'DISCO_L476VG',
88-
'MTS_GAMBIT',
89-
'ARCH_MAX',
90-
'MTS_MDOT_F405RG',
91-
'NRF51_DK',
92-
'NRF51_DONGLE',
93-
'SEEED_TINY_BLE',
94-
'LPC11U37H_401',
95-
'DELTA_DFCM_NNN40',
96-
'MAXWSNENV',
97-
'MAX32600MBED',
98-
'MOTE_L152RC',
99-
'NZ32_SC151',
100-
'SAMR21G18A',
101-
'SAMD21J18A',
102-
'SAMD21G18A',
103-
'SAML21J18A',
104-
]
36+
# backward compatibility with our scripts
37+
TARGETS = []
38+
for target in TARGET_NAMES:
39+
try:
40+
if (ProGenDef('uvision').is_supported(str(TARGET_MAP[target])) or
41+
ProGenDef('uvision').is_supported(TARGET_MAP[target].progen['target'])):
42+
TARGETS.append(target)
43+
except AttributeError:
44+
# target is not supported yet
45+
continue
10546

106-
USING_MICROLIB = [
107-
'LPC11U24',
108-
'LPC11U35_401',
109-
'LPC11U35_501',
110-
'LPC1114',
111-
'LPC11C24',
112-
'LPC812',
113-
'LPC824',
114-
'SSCI824',
115-
'NUCLEO_F030R8',
116-
'NUCLEO_F031K6',
117-
'NUCLEO_F042K6',
118-
'NUCLEO_F070RB',
119-
'NUCLEO_F072RB',
120-
'NUCLEO_F091RC',
121-
'NUCLEO_F103RB',
122-
'NUCLEO_F302R8',
123-
'NUCLEO_F303K8',
124-
'NUCLEO_F303RE',
125-
'NUCLEO_F334R8',
126-
'NUCLEO_F401RE',
127-
'NUCLEO_F410RB',
128-
'NUCLEO_F411RE',
129-
'NUCLEO_F446RE',
130-
'NUCLEO_F746ZG',
131-
'NUCLEO_L053R8',
132-
'NUCLEO_L073RZ',
133-
'NUCLEO_L152RE',
134-
'NUCLEO_L476RG',
135-
'DISCO_F051R8',
136-
'DISCO_F100RB',
137-
'DISCO_F334C8',
138-
'DISCO_F429ZI',
139-
'DISCO_F469NI',
140-
'DISCO_L053C8',
141-
'DISCO_L476VG',
142-
'B96B_F446VE',
143-
'DISCO_F407VG',
144-
'DISCO_F303VC',
145-
'LPC1549',
146-
'LPC11U68',
147-
'LPC11U35_501',
148-
'KL05Z',
149-
'LPC11U37H_401',
150-
'MOTE_L152RC',
151-
'NZ32_SC151',
152-
'SAMR21G18A',
153-
'SAMD21J18A',
154-
'SAMD21G18A',
155-
'SAML21J18A',
156-
'ARM_IOTSS_BEID',
157-
'ARM_MPS2_M0',
158-
'ARM_MPS2_M0P',
159-
'ARM_MPS2_M3',
160-
'ARM_MPS2_M4',
161-
'ARM_MPS2_M7',
162-
]
16347

164-
FILE_TYPES = {
165-
'c_sources':'1',
166-
'cpp_sources':'8',
167-
's_sources':'2'
168-
}
169-
170-
FLAGS = [
171-
"--gnu", "--no_rtti",
172-
]
173-
174-
# By convention uVision projects do not show header files in the editor:
175-
# 'headers':'5',
176-
177-
def get_toolchain(self):
178-
return 'uARM' if (self.target in self.USING_MICROLIB) else 'ARM'
48+
def generate(self):
49+
""" Generates the project files """
50+
project_data = self.progen_get_project_data()
51+
tool_specific = {}
52+
# Expand tool specific settings by uvision specific settings which are required
53+
try:
54+
if TARGET_MAP[self.target].progen['uvision']['template']:
55+
tool_specific['uvision'] = TARGET_MAP[self.target].progen['uvision']
56+
except KeyError:
57+
# use default template
58+
# by the mbed projects
59+
tool_specific['uvision'] = {
60+
'template': [join(dirname(__file__), 'uvision.uvproj.tmpl')],
61+
}
17962

180-
def get_flags(self):
181-
return self.FLAGS
63+
project_data['tool_specific'] = {}
64+
project_data['tool_specific'].update(tool_specific)
65+
# armasm does not like floating numbers in macros, timestamp to int
66+
i = 0
67+
for macro in project_data['common']['macros']:
68+
if macro.startswith('MBED_BUILD_TIMESTAMP'):
69+
timestamp = macro[len('MBED_BUILD_TIMESTAMP='):]
70+
project_data['common']['macros'][i] = 'MBED_BUILD_TIMESTAMP=' + str(int(float(timestamp)))
71+
break
72+
i += 1
73+
project_data['common']['macros'].append('__ASSERT_MSG')
74+
self.progen_gen_file('uvision', project_data)
18275

183-
def generate(self):
184-
source_files = {
185-
'mbed': [],
186-
'hal': [],
187-
'src': []
188-
}
189-
for r_type, n in Uvision4.FILE_TYPES.iteritems():
190-
for file in getattr(self.resources, r_type):
191-
f = {'name': basename(file), 'type': n, 'path': file}
192-
if file.startswith("mbed\\common"):
193-
source_files['mbed'].append(f)
194-
elif file.startswith("mbed\\targets"):
195-
source_files['hal'].append(f)
196-
else:
197-
source_files['src'].append(f)
198-
source_files = dict( [(k,v) for k,v in source_files.items() if len(v)>0])
199-
ctx = {
200-
'name': self.program_name,
201-
'include_paths': self.resources.inc_dirs,
202-
'scatter_file': self.resources.linker_script,
203-
'object_files': self.resources.objects + self.resources.libraries,
204-
'source_files': source_files.items(),
205-
'symbols': self.get_symbols() + ['__ASSERT_MSG'],
206-
'hex_files' : self.resources.hex_files,
207-
'flags' : self.get_flags(),
208-
}
209-
target = self.target.lower()
210-
# Project file
211-
self.gen_file('uvision4_%s.uvproj.tmpl' % target, ctx, '%s.uvproj' % self.program_name)
212-
self.gen_file('uvision4_%s.uvopt.tmpl' % target, ctx, '%s.uvopt' % self.program_name)

0 commit comments

Comments
 (0)