Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Sunxi Tools
Commits
24be7518
Commit
24be7518
authored
Dec 21, 2016
by
NiteHawk
Committed by
GitHub
Dec 21, 2016
Browse files
Merge pull request #87 from n1tehawk/contrib
fel: Improve on handling invalid options
parents
e31cbf86
0146dd4a
Changes
2
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
24be7518
...
...
@@ -41,7 +41,7 @@ When called with no arguments, _sunxi-fel_ will display a short usage summary.
_Note:_
Unless you select a specific device using the
`--dev`
or
`--sid`
options, the tool will access the first Allwinner device (in FEL mode) that it
finds. You can print a list of all FEL devices currently connected/detected
with
`./sunxi-fel --list`
.
with
`./sunxi-fel --list
--verbose
`
.
### fel-gpio
Simple wrapper (script) around
`fel-pio`
and
`sunxi-fel`
...
...
fel.c
View file @
24be7518
...
...
@@ -1044,6 +1044,19 @@ int main(int argc, char **argv)
argv
+=
1
;
}
/*
* If any option-style arguments remain (starting with '-') we know that
* we won't recognize them later (at best yielding "Invalid command").
* However this would only happen _AFTER_ trying to open a FEL device,
* which might fail with "Allwinner USB FEL device not found". To avoid
* confusing the user, bail out here - with a more descriptive message.
*/
int
i
;
for
(
i
=
1
;
i
<
argc
;
i
++
)
if
(
*
argv
[
i
]
==
'-'
)
pr_fatal
(
"Invalid option %s
\n
"
,
argv
[
i
]);
/* Process options that don't require a FEL device handle */
if
(
device_list
)
felusb_list_devices
();
/* and exit program afterwards */
if
(
sid_arg
)
{
...
...
@@ -1055,8 +1068,13 @@ int main(int argc, char **argv)
pr_info
(
"Selecting FEL device %03d:%03d by SID
\n
"
,
busnum
,
devnum
);
}
/*
* Open FEL device - either specified by busnum:devnum, or
* the first one matching the given USB vendor/procduct ID.
*/
handle
=
feldev_open
(
busnum
,
devnum
,
AW_USB_VENDOR_ID
,
AW_USB_PRODUCT_ID
);
/* Handle command-style arguments, in order of appearance */
while
(
argc
>
1
)
{
int
skip
=
1
;
...
...
@@ -1138,8 +1156,7 @@ int main(int argc, char **argv)
printf
(
"Warning:
\"
uboot
\"
command failed to detect image! Can't execute U-Boot.
\n
"
);
skip
=
2
;
}
else
{
fprintf
(
stderr
,
"Invalid command %s
\n
"
,
argv
[
1
]);
exit
(
1
);
pr_fatal
(
"Invalid command %s
\n
"
,
argv
[
1
]);
}
argc
-=
skip
;
argv
+=
skip
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment