Add the FPU field to the <Cpu> tag it Keil

Recently the Keil IDE has released version 5.23. This version requires
the FPU to be set as part of the <Cpu> tag in the .uvprojx (XML project
file). This patch adds the appropriate FPU settings based on the
trailing F (FPU enabled) or FD (Double precesion FPU enabled) string of
the core.
pull/3861/head
Jimmy Brisson 2017-03-01 14:16:12 -06:00
parent 3a27568a50
commit d2f2603892
2 changed files with 15 additions and 4 deletions

View File

@ -178,6 +178,16 @@ class Uvision(Exporter):
key=lambda (_, __, name): name.lower()) key=lambda (_, __, name): name.lower())
return grouped return grouped
@staticmethod
def format_fpu(core):
"""Generate a core's FPU string"""
if core.endswith("FD"):
return "FPU3(DFPU)"
elif core.endswith("F"):
return "FPU2"
else:
return ""
def generate(self): def generate(self):
"""Generate the .uvproj file""" """Generate the .uvproj file"""
cache = Cache(True, False) cache = Cache(True, False)
@ -197,10 +207,11 @@ class Uvision(Exporter):
'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'), 'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'),
'device': DeviceUvision(self.target), 'device': DeviceUvision(self.target),
} }
ctx['cputype'] = ctx['device'].core.rstrip("FD") core = ctx['device'].core
ctx['cputype'] = core.rstrip("FD")
# Turn on FPU optimizations if the core has an FPU # Turn on FPU optimizations if the core has an FPU
ctx['fpu_setting'] = 1 if 'f' not in ctx['device'].core.lower() \ ctx['fpu_setting'] = 1 if 'F' not in core or 'D' in core else 2
or 'd' in ctx['device'].core.lower() else 2 ctx['fputype'] = self.format_fpu(core)
ctx.update(self.format_flags()) ctx.update(self.format_flags())
self.gen_file('uvision/uvision.tmpl', ctx, self.project_name+".uvprojx") self.gen_file('uvision/uvision.tmpl', ctx, self.project_name+".uvprojx")
self.gen_file('uvision/uvision_debug.tmpl', ctx, self.project_name + ".uvoptx") self.gen_file('uvision/uvision_debug.tmpl', ctx, self.project_name + ".uvoptx")

View File

@ -16,7 +16,7 @@
<Vendor>{{device.dvendor}}</Vendor> <Vendor>{{device.dvendor}}</Vendor>
<PackID>{{device.pack_id}}</PackID> <PackID>{{device.pack_id}}</PackID>
<PackURL>{{device.pack_url}}</PackURL> <PackURL>{{device.pack_url}}</PackURL>
<Cpu>CPUTYPE("{{cputype}}")</Cpu> <Cpu>CPUTYPE("{{cputype}}") {{fputype}}</Cpu>
<FlashUtilSpec></FlashUtilSpec> <FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile> <StartupFile></StartupFile>
<FlashDriverDll>{{device.flash_dll}}</FlashDriverDll> <FlashDriverDll>{{device.flash_dll}}</FlashDriverDll>