diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2016-08-02 15:37:30 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2017-01-24 15:25:14 +0100 |
commit | a36694eb4a1905ec45593ceff2fc20d7eff7c8d8 (patch) | |
tree | 8f52469d15940a2df599e5f0f97e73d4fecc1e3f /utils/hwstub/tools | |
parent | 56340f4cd0a6ab318a52d2a62ded36aad2946e1d (diff) | |
download | rockbox-a36694eb4a1905ec45593ceff2fc20d7eff7c8d8.tar.gz rockbox-a36694eb4a1905ec45593ceff2fc20d7eff7c8d8.zip |
hwstub: implement EXEC command over net
Apparently I completely forgot to implement it so using hwstub over net would
just fail all EXEC commands :-s
Change-Id: I0d0506cbbce9b86c9a4f19036dacc922d1e51338
Diffstat (limited to 'utils/hwstub/tools')
-rw-r--r-- | utils/hwstub/tools/hwstub_load.cpp | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/utils/hwstub/tools/hwstub_load.cpp b/utils/hwstub/tools/hwstub_load.cpp index 6ca6079294..7e79b206cb 100644 --- a/utils/hwstub/tools/hwstub_load.cpp +++ b/utils/hwstub/tools/hwstub_load.cpp | |||
@@ -113,6 +113,8 @@ void usage(void) | |||
113 | printf(" --type/-t <t> Override file type\n"); | 113 | printf(" --type/-t <t> Override file type\n"); |
114 | 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"); | 115 | printf(" --verbose/-v Display debug output\n"); |
116 | printf(" --noload Skip loading stage and only execute the given address\n"); | ||
117 | printf(" --noexec Skip execute stage and only load data the given address\n"); | ||
116 | printf("file types:\n"); | 118 | printf("file types:\n"); |
117 | printf(" raw Load a raw binary blob\n"); | 119 | printf(" raw Load a raw binary blob\n"); |
118 | printf(" rockbox Load a rockbox image produced by scramble\n"); | 120 | printf(" rockbox Load a rockbox image produced by scramble\n"); |
@@ -129,8 +131,9 @@ int main(int argc, char **argv) | |||
129 | { | 131 | { |
130 | bool quiet = false; | 132 | bool quiet = false; |
131 | enum image_type_t type = IT_DETECT; | 133 | enum image_type_t type = IT_DETECT; |
132 | const char *uri = "usb:"; | ||
133 | bool verbose = false; | 134 | bool verbose = false; |
135 | const char *uri = hwstub::uri::default_uri().full_uri().c_str(); | ||
136 | bool no_load = false, no_exec = false; | ||
134 | 137 | ||
135 | // parse command line | 138 | // parse command line |
136 | while(1) | 139 | while(1) |
@@ -142,10 +145,12 @@ int main(int argc, char **argv) | |||
142 | {"type", required_argument, 0, 't'}, | 145 | {"type", required_argument, 0, 't'}, |
143 | {"dev", required_argument, 0, 'd'}, | 146 | {"dev", required_argument, 0, 'd'}, |
144 | {"verbose", no_argument, 0, 'v'}, | 147 | {"verbose", no_argument, 0, 'v'}, |
148 | {"noload", no_argument, 0, 'e'}, | ||
149 | {"noexec", no_argument, 0, 'l'}, | ||
145 | {0, 0, 0, 0} | 150 | {0, 0, 0, 0} |
146 | }; | 151 | }; |
147 | 152 | ||
148 | int c = getopt_long(argc, argv, "?qt:d:v", long_options, NULL); | 153 | int c = getopt_long(argc, argv, "?qt:d:elv", long_options, NULL); |
149 | if(c == -1) | 154 | if(c == -1) |
150 | break; | 155 | break; |
151 | switch(c) | 156 | switch(c) |
@@ -176,6 +181,11 @@ int main(int argc, char **argv) | |||
176 | break; | 181 | break; |
177 | case 'v': | 182 | case 'v': |
178 | verbose = true; | 183 | verbose = true; |
184 | case 'e': | ||
185 | no_load = true; | ||
186 | break; | ||
187 | case 'l': | ||
188 | no_exec = true; | ||
179 | break; | 189 | break; |
180 | default: | 190 | default: |
181 | abort(); | 191 | abort(); |
@@ -266,15 +276,33 @@ int main(int argc, char **argv) | |||
266 | return 1; | 276 | return 1; |
267 | } | 277 | } |
268 | 278 | ||
269 | size_t out_size = size; | 279 | /* load */ |
270 | ret = hwdev->write(addr, buffer, out_size, false); | 280 | if(!no_load) |
271 | if(ret != hwstub::error::SUCCESS || out_size != size) | 281 | { |
282 | size_t out_size = size; | ||
283 | ret = hwdev->write(addr, buffer, out_size, false); | ||
284 | if(ret != hwstub::error::SUCCESS || out_size != size) | ||
285 | { | ||
286 | fprintf(stderr, "Image write failed: %s, %zu/%zu\n", error_string(ret).c_str(), | ||
287 | out_size, size); | ||
288 | goto Lerr; | ||
289 | } | ||
290 | } | ||
291 | else | ||
292 | printf("Skip load as requested\n"); | ||
293 | |||
294 | /* exec */ | ||
295 | if(!no_exec) | ||
272 | { | 296 | { |
273 | fprintf(stderr, "Image write failed: %s, %zu/%zu\n", error_string(ret).c_str(), | 297 | ret = hwdev->exec(addr, HWSTUB_EXEC_JUMP); |
274 | out_size, size); | 298 | if(ret != hwstub::error::SUCCESS) |
275 | goto Lerr; | 299 | { |
300 | fprintf(stderr, "Exec failed: %s\n", error_string(ret).c_str()); | ||
301 | goto Lerr; | ||
302 | } | ||
276 | } | 303 | } |
277 | hwdev->exec(addr, HWSTUB_EXEC_JUMP); | 304 | else |
305 | printf("Skip exec as requested\n"); | ||
278 | 306 | ||
279 | return 0; | 307 | return 0; |
280 | 308 | ||