Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uvision progen #1607

Merged
merged 12 commits into from
Mar 15, 2016
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ prettytable
Jinja2
IntelHex
mbed-ls
project-generator>=0.8.8,<0.9.0
project-generator>=0.8.11,<0.9.0
junit-xml
requests
requests
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
url='https://github.com/mbedmicro/mbed',
packages=find_packages(),
license=LICENSE,
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"])
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"])

# Restore previous private_settings if needed
if backup:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>.\build\</OutputDirectory>
<OutputName>{{name}}</OutputName>
<OutputName>MBED_11</OutputName>
<CreateExecutable>1</CreateExecutable>
<CreateLib>0</CreateLib>
<CreateHexFile>0</CreateHexFile>
Expand Down Expand Up @@ -75,7 +75,7 @@
<AfterMake>
<RunUserProg1>1</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name>fromelf --bin -o build\{{name}}_KL25Z.bin build\{{name}}.axf</UserProg1Name>
<UserProg1Name>fromelf --bin --output=@L.bin !L</UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
Expand Down Expand Up @@ -345,11 +345,12 @@
<wLevel>0</wLevel>
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>
<VariousControls>
<MiscControls>{% for flag in flags %}{{flag}} {% endfor %}</MiscControls>
<Define>{% for s in symbols %} {{s}}, {% endfor %}</Define>
<MiscControls>--gnu --no_rtti</MiscControls>
<Define> </Define>
<Undefine></Undefine>
<IncludePath> {% for path in include_paths %} {{path}}; {% endfor %} </IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
<Aads>
Expand Down Expand Up @@ -377,45 +378,24 @@
<useFile>0</useFile>
<TextAddressRange>0x00000000</TextAddressRange>
<DataAddressRange>0x10000000</DataAddressRange>
<ScatterFile>{{scatter_file}}</ScatterFile>
<ScatterFile>mbed\TARGET_KL25Z\TOOLCHAIN_ARM_STD\MKL25Z4.sct</ScatterFile>
<IncludeLibs></IncludeLibs>
<IncludeLibsPath></IncludeLibsPath>
<Misc>
{% for file in object_files %}
{{file}}
{% endfor %}
</Misc>
<LinkerInputFile></LinkerInputFile>
<DisabledWarnings></DisabledWarnings>
</LDads>
</TargetArmAds>
</TargetOption>
<Groups>
{% for group,files in source_files %}

<Group>
<GroupName>{{group}}</GroupName>
<GroupName>src</GroupName>
<Files>
{% for file in files %}
<File>
<FileName>{{file.name}}</FileName>
<FileType>{{file.type}}</FileType>
<FilePath>{{file.path}}</FilePath>
{%if file.type == "1" %}
<FileOption>
<FileArmAds>
<Cads>
<VariousControls>
<MiscControls>--c99</MiscControls>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
{% endif %}
</File>
{% endfor %}
</Files>
</Group>
{% endfor %}

</Groups>
</Target>
</Targets>
Expand Down
237 changes: 50 additions & 187 deletions workspace_tools/export/uvision4.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,199 +14,62 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
from exporters import Exporter
from os.path import basename
from os.path import basename, join, dirname
from project_generator_definitions.definitions import ProGenDef

from workspace_tools.export.exporters import Exporter
from workspace_tools.targets import TARGET_MAP, TARGET_NAMES

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

TARGETS = [
'LPC1768',
'LPC11U24',
'LPC11U35_401',
'LPC11U35_501',
'KL05Z',
'KL25Z',
'KL43Z',
'KL46Z',
'K64F',
'K22F',
'K20D50M',
'TEENSY3_1',
'LPC1347',
'LPC1114',
'LPC11C24',
'LPC4088',
'LPC4088_DM',
'LPC4330_M4',
'LPC4337',
'LPC812',
'LPC824',
'SSCI824',
'NUCLEO_F030R8',
'NUCLEO_F031K6',
'NUCLEO_F042K6',
'NUCLEO_F070RB',
'NUCLEO_F072RB',
'NUCLEO_F091RC',
'NUCLEO_F103RB',
'NUCLEO_F302R8',
'NUCLEO_F303K8',
'NUCLEO_F303RE',
'NUCLEO_F334R8',
'NUCLEO_F401RE',
'NUCLEO_F410RB',
'NUCLEO_F411RE',
'NUCLEO_F446RE',
'NUCLEO_F746ZG',
'NUCLEO_L053R8',
'NUCLEO_L073RZ',
'NUCLEO_L152RE',
'NUCLEO_L476RG',
'B96B_F446VE',
'UBLOX_C027',
'LPC1549',
'LPC11U68',
# Removed as uvision4_lpc11u35_501.uvproj.tmpl is missing.
#'LPC11U35_501',
'NRF51822',
'HRM1017',
'RBLAB_NRF51822',
'ARCH_PRO',
'ARCH_BLE',
'DISCO_F051R8',
'DISCO_F100RB',
'DISCO_F303VC',
'DISCO_F407VG',
'DISCO_F429ZI',
'DISCO_F469NI',
'DISCO_L053C8',
'DISCO_F334C8',
'DISCO_F746NG',
'DISCO_L476VG',
'MTS_GAMBIT',
'ARCH_MAX',
'MTS_MDOT_F405RG',
'NRF51_DK',
'NRF51_DONGLE',
'SEEED_TINY_BLE',
'LPC11U37H_401',
'DELTA_DFCM_NNN40',
'MAXWSNENV',
'MAX32600MBED',
'MOTE_L152RC',
'NZ32_SC151',
'SAMR21G18A',
'SAMD21J18A',
'SAMD21G18A',
'SAML21J18A',
]
# backward compatibility with our scripts
TARGETS = []
for target in TARGET_NAMES:
try:
if (ProGenDef('uvision').is_supported(str(TARGET_MAP[target])) or
ProGenDef('uvision').is_supported(TARGET_MAP[target].progen['target'])):
TARGETS.append(target)
except AttributeError:
# target is not supported yet
continue

