diff options
Diffstat (limited to 'utils/hwstub/tools/hwstub_load.cpp')
| -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 6ca6079..7e79b20 100644 --- a/utils/hwstub/tools/hwstub_load.cpp +++ b/utils/hwstub/tools/hwstub_load.cpp @@ -113,6 +113,8 @@ void usage(void) printf(" --type/-t <t> Override file type\n"); printf(" --dev/-d <uri> Device URI (see below)\n"); printf(" --verbose/-v Display debug output\n"); + printf(" --noload Skip loading stage and only execute the given address\n"); + printf(" --noexec Skip execute stage and only load data the given address\n"); printf("file types:\n"); printf(" raw Load a raw binary blob\n"); printf(" rockbox Load a rockbox image produced by scramble\n"); @@ -129,8 +131,9 @@ int main(int argc, char **argv) { bool quiet = false; enum image_type_t type = IT_DETECT; - const char *uri = "usb:"; bool verbose = false; + const char *uri = hwstub::uri::default_uri().full_uri().c_str(); + bool no_load = false, no_exec = false; // parse command line while(1) @@ -142,10 +145,12 @@ int main(int argc, char **argv) {"type", required_argument, 0, 't'}, {"dev", required_argument, 0, 'd'}, {"verbose", no_argument, 0, 'v'}, + {"noload", no_argument, 0, 'e'}, + {"noexec", no_argument, 0, 'l'}, {0, 0, 0, 0} }; - int c = getopt_long(argc, argv, "?qt:d:v", long_options, NULL); + int c = getopt_long(argc, argv, "?qt:d:elv", long_options, NULL); if(c == -1) break; switch(c) @@ -176,6 +181,11 @@ int main(int argc, char **argv) break; case 'v': verbose = true; + case 'e': + no_load = true; + break; + case 'l': + no_exec = true; break; default: abort(); @@ -266,15 +276,33 @@ int main(int argc, char **argv) return 1; } - size_t out_size = size; - ret = hwdev->write(addr, buffer, out_size, false); - if(ret != hwstub::error::SUCCESS || out_size != size) + /* load */ + if(!no_load) + { + size_t out_size = size; + ret = hwdev->write(addr, buffer, out_size, false); + if(ret != hwstub::error::SUCCESS || out_size != size) + { + fprintf(stderr, "Image write failed: %s, %zu/%zu\n", error_string(ret).c_str(), + out_size, size); + goto Lerr; + } + } + else + printf("Skip load as requested\n"); + + /* exec */ + if(!no_exec) { - fprintf(stderr, "Image write failed: %s, %zu/%zu\n", error_string(ret).c_str(), - out_size, size); - goto Lerr; + ret = hwdev->exec(addr, HWSTUB_EXEC_JUMP); + if(ret != hwstub::error::SUCCESS) + { + fprintf(stderr, "Exec failed: %s\n", error_string(ret).c_str()); + goto Lerr; + } } - hwdev->exec(addr, HWSTUB_EXEC_JUMP); + else + printf("Skip exec as requested\n"); return 0; |