Skip to content

Commit 8f4cb59

Browse files
committed
Added script for detecting connected mbed targets/boards
1 parent 9dbf807 commit 8f4cb59

File tree

2 files changed

+157
-0
lines changed

2 files changed

+157
-0
lines changed

tools/default_settings.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""
2+
mbed SDK
3+
Copyright (c) 2011-2013 ARM Limited
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
"""
14+
15+
from os.path import join, abspath, dirname
16+
import logging
17+
18+
ROOT = abspath(join(dirname(__file__), ".."))
19+
20+
# These default settings have two purposes:
21+
# 1) Give a template for writing local "private_settings.py"
22+
# 2) Give default initialization fields for the "toolchains.py" constructors
23+
24+
##############################################################################
25+
# Build System Settings
26+
##############################################################################
27+
BUILD_DIR = abspath(join(ROOT, "build"))
28+
29+
# ARM
30+
ARM_PATH = "C:/Program Files/ARM"
31+
ARM_BIN = join(ARM_PATH, "bin")
32+
ARM_INC = join(ARM_PATH, "include")
33+
ARM_LIB = join(ARM_PATH, "lib")
34+
35+
ARM_CPPLIB = join(ARM_LIB, "cpplib")
36+
MY_ARM_CLIB = join(ARM_PATH, "lib", "microlib")
37+
38+
# GCC ARM
39+
GCC_ARM_PATH = ""
40+
41+
# GCC CodeRed
42+
GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin"
43+
44+
# IAR
45+
IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm"
46+
47+
# Goanna static analyser. Please overload it in private_settings.py
48+
GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin"
49+
50+
# cppcheck path (command) and output message format
51+
CPPCHECK_CMD = ["cppcheck", "--enable=all"]
52+
CPPCHECK_MSG_FORMAT = ["--template=[{severity}] {file}@{line}: {id}:{message}"]
53+
54+
BUILD_OPTIONS = []
55+
56+
# mbed.org username
57+
MBED_ORG_USER = ""
58+
59+
##############################################################################
60+
# Private Settings
61+
##############################################################################
62+
try:
63+
# Allow to overwrite the default settings without the need to edit the
64+
# settings file stored in the repository
65+
from mbed_settings import *
66+
except ImportError:
67+
print '[WARNING] Using default settings. Define your settings in the file "./mbed_settings.py"'

tools/detect_targets.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#! /usr/bin/env python2
2+
"""
3+
mbed SDK
4+
Copyright (c) 2011-2013 ARM Limited
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
19+
TEST BUILD & RUN
20+
"""
21+
import sys
22+
import os
23+
import json
24+
25+
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
26+
sys.path.insert(0, ROOT)
27+
28+
29+
from tools.options import get_default_options_parser
30+
31+
# Check: Extra modules which are required by core test suite
32+
from tools.utils import check_required_modules
33+
check_required_modules(['prettytable'])
34+
35+
# Imports related to mbed build api
36+
from tools.build_api import mcu_toolchain_matrix
37+
from tools.test_api import get_autodetected_MUTS_list
38+
39+
40+
if __name__ == '__main__':
41+
try:
42+
# Parse Options
43+
parser = get_default_options_parser()
44+
45+
parser.add_option("-S", "--supported-toolchains",
46+
action="store_true",
47+
dest="supported_toolchains",
48+
default=False,
49+
help="Displays supported matrix of targets and toolchains")
50+
51+
parser.add_option('-f', '--filter',
52+
dest='general_filter_regex',
53+
default=None,
54+
help='Filter targets')
55+
56+
parser.add_option("-v", "--verbose",
57+
action="store_true",
58+
dest="verbose",
59+
default=False,
60+
help="Verbose diagnostic output")
61+
62+
(options, args) = parser.parse_args()
63+
64+
# Only prints matrix of supported toolchains
65+
if options.supported_toolchains:
66+
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
67+
exit(0)
68+
69+
# If auto_detect attribute is present, we assume other auto-detection
70+
# parameters like 'toolchains_filter' are also set.
71+
MUTs = get_autodetected_MUTS_list()
72+
73+
count = 0
74+
for mut in MUTs.values():
75+
print ""
76+
print "[mbed] Detected %s, port %s, mounted %s" % (mut['mcu'], mut['port'], mut['disk'])
77+
print "[mbed] Supported toolchains for %s" % mut['mcu']
78+
print mcu_toolchain_matrix(platform_filter=r'^'+mut['mcu']+'$')
79+
count += 1
80+
81+
if count == 0:
82+
print "[mbed] No mbed targets where detected on your system."
83+
84+
except KeyboardInterrupt, e:
85+
print "\n[CTRL+c] exit"
86+
except Exception,e:
87+
import traceback
88+
traceback.print_exc(file=sys.stdout)
89+
print "[ERROR] %s" % str(e)
90+
sys.exit(1)

0 commit comments

Comments
 (0)