USING_MICROLIB = [
'LPC11U24',
'LPC11U35_401',
'LPC11U35_501',
'LPC1114',
'LPC11C24',
'LPC812',
'LPC824',
'SSCI824',
'NUCLEO_F030R8',
'NUCLEO_F031K6',
'NUCLEO_F042K6',
'NUCLEO_F070RB',
'NUCLEO_F072RB',
'NUCLEO_F091RC',
'NUCLEO_F103RB',
'NUCLEO_F302R8',
'NUCLEO_F303K8',
'NUCLEO_F303RE',
'NUCLEO_F334R8',
'NUCLEO_F401RE',
'NUCLEO_F410RB',
'NUCLEO_F411RE',
'NUCLEO_F446RE',
'NUCLEO_F746ZG',
'NUCLEO_L053R8',
'NUCLEO_L073RZ',
'NUCLEO_L152RE',
'NUCLEO_L476RG',
'DISCO_F051R8',
'DISCO_F100RB',
'DISCO_F334C8',
'DISCO_F429ZI',
'DISCO_F469NI',
'DISCO_L053C8',
'DISCO_L476VG',
'B96B_F446VE',
'DISCO_F407VG',
'DISCO_F303VC',
'LPC1549',
'LPC11U68',
'LPC11U35_501',
'KL05Z',
'LPC11U37H_401',
'MOTE_L152RC',
'NZ32_SC151',
'SAMR21G18A',
'SAMD21J18A',
'SAMD21G18A',
'SAML21J18A',
'ARM_IOTSS_BEID',
'ARM_MPS2_M0',
'ARM_MPS2_M0P',
'ARM_MPS2_M3',
'ARM_MPS2_M4',
'ARM_MPS2_M7',
]

FILE_TYPES = {
'c_sources':'1',
'cpp_sources':'8',
's_sources':'2'
}

FLAGS = [
"--gnu", "--no_rtti",
]

# By convention uVision projects do not show header files in the editor:
# 'headers':'5',

def get_toolchain(self):
return 'uARM' if (self.target in self.USING_MICROLIB) else 'ARM'
def generate(self):
""" Generates the project files """
project_data = self.progen_get_project_data()
tool_specific = {}
# Expand tool specific settings by uvision specific settings which are required
try:
if TARGET_MAP[self.target].progen['uvision']['template']:
tool_specific['uvision'] = TARGET_MAP[self.target].progen['uvision']
except KeyError:
# use default template
# by the mbed projects
tool_specific['uvision'] = {
'template': [join(dirname(__file__), 'uvision.uvproj.tmpl')],
}

def get_flags(self):
return self.FLAGS
project_data['tool_specific'] = {}
project_data['tool_specific'].update(tool_specific)
# armasm does not like floating numbers in macros, timestamp to int
i = 0
for macro in project_data['common']['macros']:
if macro.startswith('MBED_BUILD_TIMESTAMP'):
timestamp = macro[len('MBED_BUILD_TIMESTAMP='):]
project_data['common']['macros'][i] = 'MBED_BUILD_TIMESTAMP=' + str(int(float(timestamp)))
break
i += 1
project_data['common']['macros'].append('__ASSERT_MSG')
self.progen_gen_file('uvision', project_data)

def generate(self):
source_files = {
'mbed': [],
'hal': [],
'src': []
}
for r_type, n in Uvision4.FILE_TYPES.iteritems():
for file in getattr(self.resources, r_type):
f = {'name': basename(file), 'type': n, 'path': file}
if file.startswith("mbed\\common"):
source_files['mbed'].append(f)
elif file.startswith("mbed\\targets"):
source_files['hal'].append(f)
else:
source_files['src'].append(f)
source_files = dict( [(k,v) for k,v in source_files.items() if len(v)>0])
ctx = {
'name': self.program_name,
'include_paths': self.resources.inc_dirs,
'scatter_file': self.resources.linker_script,
'object_files': self.resources.objects + self.resources.libraries,
'source_files': source_files.items(),
'symbols': self.get_symbols() + ['__ASSERT_MSG'],
'hex_files' : self.resources.hex_files,
'flags' : self.get_flags(),
}
target = self.target.lower()
# Project file
self.gen_file('uvision4_%s.uvproj.tmpl' % target, ctx, '%s.uvproj' % self.program_name)
self.gen_file('uvision4_%s.uvopt.tmpl' % target, ctx, '%s.uvopt' % self.program_name)
Loading