Skip to content

Commit b4e467c

Browse files
committed
Merge pull request #142 from 0xc0170/dev_kl25z_coide
KL25Z CoIDE exporter
2 parents fa9f5da + 38f2422 commit b4e467c

File tree

3 files changed

+145
-11
lines changed

3 files changed

+145
-11
lines changed

workspace_tools/export/__init__.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from shutil import copytree, rmtree
2121

2222
from workspace_tools.utils import mkdir
23-
from workspace_tools.export import uvision4, codesourcery, codered, gccarm, ds5_5, iar
23+
from workspace_tools.export import uvision4, codesourcery, codered, gccarm, ds5_5, iar, coide
2424
from workspace_tools.export.exporters import zip_working_directory_and_clean_up, OldLibrariesException
2525
from workspace_tools.targets import EXPORT_MAP
2626

@@ -30,7 +30,8 @@
3030
'codesourcery': codesourcery.CodeSourcery,
3131
'gcc_arm': gccarm.GccArm,
3232
'ds5_5': ds5_5.DS5_5,
33-
'iar': iar.IAREmbeddedWorkbench
33+
'iar': iar.IAREmbeddedWorkbench,
34+
'coide' : coide.CoIDE
3435
}
3536

3637
ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN = """
@@ -51,16 +52,16 @@ def export(project_path, project_name, ide, target, destination='/tmp/', tempdir
5152
# Convention: we are using capitals for toolchain and target names
5253
if target is not None:
5354
target = target.upper()
54-
55+
5556
if tempdir is None:
5657
tempdir = tempfile.mkdtemp()
57-
58+
5859
if ide is None:
5960
# Simply copy everything, no project files to be generated
6061
for d in ['src', 'lib']:
6162
os.system("cp -r %s/* %s" % (join(project_path, d), tempdir))
6263
report = {'success': True}
63-
64+
6465
else:
6566
report = {'success': False}
6667
if ide not in EXPORTERS:
@@ -78,11 +79,11 @@ def export(project_path, project_name, ide, target, destination='/tmp/', tempdir
7879
report['success'] = True
7980
except OldLibrariesException, e:
8081
report['errormsg'] = ERROR_MESSAGE_NOT_EXPORT_LIBS
81-
82+
8283
zip_path = None
8384
if report['success']:
8485
zip_path = zip_working_directory_and_clean_up(tempdir, destination, project_name, clean)
85-
86+
8687
return zip_path, report
8788

8889

@@ -95,7 +96,7 @@ def copy_tree(src, dst, clean=True):
9596
rmtree(dst)
9697
else:
9798
return
98-
99+
99100
copytree(src, dst)
100101

101102

@@ -104,14 +105,14 @@ def setup_user_prj(user_dir, prj_path, lib_paths=None):
104105
Setup a project with the same directory structure of the mbed online IDE
105106
"""
106107
mkdir(user_dir)
107-
108+
108109
# Project Path
109110
copy_tree(prj_path, join(user_dir, "src"))
110-
111+
111112
# Project Libraries
112113
user_lib = join(user_dir, "lib")
113114
mkdir(user_lib)
114-
115+
115116
if lib_paths is not None:
116117
for lib_path in lib_paths:
117118
copy_tree(lib_path, join(user_lib, basename(lib_path)))

