3 Copyright (c) 2011-2016 ARM Limited
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
17 Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
24 from .
import host_tests_plugins
28 """! Creates simple command line parser
30 parser = optparse.OptionParser()
32 parser.add_option(
'-f',
'--file',
34 help=
'File to flash onto mbed device')
36 parser.add_option(
"-d",
"--disk",
38 help=
"Target disk (mount point) path. Example: F:, /mnt/MBED",
41 copy_methods_str =
"Plugin support: " +
', '.join(host_tests_plugins.get_plugin_caps(
'CopyMethod'))
43 parser.add_option(
"-c",
"--copy",
46 help=
"Copy (flash the target) method selector. " + copy_methods_str,
47 metavar=
"COPY_METHOD")
49 parser.add_option(
'',
'--plugins',
53 help=
'Prints registered plugins and exits')
55 parser.add_option(
'',
'--version',
59 help=
'Prints package version and exits')
61 parser.description =
"""Flash mbed devices from command line.""" \
62 """This module is using build in to mbed-host-tests plugins used for flashing mbed devices"""
63 parser.epilog =
"""Example: mbedflsh -d E: -f /path/to/file.bin"""
65 (opts, args) = parser.parse_args()
70 """! Function wrapping flashing (copy) plugin
71 @details USers can use mbedflsh command to flash mbeds from command line
78 version = pkg_resources.require(
"mbed-host-tests")[0].version
81 elif opts.list_plugins:
82 host_tests_plugins.print_plugin_info()
88 print(
"mbedflsh: opening file %s..."% opts.filename)
89 result = host_tests_plugins.call_plugin(
'CopyMethod',
91 image_path=opts.filename,
92 destination_disk=opts.disk)
93 errorlevel_flag = result ==
True
95 return errorlevel_flag
def main()
Function wrapping flashing (copy) plugin.
def cmd_parser_setup()
Creates simple command line parser.