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