workspace_tools/export/coide.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"""
2+
mbed SDK
3+
Copyright (c) 2014 ARM Limited
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
"""
17+
from exporters import Exporter
18+
from os.path import splitext, basename
19+
20+
21+
class CoIDE(Exporter):
22+
NAME = 'CoIDE'
23+
# seems like CoIDE currently supports only one type
24+
FILE_TYPES = {
25+
'c_sources':'1',
26+
'cpp_sources':'1',
27+
's_sources':'1'
28+
}
29+
TARGETS = ['KL25Z']
30+
TOOLCHAIN = 'GCC_ARM'
31+
32+
def generate(self):
33+
self.resources.win_to_unix()
34+
source_files = []
35+
for r_type, n in CoIDE.FILE_TYPES.iteritems():
36+
for file in getattr(self.resources, r_type):
37+
source_files.append({
38+
'name': basename(file), 'type': n, 'path': file
39+
})
40+
41+
libraries = []
42+
for lib in self.resources.libraries:
43+
l, _ = splitext(basename(lib))
44+
libraries.append(l[3:])
45+
46+
ctx = {
47+
'name': self.program_name,
48+
'source_files': source_files,
49+
'include_paths': self.resources.inc_dirs,
50+
'scatter_file': self.resources.linker_script,
51+
'object_files': self.resources.objects,
52+
'libraries': libraries,
53+
'symbols': self.toolchain.get_symbols()
54+
}
55+
target = self.target.lower()
56+
57+
# Project file
58+
self.gen_file('coide_%s.coproj.tmpl' % target, ctx, '%s.coproj' % self.program_name)
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<Project version="2G - 1.7.5" name="{{name}}">
3+
<Target name="{{name}}" isCurrent="1">
4+
<Device manufacturerId="4" manufacturerName="Freescale" chipId="86" chipName="MKL25Z128VLK4" boardId="" boardName=""/>
5+
<BuildOption>
6+
<Compile>
7+
<Option name="OptimizationLevel" value="4"/>
8+
<Option name="UseFPU" value="0"/>
9+
<Option name="UserEditCompiler" value="-fno-common; -fmessage-length=0; -Wall; -fno-strict-aliasing; -fno-rtti; -fno-exceptions; -ffunction-sections; -fdata-sections; -std=gnu++98"/>
10+
<Includepaths>
11+
{% for path in include_paths %} <Includepath path="{{path}}"/> {% endfor %}
12+
</Includepaths>
13+
<DefinedSymbols>
14+
{% for s in symbols %} <Define name="{{s}}"/> {% endfor %}
15+
</DefinedSymbols>
16+
</Compile>
17+
<Link useDefault="0">
18+
<Option name="DiscardUnusedSection" value="0"/>
19+
<Option name="UserEditLinkder" value=""/>
20+
<Option name="UseMemoryLayout" value="0"/>
21+
<Option name="LTO" value="0"/>
22+
<Option name="IsNewStartupCode" value="1"/>
23+
<Option name="Library" value="Not use C Library"/>
24+
<Option name="nostartfiles" value="0"/>
25+
<Option name="UserEditLinker" value="--specs=nano.specs; -u _printf_float; -u _scanf_float; {% for file in object_files %}
26+
${project.path}/{{file}}; {% endfor %} {% for lib in libraries %} -l{{lib}}; {% endfor %} -lstdc++; -lsupc++; -lm; -lc; -lgcc; -lnosys;"/>
27+
<LinkedLibraries/>
28+
<MemoryAreas debugInFlashNotRAM="1">
29+
<Memory name="IROM1" type="ReadOnly" size="0x00020000" startValue="0x00000000"/>
30+
<Memory name="IRAM1" type="ReadWrite" size="0x00001000" startValue="0x1FFFF000"/>
31+
<Memory name="IROM2" type="ReadOnly" size="" startValue=""/>
32+
<Memory name="IRAM2" type="ReadWrite" size="" startValue=""/>
33+
</MemoryAreas>
34+
<LocateLinkFile path="{{scatter_file}}" type="0"/>
35+
</Link>
36+
<Output>
37+
<Option name="OutputFileType" value="0"/>
38+
<Option name="Path" value="./"/>
39+
<Option name="Name" value="{{name}}"/>
40+
<Option name="HEX" value="1"/>
41+
<Option name="BIN" value="1"/>
42+
</Output>
43+
<User>
44+
<UserRun name="Run#1" type="Before" checked="0" value=""/>
45+
<UserRun name="Run#1" type="After" checked="0" value=""/>
46+
</User>
47+
</BuildOption>
48+
<DebugOption>
49+
<Option name="org.coocox.codebugger.gdbjtag.core.adapter" value="CMSIS-DAP"/>
50+
<Option name="org.coocox.codebugger.gdbjtag.core.debugMode" value="SWD"/>
51+
<Option name="org.coocox.codebugger.gdbjtag.core.clockDiv" value="1M"/>
52+
<Option name="org.coocox.codebugger.gdbjtag.corerunToMain" value="1"/>
53+
<Option name="org.coocox.codebugger.gdbjtag.core.jlinkgdbserver" value=""/>
54+
<Option name="org.coocox.codebugger.gdbjtag.core.userDefineGDBScript" value=""/>
55+
<Option name="org.coocox.codebugger.gdbjtag.core.targetEndianess" value="0"/>
56+
<Option name="org.coocox.codebugger.gdbjtag.core.jlinkResetMode" value="Type 0: Normal"/>
57+
<Option name="org.coocox.codebugger.gdbjtag.core.resetMode" value="SYSRESETREQ"/>
58+
<Option name="org.coocox.codebugger.gdbjtag.core.ifSemihost" value="0"/>
59+
<Option name="org.coocox.codebugger.gdbjtag.core.ifCacheRom" value="1"/>
60+
<Option name="org.coocox.codebugger.gdbjtag.core.ipAddress" value="127.0.0.1"/>
61+
<Option name="org.coocox.codebugger.gdbjtag.core.portNumber" value="2009"/>
62+
<Option name="org.coocox.codebugger.gdbjtag.core.autoDownload" value="1"/>
63+
<Option name="org.coocox.codebugger.gdbjtag.core.verify" value="1"/>
64+
<Option name="org.coocox.codebugger.gdbjtag.core.downloadFuction" value="Erase Effected"/>
65+
<Option name="org.coocox.codebugger.gdbjtag.core.defaultAlgorithm" value="KLxx_128_PRG_NO_CFG.elf"/>
66+
</DebugOption>
67+
<ExcludeFile/>
68+
</Target>
69+
<Components path="./"/>
70+
<Files>
71+
{% for file in source_files %}
72+
<File name="{{file.name}}" path="{{file.path}}" type="{{file.type}}"/>
73+
{% endfor %}
74+
</Files>
75+
</Project>

0 commit comments

Comments
 (0)