Skip to content

Commit 41aff24

Browse files
theotherjimmy0xc0170
authored andcommitted
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.
1 parent 3a27568 commit 41aff24

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

tools/export/uvision/__init__.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ def format_src(self, srcs):
178178
key=lambda (_, __, name): name.lower())
179179
return grouped
180180

181+
@staticmethod
182+
def format_fpu(core):
183+
"""Generate a core's FPU string"""
184+
if core.endswith("FD"):
185+
return "FPU3(DFPU)"
186+
elif core.endswith("F"):
187+
return "FPU2"
188+
else:
189+
return ""
190+
181191
def generate(self):
182192
"""Generate the .uvproj file"""
183193
cache = Cache(True, False)
@@ -197,10 +207,11 @@ def generate(self):
197207
'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'),
198208
'device': DeviceUvision(self.target),
199209
}
200-
ctx['cputype'] = ctx['device'].core.rstrip("FD")
210+
core = ctx['device'].core
211+
ctx['cputype'] = core.rstrip("FD")
201212
# Turn on FPU optimizations if the core has an FPU
202-
ctx['fpu_setting'] = 1 if 'f' not in ctx['device'].core.lower() \
203-
or 'd' in ctx['device'].core.lower() else 2
213+
ctx['fpu_setting'] = 1 if 'F' not in core or 'D' in core else 2
214+
ctx['fputype'] = self.format_fpu(core)
204215
ctx.update(self.format_flags())
205216
self.gen_file('uvision/uvision.tmpl', ctx, self.project_name+".uvprojx")
206217
self.gen_file('uvision/uvision_debug.tmpl', ctx, self.project_name + ".uvoptx")

tools/export/uvision/uvision.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<Vendor>{{device.dvendor}}</Vendor>
1717
<PackID>{{device.pack_id}}</PackID>
1818
<PackURL>{{device.pack_url}}</PackURL>
19-
<Cpu>CPUTYPE("{{cputype}}")</Cpu>
19+
<Cpu>CPUTYPE("{{cputype}}") {{fputype}}</Cpu>
2020
<FlashUtilSpec></FlashUtilSpec>
2121
<StartupFile></StartupFile>
2222
<FlashDriverDll>{{device.flash_dll}}</FlashDriverDll>

0 commit comments

Comments
 (0)