3Copyright (c) 2011-2016 ARM Limited
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11Unless required by applicable law or agreed to
in writing, software
12distributed under the License
is distributed on an
"AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied.
14See the License
for the specific language governing permissions
and
15limitations under the License.
17Author: Przemyslaw Wirkus <Przemyslaw.Wirkus
@arm.com>
23### Flashing/Reset API provided by mbed--host-tests (mbedhtrun)
24from . import host_tests_plugins
27def cmd_parser_setup():
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.