BBR 1 Ebene

Committer:
borlanic
Date:
Mon May 14 11:29:06 2018 +0000
Revision:
0:fbdae7e6d805
BBR

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:fbdae7e6d805 1 #! /usr/bin/env python2
borlanic 0:fbdae7e6d805 2 """
borlanic 0:fbdae7e6d805 3 mbed SDK
borlanic 0:fbdae7e6d805 4 Copyright (c) 2011-2013 ARM Limited
borlanic 0:fbdae7e6d805 5
borlanic 0:fbdae7e6d805 6 Licensed under the Apache License, Version 2.0 (the "License");
borlanic 0:fbdae7e6d805 7 you may not use this file except in compliance with the License.
borlanic 0:fbdae7e6d805 8 You may obtain a copy of the License at
borlanic 0:fbdae7e6d805 9
borlanic 0:fbdae7e6d805 10 http://www.apache.org/licenses/LICENSE-2.0
borlanic 0:fbdae7e6d805 11
borlanic 0:fbdae7e6d805 12 Unless required by applicable law or agreed to in writing, software
borlanic 0:fbdae7e6d805 13 distributed under the License is distributed on an "AS IS" BASIS,
borlanic 0:fbdae7e6d805 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
borlanic 0:fbdae7e6d805 15 See the License for the specific language governing permissions and
borlanic 0:fbdae7e6d805 16 limitations under the License.
borlanic 0:fbdae7e6d805 17 """
borlanic 0:fbdae7e6d805 18 from __future__ import print_function
borlanic 0:fbdae7e6d805 19 import sys
borlanic 0:fbdae7e6d805 20 import os
borlanic 0:fbdae7e6d805 21 import re
borlanic 0:fbdae7e6d805 22
borlanic 0:fbdae7e6d805 23 ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
borlanic 0:fbdae7e6d805 24 sys.path.insert(0, ROOT)
borlanic 0:fbdae7e6d805 25
borlanic 0:fbdae7e6d805 26 from tools.options import get_default_options_parser
borlanic 0:fbdae7e6d805 27
borlanic 0:fbdae7e6d805 28 # Check: Extra modules which are required by core test suite
borlanic 0:fbdae7e6d805 29 from tools.utils import check_required_modules
borlanic 0:fbdae7e6d805 30 check_required_modules(['prettytable'])
borlanic 0:fbdae7e6d805 31
borlanic 0:fbdae7e6d805 32 # Imports related to mbed build api
borlanic 0:fbdae7e6d805 33 from tools.build_api import mcu_toolchain_matrix
borlanic 0:fbdae7e6d805 34 from tools.test_api import get_autodetected_MUTS_list
borlanic 0:fbdae7e6d805 35 from tools.test_api import get_module_avail
borlanic 0:fbdae7e6d805 36 from argparse import ArgumentParser
borlanic 0:fbdae7e6d805 37
borlanic 0:fbdae7e6d805 38 try:
borlanic 0:fbdae7e6d805 39 import mbed_lstools
borlanic 0:fbdae7e6d805 40 except:
borlanic 0:fbdae7e6d805 41 pass
borlanic 0:fbdae7e6d805 42
borlanic 0:fbdae7e6d805 43 def main():
borlanic 0:fbdae7e6d805 44 """Entry Point"""
borlanic 0:fbdae7e6d805 45 try:
borlanic 0:fbdae7e6d805 46 # Parse Options
borlanic 0:fbdae7e6d805 47 parser = ArgumentParser()
borlanic 0:fbdae7e6d805 48
borlanic 0:fbdae7e6d805 49 parser.add_argument("-S", "--supported-toolchains",
borlanic 0:fbdae7e6d805 50 action="store_true",
borlanic 0:fbdae7e6d805 51 dest="supported_toolchains",
borlanic 0:fbdae7e6d805 52 default=False,
borlanic 0:fbdae7e6d805 53 help="Displays supported matrix of"
borlanic 0:fbdae7e6d805 54 " targets and toolchains")
borlanic 0:fbdae7e6d805 55
borlanic 0:fbdae7e6d805 56 parser.add_argument('-f', '--filter',
borlanic 0:fbdae7e6d805 57 dest='general_filter_regex',
borlanic 0:fbdae7e6d805 58 default=None,
borlanic 0:fbdae7e6d805 59 help='Filter targets')
borlanic 0:fbdae7e6d805 60
borlanic 0:fbdae7e6d805 61 parser.add_argument("-v", "--verbose",
borlanic 0:fbdae7e6d805 62 action="store_true",
borlanic 0:fbdae7e6d805 63 dest="verbose",
borlanic 0:fbdae7e6d805 64 default=False,
borlanic 0:fbdae7e6d805 65 help="Verbose diagnostic output")
borlanic 0:fbdae7e6d805 66
borlanic 0:fbdae7e6d805 67 options = parser.parse_args()
borlanic 0:fbdae7e6d805 68
borlanic 0:fbdae7e6d805 69 # Only prints matrix of supported toolchains
borlanic 0:fbdae7e6d805 70 if options.supported_toolchains:
borlanic 0:fbdae7e6d805 71 print(mcu_toolchain_matrix(
borlanic 0:fbdae7e6d805 72 platform_filter=options.general_filter_regex))
borlanic 0:fbdae7e6d805 73 exit(0)
borlanic 0:fbdae7e6d805 74
borlanic 0:fbdae7e6d805 75 # If auto_detect attribute is present, we assume other auto-detection
borlanic 0:fbdae7e6d805 76 # parameters like 'toolchains_filter' are also set.
borlanic 0:fbdae7e6d805 77 muts = get_autodetected_MUTS_list()
borlanic 0:fbdae7e6d805 78
borlanic 0:fbdae7e6d805 79 mcu_filter = options.general_filter_regex or ".*"
borlanic 0:fbdae7e6d805 80
borlanic 0:fbdae7e6d805 81 count = 0
borlanic 0:fbdae7e6d805 82 for mut in muts.values():
borlanic 0:fbdae7e6d805 83 if re.match(mcu_filter, mut['mcu'] or "Unknown"):
borlanic 0:fbdae7e6d805 84 interface_version = get_interface_version(mut['disk'])
borlanic 0:fbdae7e6d805 85 print("")
borlanic 0:fbdae7e6d805 86 print("[mbed] Detected %s, port %s, mounted %s, interface "
borlanic 0:fbdae7e6d805 87 "version %s:" %
borlanic 0:fbdae7e6d805 88 (mut['mcu'], mut['port'], mut['disk'], interface_version))
borlanic 0:fbdae7e6d805 89 print("[mbed] Supported toolchains for %s" % mut['mcu'])
borlanic 0:fbdae7e6d805 90 print(mcu_toolchain_matrix(platform_filter=mut['mcu']))
borlanic 0:fbdae7e6d805 91 count += 1
borlanic 0:fbdae7e6d805 92
borlanic 0:fbdae7e6d805 93 if count == 0:
borlanic 0:fbdae7e6d805 94 print("[mbed] No mbed targets were detected on your system.")
borlanic 0:fbdae7e6d805 95
borlanic 0:fbdae7e6d805 96 except KeyboardInterrupt:
borlanic 0:fbdae7e6d805 97 print("\n[CTRL+c] exit")
borlanic 0:fbdae7e6d805 98 except Exception as exc:
borlanic 0:fbdae7e6d805 99 import traceback
borlanic 0:fbdae7e6d805 100 traceback.print_exc(file=sys.stdout)
borlanic 0:fbdae7e6d805 101 print("[ERROR] %s" % str(exc))
borlanic 0:fbdae7e6d805 102 sys.exit(1)
borlanic 0:fbdae7e6d805 103
borlanic 0:fbdae7e6d805 104 def get_interface_version(mount_point):
borlanic 0:fbdae7e6d805 105 """ Function returns interface version from the target mounted on the specified mount point
borlanic 0:fbdae7e6d805 106
borlanic 0:fbdae7e6d805 107 mount_point can be acquired via the following:
borlanic 0:fbdae7e6d805 108 muts = get_autodetected_MUTS_list()
borlanic 0:fbdae7e6d805 109 for mut in muts.values():
borlanic 0:fbdae7e6d805 110 mount_point = mut['disk']
borlanic 0:fbdae7e6d805 111
borlanic 0:fbdae7e6d805 112 @param mount_point Name of disk where platform is connected to host machine.
borlanic 0:fbdae7e6d805 113 """
borlanic 0:fbdae7e6d805 114 if get_module_avail('mbed_lstools'):
borlanic 0:fbdae7e6d805 115 try :
borlanic 0:fbdae7e6d805 116 mbedls = mbed_lstools.create()
borlanic 0:fbdae7e6d805 117 mbeds = mbedls.list_mbeds(unique_names=True, read_details_txt=True)
borlanic 0:fbdae7e6d805 118
borlanic 0:fbdae7e6d805 119 for mbed in mbeds:
borlanic 0:fbdae7e6d805 120 if mbed['mount_point'] == mount_point:
borlanic 0:fbdae7e6d805 121
borlanic 0:fbdae7e6d805 122 if 'daplink_version' in mbed:
borlanic 0:fbdae7e6d805 123 return mbed['daplink_version']
borlanic 0:fbdae7e6d805 124 except :
borlanic 0:fbdae7e6d805 125 return 'unknown'
borlanic 0:fbdae7e6d805 126
borlanic 0:fbdae7e6d805 127 return 'unknown'
borlanic 0:fbdae7e6d805 128
borlanic 0:fbdae7e6d805 129 if __name__ == '__main__':
borlanic 0:fbdae7e6d805 130 main()