mirror of https://github.com/ARMmbed/mbed-os.git
Flake8 of uvision exporter python code
parent
11702d16b5
commit
c51467ee91
|
|
@ -2,7 +2,7 @@ from __future__ import print_function, absolute_import
|
||||||
from builtins import str
|
from builtins import str
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from os.path import sep, normpath, join, exists, dirname
|
from os.path import normpath, exists, dirname
|
||||||
import ntpath
|
import ntpath
|
||||||
import copy
|
import copy
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
@ -11,11 +11,11 @@ from subprocess import Popen, PIPE
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from tools.resources import FileType
|
from tools.resources import FileType
|
||||||
from tools.arm_pack_manager import Cache
|
|
||||||
from tools.targets import TARGET_MAP
|
from tools.targets import TARGET_MAP
|
||||||
from tools.export.exporters import Exporter, apply_supported_whitelist
|
from tools.export.exporters import Exporter
|
||||||
from tools.export.cmsis import DeviceCMSIS
|
from tools.export.cmsis import DeviceCMSIS
|
||||||
|
|
||||||
|
|
||||||
class DeviceUvision(DeviceCMSIS):
|
class DeviceUvision(DeviceCMSIS):
|
||||||
"""Uvision Device class, inherits CMSIS Device class
|
"""Uvision Device class, inherits CMSIS Device class
|
||||||
|
|
||||||
|
|
@ -42,10 +42,13 @@ class DeviceUvision(DeviceCMSIS):
|
||||||
cpu_flag = "p"+cpu
|
cpu_flag = "p"+cpu
|
||||||
|
|
||||||
# Locations found in Keil_v5/TOOLS.INI
|
# Locations found in Keil_v5/TOOLS.INI
|
||||||
debuggers = {"st-link": ('STLink\\ST-LINKIII-KEIL_SWO.dll', 'ST-LINKIII-KEIL_SWO'),
|
debuggers = {
|
||||||
|
"st-link": ('STLink\\ST-LINKIII-KEIL_SWO.dll',
|
||||||
|
'ST-LINKIII-KEIL_SWO'),
|
||||||
"j-link": ('Segger\\JL2CM3.dll', 'JL2CM3'),
|
"j-link": ('Segger\\JL2CM3.dll', 'JL2CM3'),
|
||||||
"cmsis-dap": ('BIN\\CMSIS_AGDI.dll', 'CMSIS_AGDI'),
|
"cmsis-dap": ('BIN\\CMSIS_AGDI.dll', 'CMSIS_AGDI'),
|
||||||
"nulink":('NULink\\Nu_Link.dll','Nu_Link')}
|
"nulink": ('NULink\\Nu_Link.dll', 'Nu_Link')
|
||||||
|
}
|
||||||
res = debuggers[self.debug.lower()]
|
res = debuggers[self.debug.lower()]
|
||||||
binary = res[0]
|
binary = res[0]
|
||||||
key = res[1]
|
key = res[1]
|
||||||
|
|
@ -57,7 +60,7 @@ class DeviceUvision(DeviceCMSIS):
|
||||||
S = SW/JTAG Clock ID
|
S = SW/JTAG Clock ID
|
||||||
C = CPU index in JTAG chain
|
C = CPU index in JTAG chain
|
||||||
P = Access Port
|
P = Access Port
|
||||||
For the Options for Target -> Debug tab -> settings -> "Flash" tab in the dialog:
|
For the Options for Target -> Debug -> settings -> "Flash" dialog:
|
||||||
FD = RAM Start for Flash Functions
|
FD = RAM Start for Flash Functions
|
||||||
FC = RAM Size for Flash Functions
|
FC = RAM Size for Flash Functions
|
||||||
FN = Number of Flash types
|
FN = Number of Flash types
|
||||||
|
|
@ -66,17 +69,23 @@ class DeviceUvision(DeviceCMSIS):
|
||||||
FL = Size of the Flash Device
|
FL = Size of the Flash Device
|
||||||
FP = Full path to the Device algorithm (RTE)
|
FP = Full path to the Device algorithm (RTE)
|
||||||
|
|
||||||
Necessary to flash some targets. Info gathered from algorithms field of pdsc file.
|
Necessary to flash some targets.
|
||||||
'''
|
'''
|
||||||
fl_count = 0
|
fl_count = 0
|
||||||
|
|
||||||
def get_mem_no_x(mem_str):
|
def get_mem_no_x(mem_str):
|
||||||
mem_reg = "\dx(\w+)"
|
mem_reg = "\dx(\w+)"
|
||||||
m = re.search(mem_reg, mem_str)
|
m = re.search(mem_reg, mem_str)
|
||||||
return m.group(1) if m else None
|
return m.group(1) if m else None
|
||||||
|
|
||||||
RAMS = [(get_mem_no_x(info["start"]), get_mem_no_x(info["size"]))
|
RAMS = [
|
||||||
for mem, info in self.target_info["memory"].items() if "RAM" in mem]
|
(get_mem_no_x(info["start"]), get_mem_no_x(info["size"]))
|
||||||
format_str = "UL2CM3(-S0 -C0 -P0 -FD{ramstart}"+" -FC{ramsize} "+"-FN{num_algos} {extra_flags})"
|
for mem, info in self.target_info["memory"].items() if "RAM" in mem
|
||||||
|
]
|
||||||
|
format_str = (
|
||||||
|
"UL2CM3(-S0 -C0 -P0 -FD{ramstart}"
|
||||||
|
" -FC{ramsize} -FN{num_algos} {extra_flags})"
|
||||||
|
)
|
||||||
ramstart = ''
|
ramstart = ''
|
||||||
# Default according to Keil developer
|
# Default according to Keil developer
|
||||||
ramsize = '1000'
|
ramsize = '1000'
|
||||||
|
|
@ -93,7 +102,8 @@ class DeviceUvision(DeviceCMSIS):
|
||||||
fl_name = m.group(1) if m else None
|
fl_name = m.group(1) if m else None
|
||||||
name_flag = "-FF" + str(fl_count) + fl_name
|
name_flag = "-FF" + str(fl_count) + fl_name
|
||||||
|
|
||||||
start, size = get_mem_no_x(info["start"]), get_mem_no_x(info["size"])
|
start = get_mem_no_x(info["start"])
|
||||||
|
size = get_mem_no_x(info["size"])
|
||||||
rom_start_flag = "-FS" + str(fl_count) + str(start)
|
rom_start_flag = "-FS" + str(fl_count) + str(start)
|
||||||
rom_size_flag = "-FL" + str(fl_count) + str(size)
|
rom_size_flag = "-FL" + str(fl_count) + str(size)
|
||||||
|
|
||||||
|
|
@ -101,9 +111,13 @@ class DeviceUvision(DeviceCMSIS):
|
||||||
ramstart = get_mem_no_x(info["ramstart"])
|
ramstart = get_mem_no_x(info["ramstart"])
|
||||||
ramsize = get_mem_no_x(info["ramsize"])
|
ramsize = get_mem_no_x(info["ramsize"])
|
||||||
|
|
||||||
path_flag = "-FP" + str(fl_count) + "($$Device:"+self.dname+"$"+name+")"
|
path_flag = "-FP{}($$Device:{}${})".format(
|
||||||
|
str(fl_count), self.dname, name
|
||||||
|
)
|
||||||
|
|
||||||
extra_flags.extend([name_flag, rom_start_flag, rom_size_flag, path_flag])
|
extra_flags.extend([
|
||||||
|
name_flag, rom_start_flag, rom_size_flag, path_flag
|
||||||
|
])
|
||||||
fl_count += 1
|
fl_count += 1
|
||||||
|
|
||||||
extra = " ".join(extra_flags)
|
extra = " ".join(extra_flags)
|
||||||
|
|
@ -130,7 +144,6 @@ class Uvision(Exporter):
|
||||||
"NCS36510TargetCode.ncs36510_addfib"
|
"NCS36510TargetCode.ncs36510_addfib"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
# File associations within .uvprojx file
|
# File associations within .uvprojx file
|
||||||
file_types = {'.cpp': 8, '.c': 1, '.s': 2,
|
file_types = {'.cpp': 8, '.c': 1, '.s': 2,
|
||||||
'.obj': 3, '.o': 3, '.lib': 4,
|
'.obj': 3, '.o': 3, '.lib': 4,
|
||||||
|
|
@ -212,11 +225,11 @@ class Uvision(Exporter):
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
"""Generate the .uvproj file"""
|
"""Generate the .uvproj file"""
|
||||||
cache = Cache(True, False)
|
srcs = (
|
||||||
|
self.resources.headers + self.resources.s_sources +
|
||||||
srcs = self.resources.headers + self.resources.s_sources + \
|
self.resources.c_sources + self.resources.cpp_sources +
|
||||||
self.resources.c_sources + self.resources.cpp_sources + \
|
|
||||||
self.resources.objects + self.libraries
|
self.resources.objects + self.libraries
|
||||||
|
)
|
||||||
ctx = {
|
ctx = {
|
||||||
'name': self.project_name,
|
'name': self.project_name,
|
||||||
# project_files => dict of generators - file group to generator of
|
# project_files => dict of generators - file group to generator of
|
||||||
|
|
@ -227,7 +240,8 @@ class Uvision(Exporter):
|
||||||
self.resources.inc_dirs).encode('utf-8'),
|
self.resources.inc_dirs).encode('utf-8'),
|
||||||
'device': DeviceUvision(self.target),
|
'device': DeviceUvision(self.target),
|
||||||
}
|
}
|
||||||
sct_name, sct_path = self.resources.get_file_refs(FileType.LD_SCRIPT)[0]
|
sct_name, sct_path = self.resources.get_file_refs(
|
||||||
|
FileType.LD_SCRIPT)[0]
|
||||||
ctx['linker_script'] = self.toolchain.correct_scatter_shebang(
|
ctx['linker_script'] = self.toolchain.correct_scatter_shebang(
|
||||||
sct_path, dirname(sct_name))
|
sct_path, dirname(sct_name))
|
||||||
if ctx['linker_script'] != sct_path:
|
if ctx['linker_script'] != sct_path:
|
||||||
|
|
@ -243,8 +257,12 @@ class Uvision(Exporter):
|
||||||
ctx['armc6'] = int(self.TOOLCHAIN is 'ARMC6')
|
ctx['armc6'] = int(self.TOOLCHAIN is 'ARMC6')
|
||||||
ctx['toolchain_name'] = self.TOOLCHAIN_NAME
|
ctx['toolchain_name'] = self.TOOLCHAIN_NAME
|
||||||
ctx.update(self.format_flags())
|
ctx.update(self.format_flags())
|
||||||
self.gen_file('uvision/uvision.tmpl', ctx, self.project_name+".uvprojx")
|
self.gen_file(
|
||||||
self.gen_file('uvision/uvision_debug.tmpl', ctx, self.project_name + ".uvoptx")
|
'uvision/uvision.tmpl', ctx, self.project_name + ".uvprojx"
|
||||||
|
)
|
||||||
|
self.gen_file(
|
||||||
|
'uvision/uvision_debug.tmpl', ctx, self.project_name + ".uvoptx"
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clean(project_name):
|
def clean(project_name):
|
||||||
|
|
@ -284,6 +302,7 @@ class Uvision(Exporter):
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
class UvisionArmc5(Uvision):
|
class UvisionArmc5(Uvision):
|
||||||
NAME = 'uvision5-armc5'
|
NAME = 'uvision5-armc5'
|
||||||
TOOLCHAIN = 'ARM'
|
TOOLCHAIN = 'ARM'
|
||||||
|
|
@ -306,12 +325,6 @@ class UvisionArmc5(Uvision):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def is_target_supported(cls, target_name):
|
|
||||||
target = TARGET_MAP[target_name]
|
|
||||||
return apply_supported_whitelist(
|
|
||||||
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target) and\
|
|
||||||
DeviceCMSIS.check_supported(target_name)
|
|
||||||
|
|
||||||
class UvisionArmc6(Uvision):
|
class UvisionArmc6(Uvision):
|
||||||
NAME = 'uvision5-armc6'
|
NAME = 'uvision5-armc6'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue