Clone of official tools

Committer:
Anders Blomdell
Date:
Thu Feb 04 17:17:13 2021 +0100
Revision:
47:21ae3e5a7128
Parent:
43:2a7da56ebd24
Add a few normpath calls

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 0:66f3b5499f7f 1 #! /usr/bin/env python2
screamer 0:66f3b5499f7f 2 """
screamer 0:66f3b5499f7f 3 mbed SDK
screamer 0:66f3b5499f7f 4 Copyright (c) 2011-2013 ARM Limited
screamer 0:66f3b5499f7f 5
screamer 0:66f3b5499f7f 6 Licensed under the Apache License, Version 2.0 (the "License");
screamer 0:66f3b5499f7f 7 you may not use this file except in compliance with the License.
screamer 0:66f3b5499f7f 8 You may obtain a copy of the License at
screamer 0:66f3b5499f7f 9
screamer 0:66f3b5499f7f 10 http://www.apache.org/licenses/LICENSE-2.0
screamer 0:66f3b5499f7f 11
screamer 0:66f3b5499f7f 12 Unless required by applicable law or agreed to in writing, software
screamer 0:66f3b5499f7f 13 distributed under the License is distributed on an "AS IS" BASIS,
screamer 0:66f3b5499f7f 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
screamer 0:66f3b5499f7f 15 See the License for the specific language governing permissions and
screamer 0:66f3b5499f7f 16 limitations under the License.
screamer 0:66f3b5499f7f 17
screamer 0:66f3b5499f7f 18
screamer 0:66f3b5499f7f 19 TEST BUILD & RUN
screamer 0:66f3b5499f7f 20 """
theotherjimmy 43:2a7da56ebd24 21 from __future__ import print_function
theotherjimmy 43:2a7da56ebd24 22 from builtins import str
screamer 0:66f3b5499f7f 23 import sys
The Other Jimmy 31:8ea194f6145b 24 import json
screamer 0:66f3b5499f7f 25 from time import sleep
screamer 0:66f3b5499f7f 26 from shutil import copy
The Other Jimmy 31:8ea194f6145b 27 from os.path import join, abspath, dirname
The Other Jimmy 36:96847d42f010 28 from json import load, dump
screamer 0:66f3b5499f7f 29
screamer 0:66f3b5499f7f 30 # Be sure that the tools directory is in the search path
screamer 0:66f3b5499f7f 31 ROOT = abspath(join(dirname(__file__), ".."))
screamer 0:66f3b5499f7f 32 sys.path.insert(0, ROOT)
screamer 0:66f3b5499f7f 33
screamer 0:66f3b5499f7f 34 from tools.utils import args_error
The Other Jimmy 31:8ea194f6145b 35 from tools.utils import NotSupportedException
screamer 0:66f3b5499f7f 36 from tools.paths import BUILD_DIR
The Other Jimmy 31:8ea194f6145b 37 from tools.paths import MBED_LIBRARIES
screamer 0:66f3b5499f7f 38 from tools.paths import RPC_LIBRARY
The Other Jimmy 36:96847d42f010 39 from tools.paths import USB_LIBRARIES
screamer 0:66f3b5499f7f 40 from tools.paths import DSP_LIBRARIES
screamer 0:66f3b5499f7f 41 from tools.tests import TESTS, Test, TEST_MAP
screamer 0:66f3b5499f7f 42 from tools.tests import TEST_MBED_LIB
screamer 22:9e85236d8716 43 from tools.tests import test_known, test_name_known
screamer 0:66f3b5499f7f 44 from tools.targets import TARGET_MAP
screamer 0:66f3b5499f7f 45 from tools.options import get_default_options_parser
The Other Jimmy 31:8ea194f6145b 46 from tools.options import extract_profile
The Other Jimmy 38:399953da035d 47 from tools.options import extract_mcus
theotherjimmy 43:2a7da56ebd24 48 from tools.notifier.term import TerminalNotifier
screamer 0:66f3b5499f7f 49 from tools.build_api import build_project
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 50 from tools.build_api import mcu_toolchain_matrix
The Other Jimmy 36:96847d42f010 51 from tools.build_api import mcu_toolchain_list
The Other Jimmy 36:96847d42f010 52 from tools.build_api import mcu_target_list
The Other Jimmy 36:96847d42f010 53 from tools.build_api import merge_build_data
screamer 22:9e85236d8716 54 from utils import argparse_filestring_type
screamer 22:9e85236d8716 55 from utils import argparse_many
screamer 24:25bff2709c20 56 from utils import argparse_dir_not_parent
The Other Jimmy 31:8ea194f6145b 57 from tools.toolchains import mbedToolchain, TOOLCHAIN_CLASSES, TOOLCHAIN_PATHS
screamer 0:66f3b5499f7f 58
screamer 0:66f3b5499f7f 59 if __name__ == '__main__':
screamer 0:66f3b5499f7f 60 # Parse Options
The Other Jimmy 31:8ea194f6145b 61 parser = get_default_options_parser(add_app_config=True)
screamer 22:9e85236d8716 62 group = parser.add_mutually_exclusive_group(required=False)
theotherjimmy 40:7d3fa6b99b2b 63 group.add_argument(
theotherjimmy 40:7d3fa6b99b2b 64 "-p",
theotherjimmy 40:7d3fa6b99b2b 65 type=argparse_many(test_known),
theotherjimmy 40:7d3fa6b99b2b 66 dest="program",
theotherjimmy 40:7d3fa6b99b2b 67 help="The index of the desired test program: [0-%d]" % (len(TESTS)-1))
screamer 0:66f3b5499f7f 68
theotherjimmy 40:7d3fa6b99b2b 69 group.add_argument(
theotherjimmy 40:7d3fa6b99b2b 70 "-n",
theotherjimmy 40:7d3fa6b99b2b 71 type=argparse_many(test_name_known),
theotherjimmy 40:7d3fa6b99b2b 72 dest="program",
theotherjimmy 40:7d3fa6b99b2b 73 help="The name of the desired test program")
screamer 0:66f3b5499f7f 74
theotherjimmy 40:7d3fa6b99b2b 75 parser.add_argument(
theotherjimmy 40:7d3fa6b99b2b 76 "-j", "--jobs",
theotherjimmy 40:7d3fa6b99b2b 77 type=int,
theotherjimmy 40:7d3fa6b99b2b 78 dest="jobs",
theotherjimmy 40:7d3fa6b99b2b 79 default=0,
theotherjimmy 40:7d3fa6b99b2b 80 help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)")
screamer 0:66f3b5499f7f 81
theotherjimmy 40:7d3fa6b99b2b 82 parser.add_argument(
theotherjimmy 40:7d3fa6b99b2b 83 "-v", "--verbose",
theotherjimmy 40:7d3fa6b99b2b 84 action="store_true",
theotherjimmy 40:7d3fa6b99b2b 85 dest="verbose",
theotherjimmy 40:7d3fa6b99b2b 86 default=False,
theotherjimmy 40:7d3fa6b99b2b 87 help="Verbose diagnostic output")
screamer 0:66f3b5499f7f 88
theotherjimmy 40:7d3fa6b99b2b 89 parser.add_argument(
theotherjimmy 40:7d3fa6b99b2b 90 "--silent",
theotherjimmy 40:7d3fa6b99b2b 91 action="store_true",
theotherjimmy 40:7d3fa6b99b2b 92 dest="silent",
theotherjimmy 40:7d3fa6b99b2b 93 default=False,
theotherjimmy 40:7d3fa6b99b2b 94 help="Silent diagnostic output (no copy, compile notification)")
screamer 0:66f3b5499f7f 95
theotherjimmy 40:7d3fa6b99b2b 96 parser.add_argument(
theotherjimmy 40:7d3fa6b99b2b 97 "-D",
theotherjimmy 40:7d3fa6b99b2b 98 action="append",
theotherjimmy 40:7d3fa6b99b2b 99 dest="macros",
theotherjimmy 40:7d3fa6b99b2b 100 help="Add a macro definition")
screamer 0:66f3b5499f7f 101
theotherjimmy 40:7d3fa6b99b2b 102 group.add_argument(
theotherjimmy 40:7d3fa6b99b2b 103 "-S", "--supported-toolchains",
theotherjimmy 40:7d3fa6b99b2b 104 dest="supported_toolchains",
theotherjimmy 40:7d3fa6b99b2b 105 default=False,
theotherjimmy 40:7d3fa6b99b2b 106 const="matrix",
theotherjimmy 40:7d3fa6b99b2b 107 choices=["matrix", "toolchains", "targets"],
theotherjimmy 40:7d3fa6b99b2b 108 nargs="?",
theotherjimmy 40:7d3fa6b99b2b 109 help="Displays supported matrix of MCUs and toolchains")
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 110
theotherjimmy 40:7d3fa6b99b2b 111 parser.add_argument(
theotherjimmy 40:7d3fa6b99b2b 112 '-f', '--filter',
theotherjimmy 40:7d3fa6b99b2b 113 dest='general_filter_regex',
theotherjimmy 40:7d3fa6b99b2b 114 default=None,
theotherjimmy 40:7d3fa6b99b2b 115 help='For some commands you can use filter to filter out results')
theotherjimmy 40:7d3fa6b99b2b 116
theotherjimmy 40:7d3fa6b99b2b 117 parser.add_argument(
theotherjimmy 40:7d3fa6b99b2b 118 "--stats-depth",
theotherjimmy 40:7d3fa6b99b2b 119 type=int,
theotherjimmy 40:7d3fa6b99b2b 120 dest="stats_depth",
theotherjimmy 40:7d3fa6b99b2b 121 default=2,
theotherjimmy 40:7d3fa6b99b2b 122 help="Depth level for static memory report")
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 123
screamer 0:66f3b5499f7f 124 # Local run
screamer 22:9e85236d8716 125 parser.add_argument("--automated", action="store_true", dest="automated",
screamer 0:66f3b5499f7f 126 default=False, help="Automated test")
screamer 22:9e85236d8716 127 parser.add_argument("--host", dest="host_test",
screamer 0:66f3b5499f7f 128 default=None, help="Host test")
screamer 22:9e85236d8716 129 parser.add_argument("--extra", dest="extra",
screamer 0:66f3b5499f7f 130 default=None, help="Extra files")
screamer 22:9e85236d8716 131 parser.add_argument("--peripherals", dest="peripherals",
screamer 0:66f3b5499f7f 132 default=None, help="Required peripherals")
screamer 22:9e85236d8716 133 parser.add_argument("--dep", dest="dependencies",
screamer 0:66f3b5499f7f 134 default=None, help="Dependencies")
screamer 22:9e85236d8716 135 parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type,
screamer 22:9e85236d8716 136 default=None, help="The source (input) directory", action="append")
screamer 22:9e85236d8716 137 parser.add_argument("--duration", type=int, dest="duration",
screamer 0:66f3b5499f7f 138 default=None, help="Duration of the test")
screamer 24:25bff2709c20 139 parser.add_argument("--build", dest="build_dir", type=argparse_dir_not_parent(ROOT),
screamer 0:66f3b5499f7f 140 default=None, help="The build (output) directory")
screamer 22:9e85236d8716 141 parser.add_argument("-N", "--artifact-name", dest="artifact_name",
screamer 0:66f3b5499f7f 142 default=None, help="The built project's name")
theotherjimmy 43:2a7da56ebd24 143 parser.add_argument("--ignore", dest="ignore", type=argparse_many(str),
theotherjimmy 43:2a7da56ebd24 144 default=None, help="Comma separated list of patterns to add to mbedignore (eg. ./main.cpp)")
screamer 22:9e85236d8716 145 parser.add_argument("-d", "--disk", dest="disk",
screamer 0:66f3b5499f7f 146 default=None, help="The mbed disk")
screamer 22:9e85236d8716 147 parser.add_argument("-s", "--serial", dest="serial",
screamer 0:66f3b5499f7f 148 default=None, help="The mbed serial port")
screamer 22:9e85236d8716 149 parser.add_argument("-b", "--baud", type=int, dest="baud",
screamer 0:66f3b5499f7f 150 default=None, help="The mbed serial baud rate")
screamer 22:9e85236d8716 151 group.add_argument("-L", "--list-tests", action="store_true", dest="list_tests",
screamer 0:66f3b5499f7f 152 default=False, help="List available tests in order and exit")
screamer 0:66f3b5499f7f 153
screamer 0:66f3b5499f7f 154 # Ideally, all the tests with a single "main" thread can be run with, or
The Other Jimmy 36:96847d42f010 155 # without the usb, dsp
screamer 22:9e85236d8716 156 parser.add_argument("--rpc",
screamer 0:66f3b5499f7f 157 action="store_true", dest="rpc",
screamer 0:66f3b5499f7f 158 default=False, help="Link with RPC library")
screamer 0:66f3b5499f7f 159
screamer 22:9e85236d8716 160 parser.add_argument("--usb",
screamer 0:66f3b5499f7f 161 action="store_true",
screamer 0:66f3b5499f7f 162 dest="usb",
screamer 0:66f3b5499f7f 163 default=False,
screamer 0:66f3b5499f7f 164 help="Link with USB Device library")
screamer 0:66f3b5499f7f 165
screamer 22:9e85236d8716 166 parser.add_argument("--dsp",
screamer 0:66f3b5499f7f 167 action="store_true",
screamer 0:66f3b5499f7f 168 dest="dsp",
screamer 0:66f3b5499f7f 169 default=False,
screamer 0:66f3b5499f7f 170 help="Link with DSP library")
screamer 0:66f3b5499f7f 171
screamer 22:9e85236d8716 172 parser.add_argument("--testlib",
screamer 0:66f3b5499f7f 173 action="store_true",
screamer 0:66f3b5499f7f 174 dest="testlib",
screamer 0:66f3b5499f7f 175 default=False,
screamer 0:66f3b5499f7f 176 help="Link with mbed test library")
screamer 0:66f3b5499f7f 177
The Other Jimmy 36:96847d42f010 178 parser.add_argument("--build-data",
The Other Jimmy 36:96847d42f010 179 dest="build_data",
The Other Jimmy 36:96847d42f010 180 default=None,
The Other Jimmy 36:96847d42f010 181 help="Dump build_data to this file")
The Other Jimmy 36:96847d42f010 182
screamer 0:66f3b5499f7f 183 # Specify a different linker script
screamer 22:9e85236d8716 184 parser.add_argument("-l", "--linker", dest="linker_script",
screamer 22:9e85236d8716 185 type=argparse_filestring_type,
screamer 0:66f3b5499f7f 186 default=None, help="use the specified linker script")
screamer 0:66f3b5499f7f 187
screamer 22:9e85236d8716 188 options = parser.parse_args()
screamer 0:66f3b5499f7f 189
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 190 # Only prints matrix of supported toolchains
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 191 if options.supported_toolchains:
The Other Jimmy 36:96847d42f010 192 if options.supported_toolchains == "matrix":
theotherjimmy 43:2a7da56ebd24 193 print(mcu_toolchain_matrix(platform_filter=options.general_filter_regex,
theotherjimmy 43:2a7da56ebd24 194 release_version=None))
The Other Jimmy 36:96847d42f010 195 elif options.supported_toolchains == "toolchains":
The Other Jimmy 36:96847d42f010 196 toolchain_list = mcu_toolchain_list()
The Other Jimmy 36:96847d42f010 197 # Only print the lines that matter
The Other Jimmy 36:96847d42f010 198 for line in toolchain_list.split("\n"):
The Other Jimmy 36:96847d42f010 199 if not "mbed" in line:
theotherjimmy 43:2a7da56ebd24 200 print(line)
The Other Jimmy 36:96847d42f010 201 elif options.supported_toolchains == "targets":
theotherjimmy 43:2a7da56ebd24 202 print(mcu_target_list())
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 203 exit(0)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 204
screamer 0:66f3b5499f7f 205 # Print available tests in order and exit
screamer 0:66f3b5499f7f 206 if options.list_tests is True:
theotherjimmy 43:2a7da56ebd24 207 print('\n'.join(map(str, sorted(TEST_MAP.values()))))
screamer 0:66f3b5499f7f 208 sys.exit()
screamer 0:66f3b5499f7f 209
screamer 0:66f3b5499f7f 210 # force program to "0" if a source dir is specified
screamer 0:66f3b5499f7f 211 if options.source_dir is not None:
screamer 0:66f3b5499f7f 212 p = 0
screamer 0:66f3b5499f7f 213 else:
screamer 0:66f3b5499f7f 214 # Program Number or name
screamer 22:9e85236d8716 215 p = options.program
screamer 0:66f3b5499f7f 216
screamer 0:66f3b5499f7f 217 # If 'p' was set via -n to list of numbers make this a single element integer list
screamer 0:66f3b5499f7f 218 if type(p) != type([]):
screamer 0:66f3b5499f7f 219 p = [p]
screamer 0:66f3b5499f7f 220
screamer 0:66f3b5499f7f 221 # Target
screamer 0:66f3b5499f7f 222 if options.mcu is None :
The Other Jimmy 31:8ea194f6145b 223 args_error(parser, "argument -m/--mcu is required")
The Other Jimmy 38:399953da035d 224 mcu = extract_mcus(parser, options)[0]
screamer 0:66f3b5499f7f 225
screamer 0:66f3b5499f7f 226 # Toolchain
screamer 0:66f3b5499f7f 227 if options.tool is None:
The Other Jimmy 31:8ea194f6145b 228 args_error(parser, "argument -t/--tool is required")
screamer 22:9e85236d8716 229 toolchain = options.tool[0]
screamer 22:9e85236d8716 230
The Other Jimmy 31:8ea194f6145b 231 if (options.program is None) and (not options.source_dir):
The Other Jimmy 31:8ea194f6145b 232 args_error(parser, "one of -p, -n, or --source is required")
The Other Jimmy 31:8ea194f6145b 233
The Other Jimmy 31:8ea194f6145b 234 if options.source_dir and not options.build_dir:
The Other Jimmy 31:8ea194f6145b 235 args_error(parser, "argument --build is required when argument --source is provided")
The Other Jimmy 31:8ea194f6145b 236
The Other Jimmy 31:8ea194f6145b 237
theotherjimmy 43:2a7da56ebd24 238 notify = TerminalNotifier(options.verbose, options.silent, options.color)
screamer 0:66f3b5499f7f 239
The Other Jimmy 31:8ea194f6145b 240 if not TOOLCHAIN_CLASSES[toolchain].check_executable():
The Other Jimmy 31:8ea194f6145b 241 search_path = TOOLCHAIN_PATHS[toolchain] or "No path set"
The Other Jimmy 31:8ea194f6145b 242 args_error(parser, "Could not find executable for %s.\n"
The Other Jimmy 31:8ea194f6145b 243 "Currently set search path: %s"
theotherjimmy 43:2a7da56ebd24 244 %(toolchain, search_path))
The Other Jimmy 31:8ea194f6145b 245
screamer 0:66f3b5499f7f 246 # Test
The Other Jimmy 36:96847d42f010 247 build_data_blob = {} if options.build_data else None
screamer 0:66f3b5499f7f 248 for test_no in p:
screamer 0:66f3b5499f7f 249 test = Test(test_no)
screamer 0:66f3b5499f7f 250 if options.automated is not None: test.automated = options.automated
screamer 0:66f3b5499f7f 251 if options.dependencies is not None: test.dependencies = options.dependencies
screamer 0:66f3b5499f7f 252 if options.host_test is not None: test.host_test = options.host_test;
screamer 0:66f3b5499f7f 253 if options.peripherals is not None: test.peripherals = options.peripherals;
screamer 0:66f3b5499f7f 254 if options.duration is not None: test.duration = options.duration;
screamer 0:66f3b5499f7f 255 if options.extra is not None: test.extra_files = options.extra
screamer 0:66f3b5499f7f 256
screamer 0:66f3b5499f7f 257 if not test.is_supported(mcu, toolchain):
theotherjimmy 43:2a7da56ebd24 258 print('The selected test is not supported on target %s with toolchain %s' % (mcu, toolchain))
screamer 0:66f3b5499f7f 259 sys.exit()
screamer 0:66f3b5499f7f 260
screamer 0:66f3b5499f7f 261 # Linking with extra libraries
screamer 0:66f3b5499f7f 262 if options.rpc: test.dependencies.append(RPC_LIBRARY)
screamer 0:66f3b5499f7f 263 if options.usb: test.dependencies.append(USB_LIBRARIES)
screamer 0:66f3b5499f7f 264 if options.dsp: test.dependencies.append(DSP_LIBRARIES)
screamer 0:66f3b5499f7f 265 if options.testlib: test.dependencies.append(TEST_MBED_LIB)
screamer 0:66f3b5499f7f 266
screamer 0:66f3b5499f7f 267 build_dir = join(BUILD_DIR, "test", mcu, toolchain, test.id)
screamer 0:66f3b5499f7f 268 if options.source_dir is not None:
screamer 0:66f3b5499f7f 269 test.source_dir = options.source_dir
screamer 0:66f3b5499f7f 270 build_dir = options.source_dir
screamer 0:66f3b5499f7f 271
screamer 0:66f3b5499f7f 272 if options.build_dir is not None:
screamer 0:66f3b5499f7f 273 build_dir = options.build_dir
screamer 0:66f3b5499f7f 274
screamer 0:66f3b5499f7f 275 try:
theotherjimmy 43:2a7da56ebd24 276 bin_file, update_file = build_project(
theotherjimmy 43:2a7da56ebd24 277 test.source_dir,
theotherjimmy 43:2a7da56ebd24 278 build_dir,
theotherjimmy 43:2a7da56ebd24 279 mcu,
theotherjimmy 43:2a7da56ebd24 280 toolchain,
theotherjimmy 43:2a7da56ebd24 281 set(test.dependencies),
theotherjimmy 43:2a7da56ebd24 282 linker_script=options.linker_script,
theotherjimmy 43:2a7da56ebd24 283 clean=options.clean,
theotherjimmy 43:2a7da56ebd24 284 notify=notify,
theotherjimmy 43:2a7da56ebd24 285 report=build_data_blob,
theotherjimmy 43:2a7da56ebd24 286 macros=options.macros,
theotherjimmy 43:2a7da56ebd24 287 jobs=options.jobs,
theotherjimmy 43:2a7da56ebd24 288 name=options.artifact_name,
theotherjimmy 43:2a7da56ebd24 289 app_config=options.app_config,
theotherjimmy 43:2a7da56ebd24 290 inc_dirs=[dirname(MBED_LIBRARIES)],
theotherjimmy 43:2a7da56ebd24 291 build_profile=extract_profile(parser, options, toolchain),
theotherjimmy 43:2a7da56ebd24 292 stats_depth=options.stats_depth,
theotherjimmy 43:2a7da56ebd24 293 ignore=options.ignore
theotherjimmy 43:2a7da56ebd24 294 )
theotherjimmy 43:2a7da56ebd24 295 if update_file:
theotherjimmy 43:2a7da56ebd24 296 print('Update Image: %s' % update_file)
theotherjimmy 43:2a7da56ebd24 297 print('Image: %s' % bin_file)
screamer 0:66f3b5499f7f 298
screamer 0:66f3b5499f7f 299 if options.disk:
screamer 0:66f3b5499f7f 300 # Simple copy to the mbed disk
screamer 0:66f3b5499f7f 301 copy(bin_file, options.disk)
screamer 0:66f3b5499f7f 302
screamer 0:66f3b5499f7f 303 if options.serial:
screamer 0:66f3b5499f7f 304 # Import pyserial: https://pypi.python.org/pypi/pyserial
screamer 0:66f3b5499f7f 305 from serial import Serial
screamer 0:66f3b5499f7f 306
screamer 13:ab47a20b66f0 307 sleep(TARGET_MAP[mcu].program_cycle_s)
screamer 0:66f3b5499f7f 308
screamer 0:66f3b5499f7f 309 serial = Serial(options.serial, timeout = 1)
screamer 0:66f3b5499f7f 310 if options.baud:
screamer 0:66f3b5499f7f 311 serial.setBaudrate(options.baud)
screamer 0:66f3b5499f7f 312
screamer 0:66f3b5499f7f 313 serial.flushInput()
screamer 0:66f3b5499f7f 314 serial.flushOutput()
screamer 0:66f3b5499f7f 315
screamer 0:66f3b5499f7f 316 try:
screamer 0:66f3b5499f7f 317 serial.sendBreak()
screamer 0:66f3b5499f7f 318 except:
screamer 0:66f3b5499f7f 319 # In linux a termios.error is raised in sendBreak and in setBreak.
screamer 0:66f3b5499f7f 320 # The following setBreak() is needed to release the reset signal on the target mcu.
screamer 0:66f3b5499f7f 321 try:
screamer 0:66f3b5499f7f 322 serial.setBreak(False)
screamer 0:66f3b5499f7f 323 except:
screamer 0:66f3b5499f7f 324 pass
screamer 0:66f3b5499f7f 325
screamer 0:66f3b5499f7f 326 while True:
screamer 0:66f3b5499f7f 327 c = serial.read(512)
screamer 0:66f3b5499f7f 328 sys.stdout.write(c)
screamer 0:66f3b5499f7f 329 sys.stdout.flush()
screamer 0:66f3b5499f7f 330
theotherjimmy 43:2a7da56ebd24 331 except KeyboardInterrupt as e:
theotherjimmy 43:2a7da56ebd24 332 print("\n[CTRL+c] exit")
The Other Jimmy 36:96847d42f010 333 except NotSupportedException as e:
theotherjimmy 43:2a7da56ebd24 334 print("\nCould not compile for %s: %s" % (mcu, str(e)))
theotherjimmy 43:2a7da56ebd24 335 except Exception as e:
screamer 0:66f3b5499f7f 336 if options.verbose:
screamer 0:66f3b5499f7f 337 import traceback
screamer 0:66f3b5499f7f 338 traceback.print_exc(file=sys.stdout)
screamer 0:66f3b5499f7f 339 else:
theotherjimmy 43:2a7da56ebd24 340 print("[ERROR] %s" % str(e))
theotherjimmy 40:7d3fa6b99b2b 341
screamer 0:66f3b5499f7f 342 sys.exit(1)
The Other Jimmy 36:96847d42f010 343 if options.build_data:
The Other Jimmy 36:96847d42f010 344 merge_build_data(options.build_data, build_data_blob, "application")