Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466

Dependencies:   ssd1331

Committer:
kadonotakashi
Date:
Wed Oct 10 00:33:53 2018 +0000
Revision:
0:8fdf9a60065b
how to make mbed librry

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kadonotakashi 0:8fdf9a60065b 1 """
kadonotakashi 0:8fdf9a60065b 2 mbed SDK
kadonotakashi 0:8fdf9a60065b 3 Copyright (c) 2011-2013 ARM Limited
kadonotakashi 0:8fdf9a60065b 4
kadonotakashi 0:8fdf9a60065b 5 Licensed under the Apache License, Version 2.0 (the "License");
kadonotakashi 0:8fdf9a60065b 6 you may not use this file except in compliance with the License.
kadonotakashi 0:8fdf9a60065b 7 You may obtain a copy of the License at
kadonotakashi 0:8fdf9a60065b 8
kadonotakashi 0:8fdf9a60065b 9 http://www.apache.org/licenses/LICENSE-2.0
kadonotakashi 0:8fdf9a60065b 10
kadonotakashi 0:8fdf9a60065b 11 Unless required by applicable law or agreed to in writing, software
kadonotakashi 0:8fdf9a60065b 12 distributed under the License is distributed on an "AS IS" BASIS,
kadonotakashi 0:8fdf9a60065b 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kadonotakashi 0:8fdf9a60065b 14 See the License for the specific language governing permissions and
kadonotakashi 0:8fdf9a60065b 15 limitations under the License.
kadonotakashi 0:8fdf9a60065b 16 """
kadonotakashi 0:8fdf9a60065b 17 import re
kadonotakashi 0:8fdf9a60065b 18 from os.path import join, basename, splitext, dirname, exists
kadonotakashi 0:8fdf9a60065b 19 from os import getenv
kadonotakashi 0:8fdf9a60065b 20 from distutils.spawn import find_executable
kadonotakashi 0:8fdf9a60065b 21 from distutils.version import LooseVersion
kadonotakashi 0:8fdf9a60065b 22
kadonotakashi 0:8fdf9a60065b 23 from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
kadonotakashi 0:8fdf9a60065b 24 from tools.hooks import hook_tool
kadonotakashi 0:8fdf9a60065b 25 from tools.utils import run_cmd, NotSupportedException
kadonotakashi 0:8fdf9a60065b 26
kadonotakashi 0:8fdf9a60065b 27 class GCC(mbedToolchain):
kadonotakashi 0:8fdf9a60065b 28 LINKER_EXT = '.ld'
kadonotakashi 0:8fdf9a60065b 29 LIBRARY_EXT = '.a'
kadonotakashi 0:8fdf9a60065b 30
kadonotakashi 0:8fdf9a60065b 31 STD_LIB_NAME = "lib%s.a"
kadonotakashi 0:8fdf9a60065b 32 DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(?P<col>\d+):? (?P<severity>warning|[eE]rror|fatal error): (?P<message>.+)')
kadonotakashi 0:8fdf9a60065b 33
kadonotakashi 0:8fdf9a60065b 34 GCC_RANGE = (LooseVersion("6.0.0"), LooseVersion("7.0.0"))
kadonotakashi 0:8fdf9a60065b 35 GCC_VERSION_RE = re.compile(b"\d+\.\d+\.\d+")
kadonotakashi 0:8fdf9a60065b 36
kadonotakashi 0:8fdf9a60065b 37 def __init__(self, target, notify=None, macros=None, build_profile=None,
kadonotakashi 0:8fdf9a60065b 38 build_dir=None):
kadonotakashi 0:8fdf9a60065b 39 mbedToolchain.__init__(self, target, notify, macros,
kadonotakashi 0:8fdf9a60065b 40 build_profile=build_profile, build_dir=build_dir)
kadonotakashi 0:8fdf9a60065b 41
kadonotakashi 0:8fdf9a60065b 42 tool_path=TOOLCHAIN_PATHS['GCC_ARM']
kadonotakashi 0:8fdf9a60065b 43 # Add flags for current size setting
kadonotakashi 0:8fdf9a60065b 44 default_lib = "std"
kadonotakashi 0:8fdf9a60065b 45 if hasattr(target, "default_lib"):
kadonotakashi 0:8fdf9a60065b 46 default_lib = target.default_lib
kadonotakashi 0:8fdf9a60065b 47 elif hasattr(target, "default_build"): # Legacy
kadonotakashi 0:8fdf9a60065b 48 default_lib = target.default_build
kadonotakashi 0:8fdf9a60065b 49
kadonotakashi 0:8fdf9a60065b 50 if default_lib == "small":
kadonotakashi 0:8fdf9a60065b 51 self.flags["common"].append("-DMBED_RTOS_SINGLE_THREAD")
kadonotakashi 0:8fdf9a60065b 52 self.flags["ld"].append("--specs=nano.specs")
kadonotakashi 0:8fdf9a60065b 53
kadonotakashi 0:8fdf9a60065b 54 if target.core == "Cortex-M0+":
kadonotakashi 0:8fdf9a60065b 55 self.cpu = ["-mcpu=cortex-m0plus"]
kadonotakashi 0:8fdf9a60065b 56 elif target.core.startswith("Cortex-M4"):
kadonotakashi 0:8fdf9a60065b 57 self.cpu = ["-mcpu=cortex-m4"]
kadonotakashi 0:8fdf9a60065b 58 elif target.core.startswith("Cortex-M7"):
kadonotakashi 0:8fdf9a60065b 59 self.cpu = ["-mcpu=cortex-m7"]
kadonotakashi 0:8fdf9a60065b 60 elif target.core.startswith("Cortex-M23"):
kadonotakashi 0:8fdf9a60065b 61 self.cpu = ["-mcpu=cortex-m23"]
kadonotakashi 0:8fdf9a60065b 62 elif target.core.startswith("Cortex-M33F"):
kadonotakashi 0:8fdf9a60065b 63 self.cpu = ["-mcpu=cortex-m33"]
kadonotakashi 0:8fdf9a60065b 64 elif target.core.startswith("Cortex-M33"):
kadonotakashi 0:8fdf9a60065b 65 self.cpu = ["-march=armv8-m.main"]
kadonotakashi 0:8fdf9a60065b 66 else:
kadonotakashi 0:8fdf9a60065b 67 self.cpu = ["-mcpu={}".format(target.core.lower())]
kadonotakashi 0:8fdf9a60065b 68
kadonotakashi 0:8fdf9a60065b 69 if target.core.startswith("Cortex-M"):
kadonotakashi 0:8fdf9a60065b 70 self.cpu.append("-mthumb")
kadonotakashi 0:8fdf9a60065b 71
kadonotakashi 0:8fdf9a60065b 72 # FPU handling, M7 possibly to have double FPU
kadonotakashi 0:8fdf9a60065b 73 if target.core == "Cortex-M4F":
kadonotakashi 0:8fdf9a60065b 74 self.cpu.append("-mfpu=fpv4-sp-d16")
kadonotakashi 0:8fdf9a60065b 75 self.cpu.append("-mfloat-abi=softfp")
kadonotakashi 0:8fdf9a60065b 76 elif target.core == "Cortex-M7F":
kadonotakashi 0:8fdf9a60065b 77 self.cpu.append("-mfpu=fpv5-sp-d16")
kadonotakashi 0:8fdf9a60065b 78 self.cpu.append("-mfloat-abi=softfp")
kadonotakashi 0:8fdf9a60065b 79 elif target.core == "Cortex-M7FD":
kadonotakashi 0:8fdf9a60065b 80 self.cpu.append("-mfpu=fpv5-d16")
kadonotakashi 0:8fdf9a60065b 81 self.cpu.append("-mfloat-abi=softfp")
kadonotakashi 0:8fdf9a60065b 82
kadonotakashi 0:8fdf9a60065b 83 if target.core == "Cortex-A9":
kadonotakashi 0:8fdf9a60065b 84 self.cpu.append("-mthumb-interwork")
kadonotakashi 0:8fdf9a60065b 85 self.cpu.append("-marm")
kadonotakashi 0:8fdf9a60065b 86 self.cpu.append("-march=armv7-a")
kadonotakashi 0:8fdf9a60065b 87 self.cpu.append("-mfpu=vfpv3")
kadonotakashi 0:8fdf9a60065b 88 self.cpu.append("-mfloat-abi=hard")
kadonotakashi 0:8fdf9a60065b 89 self.cpu.append("-mno-unaligned-access")
kadonotakashi 0:8fdf9a60065b 90
kadonotakashi 0:8fdf9a60065b 91 if ((target.core.startswith("Cortex-M23") or
kadonotakashi 0:8fdf9a60065b 92 target.core.startswith("Cortex-M33")) and
kadonotakashi 0:8fdf9a60065b 93 not target.core.endswith("-NS")):
kadonotakashi 0:8fdf9a60065b 94 self.cpu.append("-mcmse")
kadonotakashi 0:8fdf9a60065b 95 self.flags["ld"].extend([
kadonotakashi 0:8fdf9a60065b 96 "-Wl,--cmse-implib",
kadonotakashi 0:8fdf9a60065b 97 "-Wl,--out-implib=%s" % join(build_dir, "cmse_lib.o")
kadonotakashi 0:8fdf9a60065b 98 ])
kadonotakashi 0:8fdf9a60065b 99 elif target.core == "Cortex-M23-NS" or target.core == "Cortex-M33-NS":
kadonotakashi 0:8fdf9a60065b 100 self.flags["ld"].append("-DDOMAIN_NS=1")
kadonotakashi 0:8fdf9a60065b 101
kadonotakashi 0:8fdf9a60065b 102 self.flags["common"] += self.cpu
kadonotakashi 0:8fdf9a60065b 103
kadonotakashi 0:8fdf9a60065b 104 main_cc = join(tool_path, "arm-none-eabi-gcc")
kadonotakashi 0:8fdf9a60065b 105 main_cppc = join(tool_path, "arm-none-eabi-g++")
kadonotakashi 0:8fdf9a60065b 106 self.asm = [main_cc] + self.flags['asm'] + self.flags["common"]
kadonotakashi 0:8fdf9a60065b 107 self.cc = [main_cc]
kadonotakashi 0:8fdf9a60065b 108 self.cppc =[main_cppc]
kadonotakashi 0:8fdf9a60065b 109 self.cc += self.flags['c'] + self.flags['common']
kadonotakashi 0:8fdf9a60065b 110 self.cppc += self.flags['cxx'] + self.flags['common']
kadonotakashi 0:8fdf9a60065b 111
kadonotakashi 0:8fdf9a60065b 112 self.flags['ld'] += self.cpu
kadonotakashi 0:8fdf9a60065b 113 self.ld = [join(tool_path, "arm-none-eabi-gcc")] + self.flags['ld']
kadonotakashi 0:8fdf9a60065b 114 self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc", "nosys"]
kadonotakashi 0:8fdf9a60065b 115 self.preproc = [join(tool_path, "arm-none-eabi-cpp"), "-E", "-P"]
kadonotakashi 0:8fdf9a60065b 116
kadonotakashi 0:8fdf9a60065b 117 self.ar = join(tool_path, "arm-none-eabi-ar")
kadonotakashi 0:8fdf9a60065b 118 self.elf2bin = join(tool_path, "arm-none-eabi-objcopy")
kadonotakashi 0:8fdf9a60065b 119
kadonotakashi 0:8fdf9a60065b 120 self.use_distcc = (bool(getenv("DISTCC_POTENTIAL_HOSTS", False))
kadonotakashi 0:8fdf9a60065b 121 and not getenv("MBED_DISABLE_DISTCC", False))
kadonotakashi 0:8fdf9a60065b 122
kadonotakashi 0:8fdf9a60065b 123 def version_check(self):
kadonotakashi 0:8fdf9a60065b 124 stdout, _, retcode = run_cmd([self.cc[0], "--version"], redirect=True)
kadonotakashi 0:8fdf9a60065b 125 msg = None
kadonotakashi 0:8fdf9a60065b 126 match = self.GCC_VERSION_RE.search(stdout)
kadonotakashi 0:8fdf9a60065b 127 found_version = LooseVersion(match.group(0).decode('utf-8')) if match else None
kadonotakashi 0:8fdf9a60065b 128 min_ver, max_ver = self.GCC_RANGE
kadonotakashi 0:8fdf9a60065b 129 if found_version and (found_version < min_ver or found_version >= max_ver):
kadonotakashi 0:8fdf9a60065b 130 msg = ("Compiler version mismatch: Have {}; "
kadonotakashi 0:8fdf9a60065b 131 "expected version >= {} and < {}"
kadonotakashi 0:8fdf9a60065b 132 .format(found_version, min_ver, max_ver))
kadonotakashi 0:8fdf9a60065b 133 elif not match:
kadonotakashi 0:8fdf9a60065b 134 msg = ("Compiler version mismatch: Could not detect version; "
kadonotakashi 0:8fdf9a60065b 135 "expected version >= {} and < {}"
kadonotakashi 0:8fdf9a60065b 136 .format(min_ver, max_ver))
kadonotakashi 0:8fdf9a60065b 137 if msg:
kadonotakashi 0:8fdf9a60065b 138 self.notify.cc_info({
kadonotakashi 0:8fdf9a60065b 139 "message": msg,
kadonotakashi 0:8fdf9a60065b 140 "file": "",
kadonotakashi 0:8fdf9a60065b 141 "line": "",
kadonotakashi 0:8fdf9a60065b 142 "col": "",
kadonotakashi 0:8fdf9a60065b 143 "severity": "Warning",
kadonotakashi 0:8fdf9a60065b 144 })
kadonotakashi 0:8fdf9a60065b 145
kadonotakashi 0:8fdf9a60065b 146 def is_not_supported_error(self, output):
kadonotakashi 0:8fdf9a60065b 147 return "error: #error [NOT_SUPPORTED]" in output
kadonotakashi 0:8fdf9a60065b 148
kadonotakashi 0:8fdf9a60065b 149 def parse_output(self, output):
kadonotakashi 0:8fdf9a60065b 150 # The warning/error notification is multiline
kadonotakashi 0:8fdf9a60065b 151 msg = None
kadonotakashi 0:8fdf9a60065b 152 for line in output.splitlines():
kadonotakashi 0:8fdf9a60065b 153 match = self.DIAGNOSTIC_PATTERN.search(line)
kadonotakashi 0:8fdf9a60065b 154 if match is not None:
kadonotakashi 0:8fdf9a60065b 155 if msg is not None:
kadonotakashi 0:8fdf9a60065b 156 self.notify.cc_info(msg)
kadonotakashi 0:8fdf9a60065b 157 msg = None
kadonotakashi 0:8fdf9a60065b 158 msg = {
kadonotakashi 0:8fdf9a60065b 159 'severity': match.group('severity').lower(),
kadonotakashi 0:8fdf9a60065b 160 'file': match.group('file'),
kadonotakashi 0:8fdf9a60065b 161 'line': match.group('line'),
kadonotakashi 0:8fdf9a60065b 162 'col': match.group('col'),
kadonotakashi 0:8fdf9a60065b 163 'message': match.group('message'),
kadonotakashi 0:8fdf9a60065b 164 'text': '',
kadonotakashi 0:8fdf9a60065b 165 'target_name': self.target.name,
kadonotakashi 0:8fdf9a60065b 166 'toolchain_name': self.name
kadonotakashi 0:8fdf9a60065b 167 }
kadonotakashi 0:8fdf9a60065b 168
kadonotakashi 0:8fdf9a60065b 169 if msg is not None:
kadonotakashi 0:8fdf9a60065b 170 self.notify.cc_info(msg)
kadonotakashi 0:8fdf9a60065b 171
kadonotakashi 0:8fdf9a60065b 172 def get_dep_option(self, object):
kadonotakashi 0:8fdf9a60065b 173 base, _ = splitext(object)
kadonotakashi 0:8fdf9a60065b 174 dep_path = base + '.d'
kadonotakashi 0:8fdf9a60065b 175 return ["-MD", "-MF", dep_path]
kadonotakashi 0:8fdf9a60065b 176
kadonotakashi 0:8fdf9a60065b 177 def get_config_option(self, config_header):
kadonotakashi 0:8fdf9a60065b 178 return ['-include', config_header]
kadonotakashi 0:8fdf9a60065b 179
kadonotakashi 0:8fdf9a60065b 180 def get_compile_options(self, defines, includes, for_asm=False):
kadonotakashi 0:8fdf9a60065b 181 opts = ['-D%s' % d for d in defines]
kadonotakashi 0:8fdf9a60065b 182 if self.RESPONSE_FILES:
kadonotakashi 0:8fdf9a60065b 183 opts += ['@%s' % self.get_inc_file(includes)]
kadonotakashi 0:8fdf9a60065b 184 else:
kadonotakashi 0:8fdf9a60065b 185 opts += ["-I%s" % i for i in includes]
kadonotakashi 0:8fdf9a60065b 186
kadonotakashi 0:8fdf9a60065b 187 config_header = self.get_config_header()
kadonotakashi 0:8fdf9a60065b 188 if config_header is not None:
kadonotakashi 0:8fdf9a60065b 189 opts = opts + self.get_config_option(config_header)
kadonotakashi 0:8fdf9a60065b 190 return opts
kadonotakashi 0:8fdf9a60065b 191
kadonotakashi 0:8fdf9a60065b 192 @hook_tool
kadonotakashi 0:8fdf9a60065b 193 def assemble(self, source, object, includes):
kadonotakashi 0:8fdf9a60065b 194 # Build assemble command
kadonotakashi 0:8fdf9a60065b 195 cmd = self.asm + self.get_compile_options(self.get_symbols(True), includes) + ["-o", object, source]
kadonotakashi 0:8fdf9a60065b 196
kadonotakashi 0:8fdf9a60065b 197 # Call cmdline hook
kadonotakashi 0:8fdf9a60065b 198 cmd = self.hook.get_cmdline_assembler(cmd)
kadonotakashi 0:8fdf9a60065b 199
kadonotakashi 0:8fdf9a60065b 200 # Return command array, don't execute
kadonotakashi 0:8fdf9a60065b 201 return [cmd]
kadonotakashi 0:8fdf9a60065b 202
kadonotakashi 0:8fdf9a60065b 203 @hook_tool
kadonotakashi 0:8fdf9a60065b 204 def compile(self, cc, source, object, includes):
kadonotakashi 0:8fdf9a60065b 205 # Build compile command
kadonotakashi 0:8fdf9a60065b 206 cmd = cc + self.get_compile_options(self.get_symbols(), includes)
kadonotakashi 0:8fdf9a60065b 207
kadonotakashi 0:8fdf9a60065b 208 cmd.extend(self.get_dep_option(object))
kadonotakashi 0:8fdf9a60065b 209
kadonotakashi 0:8fdf9a60065b 210 cmd.extend(["-o", object, source])
kadonotakashi 0:8fdf9a60065b 211
kadonotakashi 0:8fdf9a60065b 212 # Call cmdline hook
kadonotakashi 0:8fdf9a60065b 213 cmd = self.hook.get_cmdline_compiler(cmd)
kadonotakashi 0:8fdf9a60065b 214 if self.use_distcc:
kadonotakashi 0:8fdf9a60065b 215 cmd = ["distcc"] + cmd
kadonotakashi 0:8fdf9a60065b 216
kadonotakashi 0:8fdf9a60065b 217 return [cmd]
kadonotakashi 0:8fdf9a60065b 218
kadonotakashi 0:8fdf9a60065b 219 def compile_c(self, source, object, includes):
kadonotakashi 0:8fdf9a60065b 220 return self.compile(self.cc, source, object, includes)
kadonotakashi 0:8fdf9a60065b 221
kadonotakashi 0:8fdf9a60065b 222 def compile_cpp(self, source, object, includes):
kadonotakashi 0:8fdf9a60065b 223 return self.compile(self.cppc, source, object, includes)
kadonotakashi 0:8fdf9a60065b 224
kadonotakashi 0:8fdf9a60065b 225 @hook_tool
kadonotakashi 0:8fdf9a60065b 226 def link(self, output, objects, libraries, lib_dirs, mem_map):
kadonotakashi 0:8fdf9a60065b 227 libs = []
kadonotakashi 0:8fdf9a60065b 228 for l in libraries:
kadonotakashi 0:8fdf9a60065b 229 name, _ = splitext(basename(l))
kadonotakashi 0:8fdf9a60065b 230 libs.append("-l%s" % name[3:])
kadonotakashi 0:8fdf9a60065b 231 libs.extend(["-l%s" % l for l in self.sys_libs])
kadonotakashi 0:8fdf9a60065b 232
kadonotakashi 0:8fdf9a60065b 233 # Preprocess
kadonotakashi 0:8fdf9a60065b 234 if mem_map:
kadonotakashi 0:8fdf9a60065b 235 preproc_output = join(dirname(output), ".link_script.ld")
kadonotakashi 0:8fdf9a60065b 236 cmd = (self.preproc + [mem_map] + self.ld[1:] +
kadonotakashi 0:8fdf9a60065b 237 [ "-o", preproc_output])
kadonotakashi 0:8fdf9a60065b 238 self.notify.cc_verbose("Preproc: %s" % ' '.join(cmd))
kadonotakashi 0:8fdf9a60065b 239 self.default_cmd(cmd)
kadonotakashi 0:8fdf9a60065b 240 mem_map = preproc_output
kadonotakashi 0:8fdf9a60065b 241
kadonotakashi 0:8fdf9a60065b 242 # Build linker command
kadonotakashi 0:8fdf9a60065b 243 map_file = splitext(output)[0] + ".map"
kadonotakashi 0:8fdf9a60065b 244 cmd = self.ld + ["-o", output, "-Wl,-Map=%s" % map_file] + objects + ["-Wl,--start-group"] + libs + ["-Wl,--end-group"]
kadonotakashi 0:8fdf9a60065b 245
kadonotakashi 0:8fdf9a60065b 246 if mem_map:
kadonotakashi 0:8fdf9a60065b 247 cmd.extend(['-T', mem_map])
kadonotakashi 0:8fdf9a60065b 248
kadonotakashi 0:8fdf9a60065b 249 for L in lib_dirs:
kadonotakashi 0:8fdf9a60065b 250 cmd.extend(['-L', L])
kadonotakashi 0:8fdf9a60065b 251 cmd.extend(libs)
kadonotakashi 0:8fdf9a60065b 252
kadonotakashi 0:8fdf9a60065b 253 # Call cmdline hook
kadonotakashi 0:8fdf9a60065b 254 cmd = self.hook.get_cmdline_linker(cmd)
kadonotakashi 0:8fdf9a60065b 255
kadonotakashi 0:8fdf9a60065b 256 if self.RESPONSE_FILES:
kadonotakashi 0:8fdf9a60065b 257 # Split link command to linker executable + response file
kadonotakashi 0:8fdf9a60065b 258 cmd_linker = cmd[0]
kadonotakashi 0:8fdf9a60065b 259 link_files = self.get_link_file(cmd[1:])
kadonotakashi 0:8fdf9a60065b 260 cmd = [cmd_linker, "@%s" % link_files]
kadonotakashi 0:8fdf9a60065b 261
kadonotakashi 0:8fdf9a60065b 262 # Exec command
kadonotakashi 0:8fdf9a60065b 263 self.notify.cc_verbose("Link: %s" % ' '.join(cmd))
kadonotakashi 0:8fdf9a60065b 264 self.default_cmd(cmd)
kadonotakashi 0:8fdf9a60065b 265
kadonotakashi 0:8fdf9a60065b 266 @hook_tool
kadonotakashi 0:8fdf9a60065b 267 def archive(self, objects, lib_path):
kadonotakashi 0:8fdf9a60065b 268 if self.RESPONSE_FILES:
kadonotakashi 0:8fdf9a60065b 269 param = ["@%s" % self.get_arch_file(objects)]
kadonotakashi 0:8fdf9a60065b 270 else:
kadonotakashi 0:8fdf9a60065b 271 param = objects
kadonotakashi 0:8fdf9a60065b 272
kadonotakashi 0:8fdf9a60065b 273 # Exec command
kadonotakashi 0:8fdf9a60065b 274 self.default_cmd([self.ar, 'rcs', lib_path] + param)
kadonotakashi 0:8fdf9a60065b 275
kadonotakashi 0:8fdf9a60065b 276 @hook_tool
kadonotakashi 0:8fdf9a60065b 277 def binary(self, resources, elf, bin):
kadonotakashi 0:8fdf9a60065b 278 # Build binary command
kadonotakashi 0:8fdf9a60065b 279 _, fmt = splitext(bin)
kadonotakashi 0:8fdf9a60065b 280 bin_arg = {'.bin': 'binary', '.hex': 'ihex'}[fmt]
kadonotakashi 0:8fdf9a60065b 281 cmd = [self.elf2bin, "-O", bin_arg, elf, bin]
kadonotakashi 0:8fdf9a60065b 282
kadonotakashi 0:8fdf9a60065b 283 # Call cmdline hook
kadonotakashi 0:8fdf9a60065b 284 cmd = self.hook.get_cmdline_binary(cmd)
kadonotakashi 0:8fdf9a60065b 285
kadonotakashi 0:8fdf9a60065b 286 # Exec command
kadonotakashi 0:8fdf9a60065b 287 self.notify.cc_verbose("FromELF: %s" % ' '.join(cmd))
kadonotakashi 0:8fdf9a60065b 288 self.default_cmd(cmd)
kadonotakashi 0:8fdf9a60065b 289
kadonotakashi 0:8fdf9a60065b 290 @staticmethod
kadonotakashi 0:8fdf9a60065b 291 def name_mangle(name):
kadonotakashi 0:8fdf9a60065b 292 return "_Z%i%sv" % (len(name), name)
kadonotakashi 0:8fdf9a60065b 293
kadonotakashi 0:8fdf9a60065b 294 @staticmethod
kadonotakashi 0:8fdf9a60065b 295 def make_ld_define(name, value):
kadonotakashi 0:8fdf9a60065b 296 return "-D%s=%s" % (name, value)
kadonotakashi 0:8fdf9a60065b 297
kadonotakashi 0:8fdf9a60065b 298 @staticmethod
kadonotakashi 0:8fdf9a60065b 299 def redirect_symbol(source, sync, build_dir):
kadonotakashi 0:8fdf9a60065b 300 return "-Wl,--defsym=%s=%s" % (source, sync)
kadonotakashi 0:8fdf9a60065b 301
kadonotakashi 0:8fdf9a60065b 302 @staticmethod
kadonotakashi 0:8fdf9a60065b 303 def check_executable():
kadonotakashi 0:8fdf9a60065b 304 """Returns True if the executable (arm-none-eabi-gcc) location
kadonotakashi 0:8fdf9a60065b 305 specified by the user exists OR the executable can be found on the PATH.
kadonotakashi 0:8fdf9a60065b 306 Returns False otherwise."""
kadonotakashi 0:8fdf9a60065b 307 if not TOOLCHAIN_PATHS['GCC_ARM'] or not exists(TOOLCHAIN_PATHS['GCC_ARM']):
kadonotakashi 0:8fdf9a60065b 308 if find_executable('arm-none-eabi-gcc'):
kadonotakashi 0:8fdf9a60065b 309 TOOLCHAIN_PATHS['GCC_ARM'] = ''
kadonotakashi 0:8fdf9a60065b 310 return True
kadonotakashi 0:8fdf9a60065b 311 else:
kadonotakashi 0:8fdf9a60065b 312 return False
kadonotakashi 0:8fdf9a60065b 313 else:
kadonotakashi 0:8fdf9a60065b 314 exec_name = join(TOOLCHAIN_PATHS['GCC_ARM'], 'arm-none-eabi-gcc')
kadonotakashi 0:8fdf9a60065b 315 return exists(exec_name) or exists(exec_name + '.exe')
kadonotakashi 0:8fdf9a60065b 316
kadonotakashi 0:8fdf9a60065b 317 class GCC_ARM(GCC):
kadonotakashi 0:8fdf9a60065b 318 pass