diff --git a/commands/usbgadget.c b/commands/usbgadget.c index 314884a..02c2c96 100644 --- a/commands/usbgadget.c +++ b/commands/usbgadget.c @@ -20,6 +20,7 @@ */ #include #include +#include #include #include #include @@ -32,11 +33,11 @@ static int do_usbgadget(int argc, char *argv[]) { int opt, ret; - int acm = 1, create_serial = 0; - char *fastboot_opts = NULL, *dfu_opts = NULL; + int acm = 1, create_serial = 0, fastboot_set = 0; + const char *fastboot_opts = NULL, *dfu_opts = NULL; struct f_multi_opts *opts; - while ((opt = getopt(argc, argv, "asdA:D:")) > 0) { + while ((opt = getopt(argc, argv, "asdA::D:")) > 0) { switch (opt) { case 'a': acm = 1; @@ -51,6 +52,7 @@ break; case 'A': fastboot_opts = optarg; + fastboot_set = 1; break; case 'd': usb_multi_unregister(); @@ -60,6 +62,9 @@ } } + if (fastboot_set && !fastboot_opts) + fastboot_opts = getenv("global.usbgadget.fastboot_function"); + if (!dfu_opts && !fastboot_opts && !create_serial) return COMMAND_ERROR_USAGE;