Committer:
borlanic
Date:
Fri Mar 30 14:07:05 2018 +0000
Revision:
4:75df35ef4fb6
Parent:
0:380207fcb5c1
commentar

Who changed what in which revision?

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