diff options
Diffstat (limited to 'utils/hwstub/tools/hwstub_load.cpp')
-rw-r--r-- | utils/hwstub/tools/hwstub_load.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/utils/hwstub/tools/hwstub_load.cpp b/utils/hwstub/tools/hwstub_load.cpp index 87737939c3..6ca6079294 100644 --- a/utils/hwstub/tools/hwstub_load.cpp +++ b/utils/hwstub/tools/hwstub_load.cpp | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <getopt.h> | 24 | #include <getopt.h> |
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
26 | #include <ctype.h> | 26 | #include <ctype.h> |
27 | #include <iostream> | ||
27 | #include "hwstub.hpp" | 28 | #include "hwstub.hpp" |
28 | #include "hwstub_uri.hpp" | 29 | #include "hwstub_uri.hpp" |
29 | 30 | ||
@@ -111,6 +112,7 @@ void usage(void) | |||
111 | printf(" --quiet/-q Quiet output\n"); | 112 | printf(" --quiet/-q Quiet output\n"); |
112 | printf(" --type/-t <t> Override file type\n"); | 113 | printf(" --type/-t <t> Override file type\n"); |
113 | printf(" --dev/-d <uri> Device URI (see below)\n"); | 114 | printf(" --dev/-d <uri> Device URI (see below)\n"); |
115 | printf(" --verbose/-v Display debug output\n"); | ||
114 | printf("file types:\n"); | 116 | printf("file types:\n"); |
115 | printf(" raw Load a raw binary blob\n"); | 117 | printf(" raw Load a raw binary blob\n"); |
116 | printf(" rockbox Load a rockbox image produced by scramble\n"); | 118 | printf(" rockbox Load a rockbox image produced by scramble\n"); |
@@ -128,6 +130,7 @@ int main(int argc, char **argv) | |||
128 | bool quiet = false; | 130 | bool quiet = false; |
129 | enum image_type_t type = IT_DETECT; | 131 | enum image_type_t type = IT_DETECT; |
130 | const char *uri = "usb:"; | 132 | const char *uri = "usb:"; |
133 | bool verbose = false; | ||
131 | 134 | ||
132 | // parse command line | 135 | // parse command line |
133 | while(1) | 136 | while(1) |
@@ -138,10 +141,11 @@ int main(int argc, char **argv) | |||
138 | {"quiet", no_argument, 0, 'q'}, | 141 | {"quiet", no_argument, 0, 'q'}, |
139 | {"type", required_argument, 0, 't'}, | 142 | {"type", required_argument, 0, 't'}, |
140 | {"dev", required_argument, 0, 'd'}, | 143 | {"dev", required_argument, 0, 'd'}, |
144 | {"verbose", no_argument, 0, 'v'}, | ||
141 | {0, 0, 0, 0} | 145 | {0, 0, 0, 0} |
142 | }; | 146 | }; |
143 | 147 | ||
144 | int c = getopt_long(argc, argv, "?qt:d:", long_options, NULL); | 148 | int c = getopt_long(argc, argv, "?qt:d:v", long_options, NULL); |
145 | if(c == -1) | 149 | if(c == -1) |
146 | break; | 150 | break; |
147 | switch(c) | 151 | switch(c) |
@@ -170,6 +174,9 @@ int main(int argc, char **argv) | |||
170 | case 'd': | 174 | case 'd': |
171 | uri = optarg; | 175 | uri = optarg; |
172 | break; | 176 | break; |
177 | case 'v': | ||
178 | verbose = true; | ||
179 | break; | ||
173 | default: | 180 | default: |
174 | abort(); | 181 | abort(); |
175 | } | 182 | } |
@@ -236,6 +243,8 @@ int main(int argc, char **argv) | |||
236 | printf("Cannot create context: %s\n", errstr.c_str()); | 243 | printf("Cannot create context: %s\n", errstr.c_str()); |
237 | return 1; | 244 | return 1; |
238 | } | 245 | } |
246 | if(verbose) | ||
247 | hwctx->set_debug(std::cout); | ||
239 | std::vector<std::shared_ptr<hwstub::device>> list; | 248 | std::vector<std::shared_ptr<hwstub::device>> list; |
240 | hwstub::error ret = hwctx->get_device_list(list); | 249 | hwstub::error ret = hwctx->get_device_list(list); |
241 | if(ret != hwstub::error::SUCCESS) | 250 | if(ret != hwstub::error::SUCCESS) |
@@ -277,7 +286,7 @@ int main(int argc, char **argv) | |||
277 | char buffer[128]; | 286 | char buffer[128]; |
278 | size_t size = sizeof(buffer) - 1; | 287 | size_t size = sizeof(buffer) - 1; |
279 | hwstub::error err = hwdev->get_log(buffer, size); | 288 | hwstub::error err = hwdev->get_log(buffer, size); |
280 | if(err != hwstub::error::SUCCESS) | 289 | if(err != error::SUCCESS || size == 0) |
281 | break; | 290 | break; |
282 | buffer[size] = 0; | 291 | buffer[size] = 0; |
283 | fprintf(stderr, "%s", buffer); | 292 | fprintf(stderr, "%s", buffer); |